aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/api_controller_spec.rb
diff options
context:
space:
mode:
authorRobin Houston <robin.houston@gmail.com>2012-06-18 12:55:11 +0100
committerRobin Houston <robin.houston@gmail.com>2012-06-18 12:55:11 +0100
commit89459d3902583fa3d6dad78462d2bf2fa6f94db6 (patch)
treedbd1a4cb6e361d8470ed2917403bc07a323d4c71 /spec/controllers/api_controller_spec.rb
parent1ff635e834c004600faa445fc53e757996cde30d (diff)
API controller tests all pass
Diffstat (limited to 'spec/controllers/api_controller_spec.rb')
-rw-r--r--spec/controllers/api_controller_spec.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb
index a39471775..1f65576b6 100644
--- a/spec/controllers/api_controller_spec.rb
+++ b/spec/controllers/api_controller_spec.rb
@@ -1,5 +1,17 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+def normalise_whitespace(s)
+ s = s.gsub(/^\s+|\s+$/, "")
+ s = s.gsub(/\s+/, " ")
+ return s
+end
+
+Spec::Matchers.define :be_equal_modulo_whitespace_to do |expected|
+ match do |actual|
+ normalise_whitespace(actual) == normalise_whitespace(expected)
+ end
+end
+
describe ApiController, "when using the API" do
it "should check the API key" do
request_data = {
@@ -99,7 +111,7 @@ describe ApiController, "when using the API" do
incoming_message = incoming_messages[0]
incoming_message.sent_at.should == Time.iso8601(sent_at)
- incoming_message.get_main_body_text_folded.should == response_body
+ incoming_message.get_main_body_text_folded.should be_equal_modulo_whitespace_to(response_body)
end
it "should add a followup to a request" do
@@ -221,7 +233,7 @@ describe ApiController, "when using the API" do
incoming_message = incoming_messages[0]
incoming_message.sent_at.should == Time.iso8601(sent_at)
- incoming_message.get_main_body_text_folded.should == response_body
+ incoming_message.get_main_body_text_folded.should be_equal_modulo_whitespace_to(response_body)
# Get the attachment
attachments = incoming_message.get_attachments_for_display
@@ -229,7 +241,7 @@ describe ApiController, "when using the API" do
attachment = attachments[0]
attachment.filename.should == "tfl.pdf"
- attachment.body.should == open("files/tfl.pdf", &:read)
+ attachment.body.should == load_file_fixture("tfl.pdf")
end
it "should show information about a request" do