diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-11-14 13:10:51 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-12-04 12:47:32 +0000 |
commit | 9af56ac5901790fb265a6492531eecbe5dd32f73 (patch) | |
tree | e0694195d9b1a54dd1765c9d22b1f0024de84d54 /spec/spec_helper.rb | |
parent | 2ad6b55a528ac0f747b6804157ed08acb616a437 (diff) |
Add option to load_file_fixture to specify that the file contents should just be loaded as binary.
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r-- | spec/spec_helper.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d4dad591d..9621211f5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -93,9 +93,14 @@ def file_fixture_name(file_name) return File.join(Spec::Runner.configuration.fixture_path, "files", file_name) end -def load_file_fixture(file_name) +def load_file_fixture(file_name, as_binary=false) file_name = file_fixture_name(file_name) - content = File.read(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 |