diff options
author | Henare Degan <henare.degan@gmail.com> | 2012-12-12 13:47:12 +1100 |
---|---|---|
committer | Henare Degan <henare.degan@gmail.com> | 2012-12-12 15:27:57 +1100 |
commit | 6e63699743941457962d53827e683fc085555aae (patch) | |
tree | 5f6cd31ebb3cd2352288cd7623f5dfc25c43cd8f /spec/support/load_file_fixtures.rb | |
parent | 0969c6997e3795fa8c2b0d77b283b9746369a0b8 (diff) |
safe_mock_model doesn't seem to be needed, also tested in Ruby 1.9
Diffstat (limited to 'spec/support/load_file_fixtures.rb')
-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 |