From b6635fb14d7935992aa004a477ac877804675794 Mon Sep 17 00:00:00 2001 From: mo khan Date: Thu, 20 Feb 2014 18:52:21 -0700 Subject: use named parameters for better readability and ensure a json response is returned. --- spec/controllers/v1/liceneses_controller_spec.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'spec/controllers') diff --git a/spec/controllers/v1/liceneses_controller_spec.rb b/spec/controllers/v1/liceneses_controller_spec.rb index 5964556..b2eb705 100644 --- a/spec/controllers/v1/liceneses_controller_spec.rb +++ b/spec/controllers/v1/liceneses_controller_spec.rb @@ -5,7 +5,7 @@ describe V1::LicensesController do let(:licenses) { [] } it "returns the first page of licenses" do - License.stub(:most_recent).with(1, 10).and_return(licenses) + License.stub(:most_recent).with(page: 1, per_page: 10).and_return(licenses) xhr :get, :index @@ -14,7 +14,7 @@ describe V1::LicensesController do end it "returns the second page of licenses" do - License.stub(:most_recent).with(2, 10).and_return(licenses) + License.stub(:most_recent).with(page: 2, per_page: 10).and_return(licenses) xhr :get, :index, page: 2 @@ -23,11 +23,18 @@ describe V1::LicensesController do end it "returns the specified number of results" do - License.stub(:most_recent).with(1, 100).and_return(licenses) + License.stub(:most_recent).with(page: 1, per_page: 100).and_return(licenses) xhr :get, :index, per_page: 100 response.should be_success assigns(:licenses).should == licenses end + + it "returns a json response" do + License.stub(:most_recent).with(page: 1, per_page: 10).and_return(licenses) + + xhr :get, :index + -> { JSON.parse(response.body) }.should_not raise_error + end end end -- cgit v1.2.3