require "spec_helper" describe V1::LicensesController do describe :index do let(:licenses) { [] } it "returns the first page of licenses" do License.stub(:most_recent).with(page: 1, per_page: 10).and_return(licenses) get :index response.should be_success assigns(:licenses).should == licenses end it "returns the second page of licenses" do License.stub(:most_recent).with(page: 2, per_page: 10).and_return(licenses) get :index, page: 2 response.should be_success assigns(:licenses).should == licenses end it "returns the specified number of results" do License.stub(:most_recent).with(page: 1, per_page: 100).and_return(licenses) get :index, per_page: 100 response.should be_success assigns(:licenses).should == licenses end end describe :show do let(:license) { License.new(id: SecureRandom.uuid) } before :each do License.stub(:find).with(license.id).and_return(license) get :show, id: license.id end it "returns the correct license" do assigns(:license).should == license end end end