spec/krautbuster_spec.rb in tokyo_api-0.6.1 vs spec/krautbuster_spec.rb in tokyo_api-1.0.1

- old
+ new

@@ -69,11 +69,23 @@ expect { subject.subscription_status(token) }.to raise_error Vertebrae::ResponseError end end describe '#user_path' do - it "should return relative path to user API endpoint" do - expect(subject.krautbuster.user_path('123abc456', 'save-the-trees')).to eq '/krautbuster/user/123abc456?petition_id=save-the-trees' + context 'without required_fields' do + it "should return relative path to user API endpoint" do + expect(subject.krautbuster.user_path('123abc456', petition_id: 'save-the-trees')).to eq '/krautbuster/user/123abc456?petition_id=save-the-trees' + end + end + + context 'with required_fields' do + it "should return relative path to user API endpoint" do + expect(subject.krautbuster.user_path('123abc456', petition_id: 'save-the-trees', required_fields: [:first_name, :last_name, :email])).to eq '/krautbuster/user/123abc456?petition_id=save-the-trees&required_fields=first_name,last_name,email' + end + + it 'should url-escape field names with weird characters' do + expect(subject.krautbuster.user_path('123abc456', petition_id: 'save-the-trees', required_fields: ['email', 'fish & chips'])).to eq '/krautbuster/user/123abc456?petition_id=save-the-trees&required_fields=email,fish+%26+chips' + end end end describe '#subscription_status_path' do subject { TokyoApi::Krautbuster.new }