Skip to content

Commit

Permalink
Add support for the rest of the beer endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewshafer committed Apr 11, 2014
1 parent 8202b43 commit 6528782
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/tankard/api/beer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def id(beer_id)
self
end

# Sets the request to beer/:id/adjuncts
#
# @return [self] returns itself
def adjuncts
@http_request_parameters.endpoint = 'adjuncts'
self
end

# Sets the request to beer/:id/breweries
#
# @return [self] returns itself
Expand All @@ -67,6 +75,22 @@ def events
self
end

# Sets the request to beer/:id/fermentables
#
# @return [self] returns itself
def fermentables
@http_request_parameters.endpoint = 'fermentables'
self
end

# Sets the request to beer/:id/hops
#
# @return [self] returns itself
def hops
@http_request_parameters.endpoint = 'hops'
self
end

# Sets the request to beer/:id/ingredients
#
# @return [self] returns itself
Expand All @@ -83,6 +107,14 @@ def social_accounts
self
end

# Sets the reques to beer/:id/upcs
#
# @return [self] returns itself
def upcs
@http_request_parameters.endpoint = 'upcs'
self
end

# Sets the request to beer/:id/variations
#
# @return [self] returns itself
Expand All @@ -91,6 +123,14 @@ def variations
self
end

# Sets the reques to beer/:id/yeasts
#
# @return [self] returns itself
def yeasts
@http_request_parameters.endpoint = 'yeasts'
self
end

# Additional parameters to send with the request
#
# @param options [Hash]
Expand Down
65 changes: 65 additions & 0 deletions spec/tankard/api/beer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@
end
end

describe '#adjuncts' do

it 'sets the options[:endpoint] to adjuncts' do
beer.adjuncts
beer_options = beer.instance_variable_get(:"@http_request_parameters")
expect(beer_options[:endpoint]).to eql('adjuncts')
end

it 'returns itself' do
expect(beer.object_id).to eql(beer.adjuncts.object_id)
end
end

describe '#breweries' do

it 'sets the options[:endpoint] to breweries' do
Expand All @@ -65,6 +78,32 @@
end
end

describe '#fermentables' do

it 'sets the options[:endpoint] to fermentables' do
beer.fermentables
beer_options = beer.instance_variable_get(:"@http_request_parameters")
expect(beer_options[:endpoint]).to eql('fermentables')
end

it 'returns itself' do
expect(beer.object_id).to eql(beer.fermentables.object_id)
end
end

describe '#hops' do

it 'sets the options[:endpoint] to hops' do
beer.hops
beer_options = beer.instance_variable_get(:"@http_request_parameters")
expect(beer_options[:endpoint]).to eql('hops')
end

it 'returns itself' do
expect(beer.object_id).to eql(beer.hops.object_id)
end
end

describe '#ingredients' do

it 'sets the options[:endpoint] to ingredients' do
Expand All @@ -91,6 +130,19 @@
end
end

describe '#upcs' do

it 'sets the options[:endpoint] to upcs' do
beer.upcs
beer_options = beer.instance_variable_get(:"@http_request_parameters")
expect(beer_options[:endpoint]).to eql('upcs')
end

it 'returns itself' do
expect(beer.object_id).to eql(beer.upcs.object_id)
end
end

describe '#variations' do

it 'sets the options[:endpoint] to variations' do
Expand All @@ -104,6 +156,19 @@
end
end

describe '#yeasts' do

it 'sets the options[:endpoint] to yeasts' do
beer.yeasts
beer_options = beer.instance_variable_get(:"@http_request_parameters")
expect(beer_options[:endpoint]).to eql('yeasts')
end

it 'returns itself' do
expect(beer.object_id).to eql(beer.yeasts.object_id)
end
end

describe '#params' do

it 'sets parameters' do
Expand Down

0 comments on commit 6528782

Please sign in to comment.