Skip to content

Commit

Permalink
Initial rspec3 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewshafer committed Jan 4, 2015
1 parent eeca835 commit d54ecab
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 63 deletions.
8 changes: 4 additions & 4 deletions spec/tankard/api/adjunct_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

describe '#find' do
before do
@request.stub(:get).with('adjunct/valid1', {}).and_return('data' => 'valid1_found')
@request.stub(:get).with('adjunct/valid2', {}).and_return('data' => 'valid2_found')
@request.stub(:get).with('adjunct/invalid1', {}).and_raise(Tankard::Error::HttpError)
@request.stub(:get).with('adjunct/invalid2', {}).and_raise(Tankard::Error::HttpError)
allow(@request).to receive(:get).with('adjunct/valid1', {}).and_return('data' => 'valid1_found')
allow(@request).to receive(:get).with('adjunct/valid2', {}).and_return('data' => 'valid2_found')
allow(@request).to receive(:get).with('adjunct/invalid1', {}).and_raise(Tankard::Error::HttpError)
allow(@request).to receive(:get).with('adjunct/invalid2', {}).and_raise(Tankard::Error::HttpError)
end

it_should_behave_like 'the find method' do
Expand Down
12 changes: 6 additions & 6 deletions spec/tankard/api/beer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

describe '#find' do
before do
@request.stub(:get).with('beer/valid1', {}).and_return('data' => 'valid1_found')
@request.stub(:get).with('beer/valid2', {}).and_return('data' => 'valid2_found')
@request.stub(:get).with('beer/invalid1', {}).and_raise(Tankard::Error::HttpError)
@request.stub(:get).with('beer/invalid2', {}).and_raise(Tankard::Error::HttpError)
allow(@request).to receive(:get).with('beer/valid1', {}).and_return('data' => 'valid1_found')
allow(@request).to receive(:get).with('beer/valid2', {}).and_return('data' => 'valid2_found')
allow(@request).to receive(:get).with('beer/invalid1', {}).and_raise(Tankard::Error::HttpError)
allow(@request).to receive(:get).with('beer/invalid2', {}).and_raise(Tankard::Error::HttpError)
end

it_should_behave_like 'the find method' do
Expand Down Expand Up @@ -224,8 +224,8 @@

describe '#http_request_uri' do
before do
beer.stub(:route).and_return('beer')
beer.stub(:raise_if_no_id_in_options).and_return('123')
allow(beer).to receive(:route).and_return('beer')
allow(beer).to receive(:raise_if_no_id_in_options).and_return('123')
end

context 'no endpoint is set' do
Expand Down
2 changes: 1 addition & 1 deletion spec/tankard/api/categories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

describe 'when making a request' do
it 'returns the data portion of the request' do
@request.stub(:get).with('categories', {}).and_return('data' => %w(test1 test2))
allow(@request).to receive(:get).with('categories', {}).and_return('data' => %w(test1 test2))
expect(categories.map { |x| x }).to eql(%w(test1 test2))
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/tankard/api/category_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

describe '#find' do
before do
@request.stub(:get).with('category/1', {}).and_return('data' => 'valid1_found')
@request.stub(:get).with('category/2', {}).and_return('data' => 'valid2_found')
@request.stub(:get).with('category/3', {}).and_raise(Tankard::Error::HttpError)
@request.stub(:get).with('category/4', {}).and_raise(Tankard::Error::HttpError)
allow(@request).to receive(:get).with('category/1', {}).and_return('data' => 'valid1_found')
allow(@request).to receive(:get).with('category/2', {}).and_return('data' => 'valid2_found')
allow(@request).to receive(:get).with('category/3', {}).and_raise(Tankard::Error::HttpError)
allow(@request).to receive(:get).with('category/4', {}).and_raise(Tankard::Error::HttpError)
end

it_should_behave_like 'the find method' do
Expand Down
8 changes: 4 additions & 4 deletions spec/tankard/api/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@

describe '#each' do
it 'should call raise_if_required_options_not_set' do
search.stub(:find_on_single_or_all_pages).and_return(nil)
search.should_receive(:raise_if_required_options_not_set)
allow(search).to receive(:find_on_single_or_all_pages).and_return(nil)
expect(search).to receive(:raise_if_required_options_not_set)
search.each
end

it 'calls the super object with the block' do
block = -> x { x }
search.stub(:raise_if_required_options_not_set).and_return(nil)
search.should_receive(:find_on_single_or_all_pages)
allow(search).to receive(:raise_if_required_options_not_set).and_return(nil)
expect(search).to receive(:find_on_single_or_all_pages)
search.each(&block)
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/tankard/api/style_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

describe '#find' do
before do
@request.stub(:get).with('style/1', {}).and_return('data' => 'valid1_found')
@request.stub(:get).with('style/2', {}).and_return('data' => 'valid2_found')
@request.stub(:get).with('style/3', {}).and_raise(Tankard::Error::HttpError)
@request.stub(:get).with('style/4', {}).and_raise(Tankard::Error::HttpError)
allow(@request).to receive(:get).with('style/1', {}).and_return('data' => 'valid1_found')
allow(@request).to receive(:get).with('style/2', {}).and_return('data' => 'valid2_found')
allow(@request).to receive(:get).with('style/3', {}).and_raise(Tankard::Error::HttpError)
allow(@request).to receive(:get).with('style/4', {}).and_raise(Tankard::Error::HttpError)
end

it_should_behave_like 'the find method' do
Expand Down
2 changes: 1 addition & 1 deletion spec/tankard/api/styles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

describe 'when making a request' do
it 'returns the data portion of the request' do
@request.stub(:get).with('styles', {}).and_return('data' => %w(test1 test2))
allow(@request).to receive(:get).with('styles', {}).and_return('data' => %w(test1 test2))
expect(styles.map { |x| x }).to eql(%w(test1 test2))
end
end
Expand Down
30 changes: 15 additions & 15 deletions spec/tankard/api/utils/page_finders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,58 +48,58 @@

describe '#find_on_single_page' do
before do
finders.stub(:http_request_uri).and_return('test')
finders.stub(:http_client).and_return(@request)
finders.stub(:call_block_with_data).with(['test'], nil)
allow(finders).to receive(:http_request_uri).and_return('test')
allow(finders).to receive(:http_client).and_return(@request)
allow(finders).to receive(:call_block_with_data).with(['test'], nil)
end

it 'sends response[data] to call_block_with_data' do
finders.stub(:get_request).and_return('data' => ['test'])
allow(finders).to receive(:get_request).and_return('data' => ['test'])
finders.send(:find_on_single_page, {}, nil)
end

it 'returns 0 when number of pages is not set' do
finders.stub(:get_request).and_return('data' => ['test'])
allow(finders).to receive(:get_request).and_return('data' => ['test'])
expect(finders.send(:find_on_single_page, {}, nil)).to eql(0)
end

it 'returns a value when number of pages is set' do
finders.stub(:get_request).and_return('data' => ['test'], 'numberOfPages' => '3')
allow(finders).to receive(:get_request).and_return('data' => ['test'], 'numberOfPages' => '3')
expect(finders.send(:find_on_single_page, {}, nil)).to eql(3)
end
end

describe '#find_on_all_pages' do
it 'only sets the page when the page is greater than 1' do
finders.should_receive(:find_on_single_page).with({}, nil).and_return(2)
finders.should_not_receive(:find_on_single_page).with({ p: 1 }, nil)
finders.should_receive(:find_on_single_page).with({ p: 2 }, nil).and_return(2)
expect(finders).to receive(:find_on_single_page).with({}, nil).and_return(2)
expect(finders).not_to receive(:find_on_single_page).with({ p: 1 }, nil)
expect(finders).to receive(:find_on_single_page).with({ p: 2 }, nil).and_return(2)

finders.send(:find_on_all_pages, {}, nil)
end
end

describe '#find_on_single_or_all_pages' do
it 'calls find_with_options when a page is set in options' do
finders.should_receive(:find_on_single_page).with({ p: 2 }, nil)
expect(finders).to receive(:find_on_single_page).with({ p: 2 }, nil)
finders.send(:find_on_single_or_all_pages, { p: 2 }, nil)
end

it 'calls find_on_all_pages when a page is not set in options' do
finders.should_receive(:find_on_all_pages).with({}, nil)
expect(finders).to receive(:find_on_all_pages).with({}, nil)
finders.send(:find_on_single_or_all_pages, {}, nil)
end
end

describe '#each' do
before do
finders.stub(:http_request_uri).and_return('test')
finders.stub(:http_client).and_return(nil)
finders.stub(:http_request_parameters).and_return({})
allow(finders).to receive(:http_request_uri).and_return('test')
allow(finders).to receive(:http_client).and_return(nil)
allow(finders).to receive(:http_request_parameters).and_return({})
end

it 'calls find_on_single_or_all_pages' do
finders.should_receive(:find_on_single_or_all_pages).with({}, nil)
expect(finders).to receive(:find_on_single_or_all_pages).with({}, nil)
finders.each
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/tankard/api/yeast_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

describe '#find' do
before do
@request.stub(:get).with('yeast/1', {}).and_return('data' => 'valid1_found')
@request.stub(:get).with('yeast/2', {}).and_return('data' => 'valid2_found')
@request.stub(:get).with('yeast/3', {}).and_raise(Tankard::Error::HttpError)
@request.stub(:get).with('yeast/4', {}).and_raise(Tankard::Error::HttpError)
allow(@request).to receive(:get).with('yeast/1', {}).and_return('data' => 'valid1_found')
allow(@request).to receive(:get).with('yeast/2', {}).and_return('data' => 'valid2_found')
allow(@request).to receive(:get).with('yeast/3', {}).and_raise(Tankard::Error::HttpError)
allow(@request).to receive(:get).with('yeast/4', {}).and_raise(Tankard::Error::HttpError)
end

it_should_behave_like 'the find method' do
Expand Down
36 changes: 18 additions & 18 deletions spec/tankard/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
context 'when passed a hash of options' do
before do
@request = double('request')
Tankard::Request.stub(:new).and_return(@request)
allow(Tankard::Request).to receive(:new).and_return(@request)
end

it 'passes the options to the beer object' do
Tankard::Api::Adjunct.should_receive(:new).with(@request, test: 123)
expect(Tankard::Api::Adjunct).to receive(:new).with(@request, test: 123)
client.adjunct(test: 123)
end
end
Expand All @@ -35,11 +35,11 @@
context 'when passed a hash of options' do
before do
@request = double('request')
Tankard::Request.stub(:new).and_return(@request)
allow(Tankard::Request).to receive(:new).and_return(@request)
end

it 'passes the options to the beer object' do
Tankard::Api::Adjuncts.should_receive(:new).with(@request, test: 123)
expect(Tankard::Api::Adjuncts).to receive(:new).with(@request, test: 123)
client.adjuncts(test: 123)
end
end
Expand All @@ -56,11 +56,11 @@
context 'when passed a hash of options' do
before do
@request = double('request')
Tankard::Request.stub(:new).and_return(@request)
allow(Tankard::Request).to receive(:new).and_return(@request)
end

it 'passes the options to the beer object' do
Tankard::Api::Beer.should_receive(:new).with(@request, test: 123)
expect(Tankard::Api::Beer).to receive(:new).with(@request, test: 123)
client.beer(test: 123)
end
end
Expand All @@ -77,11 +77,11 @@
context 'when passed a hash of options' do
before do
@request = double('request')
Tankard::Request.stub(:new).and_return(@request)
allow(Tankard::Request).to receive(:new).and_return(@request)
end

it 'passes the options to the beer object' do
Tankard::Api::Beers.should_receive(:new).with(@request, test: 123)
expect(Tankard::Api::Beers).to receive(:new).with(@request, test: 123)
client.beers(test: 123)
end
end
Expand All @@ -107,11 +107,11 @@
context 'when passed a hash of options' do
before do
@request = double('request')
Tankard::Request.stub(:new).and_return(@request)
allow(Tankard::Request).to receive(:new).and_return(@request)
end

it 'passes the options to the category object' do
Tankard::Api::Category.should_receive(:new).with(@request, test: 123)
expect(Tankard::Api::Category).to receive(:new).with(@request, test: 123)
client.category(test: 123)
end
end
Expand All @@ -128,11 +128,11 @@
context 'when passed a hash of options' do
before do
@request = double('request')
Tankard::Request.stub(:new).and_return(@request)
allow(Tankard::Request).to receive(:new).and_return(@request)
end

it 'passes the options to the search object' do
Tankard::Api::Search.should_receive(:new).with(@request, test: 123)
expect(Tankard::Api::Search).to receive(:new).with(@request, test: 123)
client.search(test: 123)
end
end
Expand All @@ -158,11 +158,11 @@
context 'when passed a hash of options' do
before do
@request = double('request')
Tankard::Request.stub(:new).and_return(@request)
allow(Tankard::Request).to receive(:new).and_return(@request)
end

it 'passes the options to the style object' do
Tankard::Api::Style.should_receive(:new).with(@request, test: 123)
expect(Tankard::Api::Style).to receive(:new).with(@request, test: 123)
client.style(test: 123)
end
end
Expand All @@ -179,11 +179,11 @@
context 'when passed a hash of options' do
before do
@request = double('request')
Tankard::Request.stub(:new).and_return(@request)
allow(Tankard::Request).to receive(:new).and_return(@request)
end

it 'passes the options ot the yeast object' do
Tankard::Api::Yeast.should_receive(:new).with(@request, test: 123)
expect(Tankard::Api::Yeast).to receive(:new).with(@request, test: 123)
client.yeast(test: 123)
end
end
Expand All @@ -200,11 +200,11 @@
context 'when passed a hash of options' do
before do
@request = double('request')
Tankard::Request.stub(:new).and_return(@request)
allow(Tankard::Request).to receive(:new).and_return(@request)
end

it 'passes the options to the yeasts object' do
Tankard::Api::Yeasts.should_receive(:new).with(@request, test: 123)
expect(Tankard::Api::Yeasts).to receive(:new).with(@request, test: 123)
client.yeasts(test: 123)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/tankard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Tankard do
context 'when delegating to a client' do
before do
Tankard::Client.any_instance.stub(:test).and_return('testing')
allow_any_instance_of(Tankard::Client).to receive(:test).and_return('testing')
end

it 'delegates to Tankard::Client' do
Expand Down
2 changes: 1 addition & 1 deletion tankard.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_development_dependency 'rake', '~> 10.4'
spec.add_development_dependency 'rspec', '~> 2.14'
spec.add_development_dependency 'rspec', '~> 3.1'
spec.add_development_dependency 'webmock', '~> 1.20'
spec.add_development_dependency 'simplecov', '~> 0.9'
spec.add_development_dependency 'coveralls', '~> 0.7'
Expand Down

0 comments on commit d54ecab

Please sign in to comment.