diff --git a/lib/tankard/api/beer.rb b/lib/tankard/api/beer.rb index c68d473..59dfd8f 100644 --- a/lib/tankard/api/beer.rb +++ b/lib/tankard/api/beer.rb @@ -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 @@ -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 @@ -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 @@ -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] diff --git a/spec/tankard/api/beer_spec.rb b/spec/tankard/api/beer_spec.rb index 9868fe7..0a1ccf5 100644 --- a/spec/tankard/api/beer_spec.rb +++ b/spec/tankard/api/beer_spec.rb @@ -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 @@ -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 @@ -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 @@ -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