diff options
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/load_file_fixtures.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/support/load_file_fixtures.rb b/spec/support/load_file_fixtures.rb new file mode 100644 index 000000000..08079f654 --- /dev/null +++ b/spec/support/load_file_fixtures.rb @@ -0,0 +1,14 @@ +def file_fixture_name(file_name) + return File.join(RSpec.configuration.fixture_path, "files", file_name) +end + +def load_file_fixture(file_name, as_binary=false) + file_name = file_fixture_name(file_name) + content = File.open(file_name, 'r') do |file| + if as_binary + file.set_encoding(Encoding::BINARY) if file.respond_to?(:set_encoding) + end + file.read + end + return content +end |