spec/actionkit_spec.rb in tokyo_api-0.6.1 vs spec/actionkit_spec.rb in tokyo_api-1.0.1
- old
+ new
@@ -36,18 +36,22 @@
'extra_field' => 'hidden extra field', 'email' => 'foo@bar.com' })
end
end
describe 'user_path' do
- context 'phone not required' do
+ context 'without required_fields' do
it "should return relative path to user API endpoint" do
- expect(subject.actionkit.user_path('abc.123.xyz', false)).to eq('/actionkit/user/abc.123.xyz?phone_required=false')
+ expect(subject.actionkit.user_path('abc.123.xyz')).to eq('/actionkit/user/abc.123.xyz')
end
end
- context 'phone required' do
+ context 'with required_fields' do
it "should return relative path to user API endpoint" do
- expect(subject.actionkit.user_path('abc.123.xyz', true)).to eq('/actionkit/user/abc.123.xyz?phone_required=true')
+ expect(subject.actionkit.user_path('abc.123.xyz', required_fields: [:first_name, :last_name, :email, :postal, :phone])).to eq('/actionkit/user/abc.123.xyz?required_fields=first_name,last_name,email,postal,phone')
+ end
+
+ it 'should url-escape field names with weird characters' do
+ expect(subject.actionkit.user_path('abc.123.xyz', required_fields: ['email', 'fish & chips'])).to eq('/actionkit/user/abc.123.xyz?required_fields=email,fish+%26+chips')
end
end
end
end
end