onfleet-ruby 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +3 -0
- data/.rspec +1 -2
- data/.rubocop.yml +26 -0
- data/.rubocop_todo.yml +38 -0
- data/.ruby-version +2 -0
- data/Gemfile +3 -3
- data/Rakefile +10 -0
- data/lib/onfleet-ruby.rb +40 -38
- data/lib/onfleet-ruby/actions/create.rb +6 -3
- data/lib/onfleet-ruby/actions/delete.rb +4 -4
- data/lib/onfleet-ruby/actions/find.rb +8 -6
- data/lib/onfleet-ruby/actions/get.rb +5 -4
- data/lib/onfleet-ruby/actions/list.rb +15 -13
- data/lib/onfleet-ruby/actions/query_metadata.rb +5 -5
- data/lib/onfleet-ruby/actions/save.rb +13 -9
- data/lib/onfleet-ruby/actions/update.rb +4 -4
- data/lib/onfleet-ruby/address.rb +1 -0
- data/lib/onfleet-ruby/admin.rb +2 -1
- data/lib/onfleet-ruby/destination.rb +2 -1
- data/lib/onfleet-ruby/errors/authentication_error.rb +1 -0
- data/lib/onfleet-ruby/errors/connection_error.rb +1 -0
- data/lib/onfleet-ruby/errors/invalid_request_error.rb +1 -0
- data/lib/onfleet-ruby/errors/onfleet_error.rb +1 -0
- data/lib/onfleet-ruby/onfleet_object.rb +58 -59
- data/lib/onfleet-ruby/organization.rb +4 -9
- data/lib/onfleet-ruby/recipient.rb +2 -1
- data/lib/onfleet-ruby/task.rb +4 -4
- data/lib/onfleet-ruby/team.rb +2 -1
- data/lib/onfleet-ruby/util.rb +22 -20
- data/lib/onfleet-ruby/vehicle.rb +1 -0
- data/lib/onfleet-ruby/webhook.rb +2 -2
- data/lib/onfleet-ruby/worker.rb +2 -1
- data/onfleet-ruby.gemspec +11 -6
- data/spec/onfleet/admin_spec.rb +70 -0
- data/spec/onfleet/destination_spec.rb +62 -0
- data/spec/onfleet/organization_spec.rb +25 -0
- data/spec/onfleet/recipient_spec.rb +75 -0
- data/spec/onfleet/task_spec.rb +123 -0
- data/spec/onfleet/team_spec.rb +30 -0
- data/spec/onfleet/webhook_spec.rb +49 -0
- data/spec/onfleet/worker_spec.rb +67 -0
- data/spec/spec_helper.rb +78 -2
- data/spec/support/http_requests/shared_examples.rb +126 -0
- metadata +97 -13
- data/spec/test_data.rb +0 -14
@@ -0,0 +1,62 @@
|
|
1
|
+
RSpec.describe Onfleet::Destination do
|
2
|
+
let(:destination) { described_class.new(params) }
|
3
|
+
let(:params) { { id: 'a-destination', address: address_params } }
|
4
|
+
let(:address_params) { { street: '123 Main', city: 'Foo', state: 'TX' } }
|
5
|
+
|
6
|
+
describe ".create" do
|
7
|
+
subject { -> { described_class.create(params) } }
|
8
|
+
it_should_behave_like Onfleet::Actions::Create, path: 'destinations'
|
9
|
+
end
|
10
|
+
|
11
|
+
describe ".get" do
|
12
|
+
subject { -> { described_class.get(id) } }
|
13
|
+
let(:id) { 'a-destination' }
|
14
|
+
it_should_behave_like Onfleet::Actions::Get, path: 'destinations/a-destination'
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".query_by_metadata" do
|
18
|
+
subject { -> { described_class.query_by_metadata(metadata) } }
|
19
|
+
let(:metadata) { [{ name: 'color', type: 'string', value: 'ochre' }] }
|
20
|
+
it_should_behave_like Onfleet::Actions::QueryMetadata, path: 'destinations'
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#save" do
|
24
|
+
subject { -> { destination.save } }
|
25
|
+
|
26
|
+
context "with an ID attribute" do
|
27
|
+
before { expect(params[:id]).to be }
|
28
|
+
it_should_behave_like Onfleet::Actions::Update, path: 'destinations/a-destination'
|
29
|
+
end
|
30
|
+
|
31
|
+
context "without an ID attribute" do
|
32
|
+
let(:params) { { address: address_params } }
|
33
|
+
it_should_behave_like Onfleet::Actions::Create, path: 'destinations'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#address" do
|
38
|
+
subject { destination.address }
|
39
|
+
|
40
|
+
context "when initialized with address params" do
|
41
|
+
let(:address_params) do
|
42
|
+
{
|
43
|
+
number: '123',
|
44
|
+
street: 'Main St.',
|
45
|
+
apartment: '',
|
46
|
+
city: 'Foo',
|
47
|
+
state: 'TX',
|
48
|
+
postalCode: '99999',
|
49
|
+
country: 'United States'
|
50
|
+
}
|
51
|
+
end
|
52
|
+
its(:number) { should == '123' }
|
53
|
+
its(:postal_code) { should == '99999' }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when initialized with no address params" do
|
57
|
+
let(:address_params) { nil }
|
58
|
+
it { should be_nil }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
RSpec.describe Onfleet::Organization do
|
2
|
+
let(:organization) { described_class.new(params) }
|
3
|
+
let(:params) { { id: 'an-org' } }
|
4
|
+
|
5
|
+
describe ".get" do
|
6
|
+
subject { -> { described_class.get } }
|
7
|
+
it_should_behave_like Onfleet::Actions::Get, path: 'organization'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".get_delegatee_details" do
|
11
|
+
subject { -> { described_class.get_delegatee_details(id) } }
|
12
|
+
let(:id) { 'my-org' }
|
13
|
+
it_should_behave_like Onfleet::Actions::Get, path: 'organizations/my-org'
|
14
|
+
end
|
15
|
+
|
16
|
+
%i[id name email country timezone time_created time_last_modified].each do |attr|
|
17
|
+
describe "##{attr}" do
|
18
|
+
subject { organization.public_send(attr) }
|
19
|
+
let(:params) { { attr => value } }
|
20
|
+
let(:value) { 'pizza' }
|
21
|
+
it { should == value }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
RSpec.describe Onfleet::Recipient do
|
2
|
+
let(:recipient) { described_class.new(params) }
|
3
|
+
let(:params) { { id: 'a-recipient', name: 'Recipient Jones' } }
|
4
|
+
|
5
|
+
describe ".create" do
|
6
|
+
subject { -> { described_class.create(params) } }
|
7
|
+
it_should_behave_like Onfleet::Actions::Create, path: 'recipients'
|
8
|
+
|
9
|
+
context "with the `skip_sms_notifications` attribute" do
|
10
|
+
set_up_request_stub(:post, 'recipients')
|
11
|
+
let(:params) { { skip_sms_notifications: true } }
|
12
|
+
let(:response_body) { { id: 'an-object' } }
|
13
|
+
|
14
|
+
it "should camelize the attribute name properly" do
|
15
|
+
subject.call
|
16
|
+
expect(
|
17
|
+
a_request(:post, url).with(body: { 'skipSMSNotifications' => true }.to_json)
|
18
|
+
).to have_been_made.once
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".get" do
|
24
|
+
subject { -> { described_class.get(id) } }
|
25
|
+
let(:id) { 'a-recipient' }
|
26
|
+
it_should_behave_like Onfleet::Actions::Get, path: 'recipients/a-recipient'
|
27
|
+
end
|
28
|
+
|
29
|
+
describe ".update" do
|
30
|
+
subject { -> { described_class.update(id, params) } }
|
31
|
+
let(:id) { 'a-recipient' }
|
32
|
+
it_should_behave_like Onfleet::Actions::Update, path: 'recipients/a-recipient'
|
33
|
+
|
34
|
+
context "with the `skip_sms_notifications` attribute" do
|
35
|
+
set_up_request_stub(:put, 'recipients/a-recipient')
|
36
|
+
let(:params) { { id: 'a-recipient', skip_sms_notifications: true } }
|
37
|
+
let(:response_body) { { id: 'an-object' } }
|
38
|
+
|
39
|
+
it "should camelize the attribute name properly" do
|
40
|
+
subject.call
|
41
|
+
expect(
|
42
|
+
a_request(:put, url).with(body: { id: 'a-recipient', 'skipSMSNotifications' => true }.to_json)
|
43
|
+
).to have_been_made.once
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe ".find" do
|
49
|
+
subject { -> { described_class.find(attribute, value) } }
|
50
|
+
let(:attribute) { 'name' }
|
51
|
+
let(:value) { 'Ma Bell' }
|
52
|
+
it_should_behave_like Onfleet::Actions::Find, path: "recipients/name/Ma+Bell"
|
53
|
+
end
|
54
|
+
|
55
|
+
describe ".query_by_metadata" do
|
56
|
+
subject { -> { described_class.query_by_metadata(metadata) } }
|
57
|
+
let(:metadata) { [{ name: 'color', type: 'string', value: 'ochre' }] }
|
58
|
+
it_should_behave_like Onfleet::Actions::QueryMetadata, path: 'recipients'
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#save" do
|
62
|
+
subject { -> { recipient.save } }
|
63
|
+
|
64
|
+
context "with an ID attribute" do
|
65
|
+
before { expect(params[:id]).to be }
|
66
|
+
it_should_behave_like Onfleet::Actions::Update, path: 'recipients/a-recipient'
|
67
|
+
end
|
68
|
+
|
69
|
+
context "without an ID attribute" do
|
70
|
+
let(:params) { { name: 'Recipient Jones' } }
|
71
|
+
it_should_behave_like Onfleet::Actions::Create, path: 'recipients'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
@@ -0,0 +1,123 @@
|
|
1
|
+
RSpec.describe Onfleet::Task do
|
2
|
+
let(:task) { described_class.new(params) }
|
3
|
+
let(:params) { { id: 'a-task', short_id: 'at', recipients: ['jeff'] } }
|
4
|
+
|
5
|
+
describe ".list" do
|
6
|
+
subject { -> { described_class.list(query_params) } }
|
7
|
+
|
8
|
+
context "with no filter" do
|
9
|
+
let(:query_params) { nil }
|
10
|
+
it_should_behave_like Onfleet::Actions::List, path: 'tasks'
|
11
|
+
end
|
12
|
+
|
13
|
+
context "with query params" do
|
14
|
+
let(:query_params) { { food: 'pizza', topping: 'mushroom' } }
|
15
|
+
it_should_behave_like Onfleet::Actions::List, path: 'tasks?food=pizza&topping=mushroom'
|
16
|
+
end
|
17
|
+
|
18
|
+
context "with a URL-unsafe query param" do
|
19
|
+
let(:query_params) { { food: 'green eggs & ham' } }
|
20
|
+
it_should_behave_like Onfleet::Actions::List, path: 'tasks?food=green+eggs+%26+ham'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".create" do
|
25
|
+
subject { -> { described_class.create(params) } }
|
26
|
+
it_should_behave_like Onfleet::Actions::Create, path: 'tasks'
|
27
|
+
|
28
|
+
context "with the skip_sms_notification override attribute" do
|
29
|
+
set_up_request_stub(:post, 'tasks')
|
30
|
+
let(:params) { { recipient_skip_sms_notifications: true } }
|
31
|
+
let(:response_body) { { id: 'an-object' } }
|
32
|
+
|
33
|
+
it "should camelize the attribute name properly" do
|
34
|
+
pending('The SMS acronym does not camelize consistently')
|
35
|
+
subject.call
|
36
|
+
expect(
|
37
|
+
a_request(:post, url).with(body: { recipientSkipSMSNotifications: true }.to_json)
|
38
|
+
).to have_been_made.once
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "with barcode attributes" do
|
43
|
+
set_up_request_stub(:post, 'tasks')
|
44
|
+
let(:params) { { barcodes: [{ data: 'abc', block_completion: true }] } }
|
45
|
+
let(:response_body) { { id: 'an-object' } }
|
46
|
+
|
47
|
+
it "should camelize the attribute name properly" do
|
48
|
+
pending('JSON subkeys of non-Onfleet objects do not camelize')
|
49
|
+
subject.call
|
50
|
+
expect(
|
51
|
+
a_request(:post, url).with(body: { barcodes: [{ data: 'abc', 'blockCompletion' => true }] }.to_json)
|
52
|
+
).to have_been_made.once
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe ".get" do
|
58
|
+
subject { -> { described_class.get(id) } }
|
59
|
+
let(:id) { 'a-task' }
|
60
|
+
it_should_behave_like Onfleet::Actions::Get, path: 'tasks/a-task'
|
61
|
+
end
|
62
|
+
|
63
|
+
describe ".update" do
|
64
|
+
subject { -> { described_class.update(id, params) } }
|
65
|
+
let(:id) { 'a-task' }
|
66
|
+
it_should_behave_like Onfleet::Actions::Update, path: 'tasks/a-task'
|
67
|
+
|
68
|
+
context "with the skip_sms_notification override attribute" do
|
69
|
+
set_up_request_stub(:put, 'tasks/a-task')
|
70
|
+
let(:params) { { id: 'a-task', recipient_skip_sms_notifications: true } }
|
71
|
+
let(:response_body) { { id: 'an-object' } }
|
72
|
+
|
73
|
+
it "should camelize the attribute name properly" do
|
74
|
+
pending('The SMS acronym does not camelize consistently')
|
75
|
+
subject.call
|
76
|
+
expect(
|
77
|
+
a_request(:put, url).with(body: { recipientSkipSMSNotifications: true }.to_json)
|
78
|
+
).to have_been_made.once
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "with barcode attributes" do
|
83
|
+
set_up_request_stub(:put, 'tasks/a-task')
|
84
|
+
let(:params) { { id: 'a-task', barcodes: [{ data: 'abc', block_completion: true }] } }
|
85
|
+
let(:response_body) { { id: 'an-object' } }
|
86
|
+
|
87
|
+
it "should camelize the attribute name properly" do
|
88
|
+
pending('JSON subkeys of non-Onfleet objects do not camelize')
|
89
|
+
subject.call
|
90
|
+
expect(
|
91
|
+
a_request(:put, url).with(body: { barcodes: [{ data: 'abc', 'blockCompletion' => true }] }.to_json)
|
92
|
+
).to have_been_made.once
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe ".delete" do
|
98
|
+
subject { -> { described_class.delete(id) } }
|
99
|
+
let(:id) { 'an-task' }
|
100
|
+
it_should_behave_like Onfleet::Actions::Delete, path: 'tasks/an-task'
|
101
|
+
end
|
102
|
+
|
103
|
+
describe ".query_by_metadata" do
|
104
|
+
subject { -> { described_class.query_by_metadata(metadata) } }
|
105
|
+
let(:metadata) { [{ name: 'color', type: 'string', value: 'ochre' }] }
|
106
|
+
it_should_behave_like Onfleet::Actions::QueryMetadata, path: 'tasks'
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "#save" do
|
110
|
+
subject { -> { task.save } }
|
111
|
+
|
112
|
+
context "with an ID attribute" do
|
113
|
+
before { expect(params[:id]).to be }
|
114
|
+
it_should_behave_like Onfleet::Actions::Update, path: 'tasks/a-task'
|
115
|
+
end
|
116
|
+
|
117
|
+
context "without an ID attribute" do
|
118
|
+
let(:params) { { short_id: 'at', recipients: ['jeff'] } }
|
119
|
+
it_should_behave_like Onfleet::Actions::Create, path: 'tasks'
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
RSpec.describe Onfleet::Team do
|
2
|
+
let(:team) { described_class.new(params) }
|
3
|
+
let(:params) { { id: 'a-team', name: 'Detroit Redwings' } }
|
4
|
+
|
5
|
+
describe ".list" do
|
6
|
+
subject { -> { described_class.list(query_params) } }
|
7
|
+
|
8
|
+
context "with no filter" do
|
9
|
+
let(:query_params) { nil }
|
10
|
+
it_should_behave_like Onfleet::Actions::List, path: 'teams'
|
11
|
+
end
|
12
|
+
|
13
|
+
context "with query params" do
|
14
|
+
let(:query_params) { { food: 'pizza', topping: 'mushroom' } }
|
15
|
+
it_should_behave_like Onfleet::Actions::List, path: 'teams?food=pizza&topping=mushroom'
|
16
|
+
end
|
17
|
+
|
18
|
+
context "with a URL-unsafe query param" do
|
19
|
+
let(:query_params) { { food: 'green eggs & ham' } }
|
20
|
+
it_should_behave_like Onfleet::Actions::List, path: 'teams?food=green+eggs+%26+ham'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".get" do
|
25
|
+
subject { -> { described_class.get(id) } }
|
26
|
+
let(:id) { 'a-team' }
|
27
|
+
it_should_behave_like Onfleet::Actions::Get, path: 'teams/a-team'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
RSpec.describe Onfleet::Webhook do
|
2
|
+
let(:webhook) { described_class.new(params) }
|
3
|
+
let(:params) { { id: 'a-webhook', url: 'https://example.com', is_enabled: true } }
|
4
|
+
|
5
|
+
describe ".list" do
|
6
|
+
subject { -> { described_class.list(query_params) } }
|
7
|
+
|
8
|
+
context "with no filter" do
|
9
|
+
let(:query_params) { nil }
|
10
|
+
it_should_behave_like Onfleet::Actions::List, path: 'webhooks'
|
11
|
+
end
|
12
|
+
|
13
|
+
context "with query params" do
|
14
|
+
let(:query_params) { { food: 'pizza', topping: 'mushroom' } }
|
15
|
+
it_should_behave_like Onfleet::Actions::List, path: 'webhooks?food=pizza&topping=mushroom'
|
16
|
+
end
|
17
|
+
|
18
|
+
context "with a URL-unsafe query param" do
|
19
|
+
let(:query_params) { { food: 'green eggs & ham' } }
|
20
|
+
it_should_behave_like Onfleet::Actions::List, path: 'webhooks?food=green+eggs+%26+ham'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".create" do
|
25
|
+
subject { -> { described_class.create(params) } }
|
26
|
+
it_should_behave_like Onfleet::Actions::Create, path: 'webhooks'
|
27
|
+
end
|
28
|
+
|
29
|
+
describe ".delete" do
|
30
|
+
subject { -> { described_class.delete(id) } }
|
31
|
+
let(:id) { 'a-webhook' }
|
32
|
+
it_should_behave_like Onfleet::Actions::Delete, path: 'webhooks/a-webhook'
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#save" do
|
36
|
+
subject { -> { webhook.save } }
|
37
|
+
|
38
|
+
context "with an ID attribute" do
|
39
|
+
before { expect(params[:id]).to be }
|
40
|
+
it_should_behave_like Onfleet::Actions::Update, path: 'webhooks/a-webhook'
|
41
|
+
end
|
42
|
+
|
43
|
+
context "without an ID attribute" do
|
44
|
+
let(:params) { { name: 'An Webhook' } }
|
45
|
+
it_should_behave_like Onfleet::Actions::Create, path: 'webhooks'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
RSpec.describe Onfleet::Worker do
|
2
|
+
let(:worker) { described_class.new(params) }
|
3
|
+
let(:params) { { id: 'a-worker', name: 'F. Prefect', phone: '5551212' } }
|
4
|
+
|
5
|
+
describe ".list" do
|
6
|
+
subject { -> { described_class.list(query_params) } }
|
7
|
+
|
8
|
+
context "with no filter" do
|
9
|
+
let(:query_params) { nil }
|
10
|
+
it_should_behave_like Onfleet::Actions::List, path: 'workers'
|
11
|
+
end
|
12
|
+
|
13
|
+
context "with query params" do
|
14
|
+
let(:query_params) { { food: 'pizza', topping: 'mushroom' } }
|
15
|
+
it_should_behave_like Onfleet::Actions::List, path: 'workers?food=pizza&topping=mushroom'
|
16
|
+
end
|
17
|
+
|
18
|
+
context "with a URL-unsafe query param" do
|
19
|
+
let(:query_params) { { food: 'green eggs & ham' } }
|
20
|
+
it_should_behave_like Onfleet::Actions::List, path: 'workers?food=green+eggs+%26+ham'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".create" do
|
25
|
+
subject { -> { described_class.create(params) } }
|
26
|
+
it_should_behave_like Onfleet::Actions::Create, path: 'workers'
|
27
|
+
end
|
28
|
+
|
29
|
+
describe ".get" do
|
30
|
+
subject { -> { described_class.get(id) } }
|
31
|
+
let(:id) { 'a-worker' }
|
32
|
+
it_should_behave_like Onfleet::Actions::Get, path: 'workers/a-worker'
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".update" do
|
36
|
+
subject { -> { described_class.update(id, params) } }
|
37
|
+
let(:id) { 'a-worker' }
|
38
|
+
it_should_behave_like Onfleet::Actions::Update, path: 'workers/a-worker'
|
39
|
+
end
|
40
|
+
|
41
|
+
describe ".delete" do
|
42
|
+
subject { -> { described_class.delete(id) } }
|
43
|
+
let(:id) { 'a-worker' }
|
44
|
+
it_should_behave_like Onfleet::Actions::Delete, path: 'workers/a-worker'
|
45
|
+
end
|
46
|
+
|
47
|
+
describe ".query_by_metadata" do
|
48
|
+
subject { -> { described_class.query_by_metadata(metadata) } }
|
49
|
+
let(:metadata) { [{ name: 'color', type: 'string', value: 'ochre' }] }
|
50
|
+
it_should_behave_like Onfleet::Actions::QueryMetadata, path: 'workers'
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#save" do
|
54
|
+
subject { -> { worker.save } }
|
55
|
+
|
56
|
+
context "with an ID attribute" do
|
57
|
+
before { expect(params[:id]).to be }
|
58
|
+
it_should_behave_like Onfleet::Actions::Update, path: 'workers/a-worker'
|
59
|
+
end
|
60
|
+
|
61
|
+
context "without an ID attribute" do
|
62
|
+
let(:params) { { name: 'An Worker' } }
|
63
|
+
it_should_behave_like Onfleet::Actions::Create, path: 'workers'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,78 @@
|
|
1
|
-
require '
|
2
|
-
require
|
1
|
+
require 'rspec/its'
|
2
|
+
require 'webmock/rspec'
|
3
|
+
require File.expand_path(File.join('..', 'lib', 'onfleet-ruby'), __dir__)
|
4
|
+
|
5
|
+
Dir.glob(File.expand_path(File.join('support', '**', '*.rb'), __dir__)).each { |file| require file }
|
6
|
+
|
7
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.expect_with :rspec do |expectations|
|
10
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
11
|
+
# and `failure_message` of custom matchers include text for helper methods
|
12
|
+
# defined using `chain`, e.g.:
|
13
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
14
|
+
# # => "be bigger than 2 and smaller than 4"
|
15
|
+
# ...rather than:
|
16
|
+
# # => "be bigger than 2"
|
17
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
18
|
+
end
|
19
|
+
|
20
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
21
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
22
|
+
config.mock_with :rspec do |mocks|
|
23
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
24
|
+
# a real object. This is generally recommended, and will default to
|
25
|
+
# `true` in RSpec 4.
|
26
|
+
mocks.verify_partial_doubles = true
|
27
|
+
end
|
28
|
+
|
29
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
30
|
+
# have no way to turn it off -- the option exists only for backwards
|
31
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
32
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
33
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
34
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
35
|
+
|
36
|
+
# This allows you to limit a spec run to individual examples or groups
|
37
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
38
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
39
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
40
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
41
|
+
config.filter_run_when_matching :focus
|
42
|
+
|
43
|
+
# Allows RSpec to persist some state between runs in order to support
|
44
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
45
|
+
# you configure your source control system to ignore this file.
|
46
|
+
config.example_status_persistence_file_path = 'spec/examples.txt'
|
47
|
+
|
48
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
49
|
+
# recommended. For more details, see:
|
50
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
51
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
52
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
53
|
+
config.disable_monkey_patching!
|
54
|
+
|
55
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
56
|
+
# be too noisy due to issues in dependencies.
|
57
|
+
config.warnings = true
|
58
|
+
|
59
|
+
# Print the 10 slowest examples and example groups at the
|
60
|
+
# end of the spec run, to help surface which specs are running
|
61
|
+
# particularly slow.
|
62
|
+
config.profile_examples = 10
|
63
|
+
|
64
|
+
# Run specs in random order to surface order dependencies. If you find an
|
65
|
+
# order dependency and want to debug it, you can fix the order by providing
|
66
|
+
# the seed, which is printed after each run.
|
67
|
+
# --seed 1234
|
68
|
+
config.order = :random
|
69
|
+
|
70
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
71
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
72
|
+
# test failures related to randomization by passing the same `--seed` value
|
73
|
+
# as the one that triggered the failure.
|
74
|
+
Kernel.srand config.seed
|
75
|
+
|
76
|
+
config.before { Onfleet.api_key = 'TEST API KEY' }
|
77
|
+
end
|
78
|
+
|