spec/actionkit_spec.rb in tokyo_api-1.5.1 vs spec/actionkit_spec.rb in tokyo_api-1.6.0
- old
+ new
@@ -1,7 +1,9 @@
-require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
+# frozen_string_literal: true
+require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+
describe TokyoApi::Actionkit do
subject { TokyoApi.new(host: 'test.com') }
describe 'configuration' do
it 'should propagate the host' do
@@ -13,19 +15,19 @@
let(:body) { fixture('responses/full_user_success') }
let(:request_path) { '/actionkit/full_user/1' }
let(:status) { 200 }
before(:each) do
- stub_get(request_path).to_return(:body => body, :status => status,
- :headers => { content_type: "application/json; charset=utf-8"})
+ stub_get(request_path).to_return(body: body, status: status,
+ headers: { content_type: 'application/json; charset=utf-8' })
end
describe 'error' do
let(:body) { fixture('responses/full_user_error') }
it 'should return an error hash' do
- expect(subject.actionkit.full_user('1')).to eq({'error' => 'Connection refused'})
+ expect(subject.actionkit.full_user('1')).to eq({ 'error' => 'Connection refused' })
end
end
describe 'success' do
let(:body) { fixture('responses/actionkit/full_user_success') }
@@ -37,21 +39,25 @@
end
end
describe 'user_path' do
context 'without required_fields' do
- it "should return relative path to user API endpoint" do
+ it 'should return relative path to user API endpoint' do
expect(subject.actionkit.user_path('abc.123.xyz')).to eq('/actionkit/user/abc.123.xyz')
end
end
context 'with required_fields' do
- it "should return relative path to user API endpoint" do
- 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')
+ it 'should return relative path to user API endpoint' do
+ expect(subject.actionkit.user_path('abc.123.xyz',
+ required_fields: %i[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')
+ 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