From c8de5ff799bb282a586185dbc6c86dad412e6204 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 4 Jan 2013 12:18:07 +1100 Subject: response.status now returns an integer --- spec/controllers/api_controller_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'spec/controllers/api_controller_spec.rb') diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb index 1c320f85c..aeb452afe 100644 --- a/spec/controllers/api_controller_spec.rb +++ b/spec/controllers/api_controller_spec.rb @@ -173,7 +173,7 @@ describe ApiController, "when using the API" do "body" => "xxx" }.to_json - response.status.should == "500 Internal Server Error" + response.status.should == 500 ActiveSupport::JSON.decode(response.body)["errors"].should == [ "Request #{request_id} cannot be updated using the API"] @@ -195,7 +195,7 @@ describe ApiController, "when using the API" do "body" => "xxx" }.to_json - response.status.should == "500 Internal Server Error" + response.status.should == 500 ActiveSupport::JSON.decode(response.body)["errors"].should == [ "You do not own request #{request_id}"] @@ -218,7 +218,7 @@ describe ApiController, "when using the API" do # Make sure it worked - response.status.to_i.should == 500 + response.status.should == 500 errors = ActiveSupport::JSON.decode(response.body)["errors"] errors.should == ["You cannot attach files to messages in the 'request' direction"] end @@ -360,7 +360,7 @@ describe ApiController, "when using the API" do "sent_at" => sent_at, "body" => response_body }.to_json - response.status.should == "404 Not Found" + response.status.should == 404 ActiveSupport::JSON.decode(response.body)["errors"].should == ["Could not find request 123459876"] end @@ -376,7 +376,7 @@ describe ApiController, "when using the API" do "sent_at" => sent_at, "body" => response_body }.to_json - response.status.should == "500 Internal Server Error" + response.status.should == 500 ActiveSupport::JSON.decode(response.body)["errors"].should == ["Request #{request_id} cannot be updated using the API"] end end -- cgit v1.2.3 From fc326e9b3d1750c28cacd680d944c8bed302bc61 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 4 Jan 2013 12:24:42 +1100 Subject: No need to specify extension when testing particular template is rendered --- spec/controllers/api_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/controllers/api_controller_spec.rb') diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb index aeb452afe..8dc8e2990 100644 --- a/spec/controllers/api_controller_spec.rb +++ b/spec/controllers/api_controller_spec.rb @@ -286,7 +286,7 @@ describe ApiController, "when using the API" do :feed_type => "atom" response.should be_success - response.should render_template("api/request_events.atom") + response.should render_template("api/request_events") assigns[:events].size.should > 0 assigns[:events].each do |event| event.info_request.public_body.should == public_bodies(:geraldine_public_body) @@ -341,7 +341,7 @@ describe ApiController, "when using the API" do :feed_type => "atom" response.should be_success - response.should render_template("api/request_events.atom") + response.should render_template("api/request_events") assigns[:events].size.should > 0 assigns[:events].each do |event| event.created_at.should >= Date.new(2010, 1, 1) -- cgit v1.2.3 From bc0ce470ade27fed5376e983d72e9f495d4c0405 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Mon, 28 Jan 2013 16:33:17 +1100 Subject: Use preceding slash on paths to fixtures files --- spec/controllers/api_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/controllers/api_controller_spec.rb') diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb index 8dc8e2990..2de1c5071 100644 --- a/spec/controllers/api_controller_spec.rb +++ b/spec/controllers/api_controller_spec.rb @@ -213,7 +213,7 @@ describe ApiController, "when using the API" do "body" => "Are you joking, or are you serious?" }.to_json, :attachments => [ - fixture_file_upload("files/tfl.pdf") + fixture_file_upload("/files/tfl.pdf") ] @@ -242,7 +242,7 @@ describe ApiController, "when using the API" do "body" => response_body }.to_json, :attachments => [ - fixture_file_upload("files/tfl.pdf") + fixture_file_upload("/files/tfl.pdf") ] # And make sure it worked -- cgit v1.2.3 From 8f1caab7990dc417e32b14cbb5f00c34a0ddc10c Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Thu, 14 Feb 2013 19:02:03 +1100 Subject: Spec is deprecated in favour of RSpec --- spec/controllers/api_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/controllers/api_controller_spec.rb') diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb index 2de1c5071..749be9f85 100644 --- a/spec/controllers/api_controller_spec.rb +++ b/spec/controllers/api_controller_spec.rb @@ -7,7 +7,7 @@ def normalise_whitespace(s) return s end -Spec::Matchers.define :be_equal_modulo_whitespace_to do |expected| +RSpec::Matchers.define :be_equal_modulo_whitespace_to do |expected| match do |actual| normalise_whitespace(actual) == normalise_whitespace(expected) end -- cgit v1.2.3 From 9a5ef164ba29a8f56b3e2f42edf83d732613738f Mon Sep 17 00:00:00 2001 From: Mark Longair Date: Thu, 9 May 2013 14:19:50 +0100 Subject: Switch to just loading fixtures in tests as binary strings The data loaded with load_file_fixture is generally used in the tests as if it were binary data received from the MTA, so just load it as binary data - in Ruby 1.9 this means that it will end up with the encoding ASCII-8BIT. The same is the case when reading data from a fixture file in receive_incoming_mail. --- spec/controllers/api_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/controllers/api_controller_spec.rb') diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb index 749be9f85..66b8e33f0 100644 --- a/spec/controllers/api_controller_spec.rb +++ b/spec/controllers/api_controller_spec.rb @@ -259,7 +259,7 @@ describe ApiController, "when using the API" do attachments.size.should == 1 attachment = attachments[0] attachment.filename.should == "tfl.pdf" - attachment.body.should == load_file_fixture("tfl.pdf", as_binary=true) + attachment.body.should == load_file_fixture("tfl.pdf") end it "should show information about a request" do -- cgit v1.2.3