spec/a2z/requests/response_group_spec.rb in a2z-0.1.1 vs spec/a2z/requests/response_group_spec.rb in a2z-0.1.2

- old
+ new

@@ -4,11 +4,55 @@ subject do A2z::Requests::ResponseGroup.new(value, &block) end let(:value) { nil } - let(:block) { Proc.new { } } + let(:block) { proc { } } describe '#params' do - it 'should return a hash' + specify { subject.params.should be_a Hash } + + describe 'when value is a string' do + let(:value) { 'OfferSummary' } + + it 'sets the response group' do + subject.params['ResponseGroup'].should eq 'OfferSummary' + end + end + + describe 'when value is an array' do + let(:value) { %w(OfferSummary Images) } + + it 'sets the comma-delimited response group' do + subject.params['ResponseGroup'].should eq 'OfferSummary,Images' + end + end + + describe 'when the related item page is specified' do + let(:block) { proc { related_item_page 2 } } + + it 'sets the related item page' do + subject.params['RelatedItemPage'].should eq 2 + end + end + + describe 'when the relationship type is specified' do + let(:block) { proc { relationship_type 'Episode' } } + + it 'sets the relationship type' do + subject.params['RelationshipType'].should eq 'Episode' + end + end + + describe 'when nothing is specified' do + let(:block) { proc { } } + + it 'does not set the related item page' do + subject.params.should_not have_key 'RelatedItemPage' + end + + it 'does not set the relationship type' do + subject.params.should_not have_key 'RelationshipType' + end + end end end