diff options
| author | mo khan <mo@mokhan.ca> | 2014-02-20 18:52:21 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-02-20 18:52:21 -0700 |
| commit | b6635fb14d7935992aa004a477ac877804675794 (patch) | |
| tree | 1758aadace34794f33fd3f407393fd8230a64fd8 /spec/controllers/v1 | |
| parent | 4f506a2366115e61c6f0cbb5ae154e2555b9d1ca (diff) | |
use named parameters for better readability and ensure a json response is returned.
Diffstat (limited to 'spec/controllers/v1')
| -rw-r--r-- | spec/controllers/v1/liceneses_controller_spec.rb | 13 |
1 files changed, 10 insertions, 3 deletions
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 |
