aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--spec/controllers/api_controller_spec.rb3
-rw-r--r--spec/spec_helper.rb9
2 files changed, 8 insertions, 4 deletions
diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb
index 5e148a9f5..1c320f85c 100644
--- a/spec/controllers/api_controller_spec.rb
+++ b/spec/controllers/api_controller_spec.rb
@@ -258,9 +258,8 @@ describe ApiController, "when using the API" do
attachments = incoming_message.get_attachments_for_display
attachments.size.should == 1
attachment = attachments[0]
-
attachment.filename.should == "tfl.pdf"
- attachment.body.should == load_file_fixture("tfl.pdf")
+ attachment.body.should == load_file_fixture("tfl.pdf", as_binary=true)
end
it "should show information about a request" do
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