flapjack-diner 1.4.0 → 2.0.0.a4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -1
- data/README.md +620 -413
- data/flapjack-diner.gemspec +1 -1
- data/lib/flapjack-diner/argument_validator.rb +77 -7
- data/lib/flapjack-diner/configuration.rb +409 -0
- data/lib/flapjack-diner/index_range.rb +42 -0
- data/lib/flapjack-diner/log_formatter.rb +22 -0
- data/lib/flapjack-diner/query.rb +114 -0
- data/lib/flapjack-diner/relationships.rb +180 -0
- data/lib/flapjack-diner/request.rb +280 -0
- data/lib/flapjack-diner/resources.rb +64 -0
- data/lib/flapjack-diner/response.rb +91 -0
- data/lib/flapjack-diner/tools.rb +47 -251
- data/lib/flapjack-diner/utility.rb +16 -0
- data/lib/flapjack-diner/version.rb +1 -1
- data/lib/flapjack-diner.rb +54 -20
- data/spec/argument_validator_spec.rb +87 -28
- data/spec/flapjack-diner_spec.rb +42 -64
- data/spec/relationships_spec.rb +211 -0
- data/spec/resources/checks_spec.rb +219 -79
- data/spec/resources/contacts_spec.rb +179 -151
- data/spec/resources/events_spec.rb +208 -0
- data/spec/resources/maintenance_periods_spec.rb +177 -565
- data/spec/resources/media_spec.rb +157 -171
- data/spec/resources/metrics_spec.rb +45 -0
- data/spec/resources/rules_spec.rb +278 -0
- data/spec/resources/states_spec.rb +93 -0
- data/spec/resources/statistics_spec.rb +53 -0
- data/spec/resources/tags_spec.rb +243 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/fixture_data.rb +541 -0
- metadata +33 -31
- data/.rubocop.yml +0 -21
- data/.rubocop_todo.yml +0 -135
- data/lib/flapjack-diner/resources/checks.rb +0 -64
- data/lib/flapjack-diner/resources/contacts.rb +0 -70
- data/lib/flapjack-diner/resources/entities.rb +0 -68
- data/lib/flapjack-diner/resources/maintenance_periods.rb +0 -82
- data/lib/flapjack-diner/resources/media.rb +0 -61
- data/lib/flapjack-diner/resources/notification_rules.rb +0 -66
- data/lib/flapjack-diner/resources/notifications.rb +0 -28
- data/lib/flapjack-diner/resources/pagerduty_credentials.rb +0 -59
- data/lib/flapjack-diner/resources/reports.rb +0 -33
- data/spec/pacts/flapjack-diner-flapjack.json +0 -4515
- data/spec/resources/entities_spec.rb +0 -181
- data/spec/resources/notification_rules_spec.rb +0 -341
- data/spec/resources/notifications_spec.rb +0 -208
- data/spec/resources/pagerduty_credentials_spec.rb +0 -237
- data/spec/resources/reports_spec.rb +0 -255
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'flapjack-diner'
|
3
3
|
|
4
|
-
describe Flapjack::Diner::Resources
|
4
|
+
describe Flapjack::Diner::Resources, :pact => true do
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
Flapjack::Diner.base_uri('localhost:19081')
|
@@ -11,74 +11,67 @@ describe Flapjack::Diner::Resources::Contacts, :pact => true do
|
|
11
11
|
context 'create' do
|
12
12
|
|
13
13
|
it "submits a POST request for a contact" do
|
14
|
-
|
15
|
-
|
16
|
-
:last_name => 'Smith',
|
17
|
-
:email => 'jims@example.com',
|
18
|
-
:timezone => 'UTC' }]
|
14
|
+
req_data = contact_json(contact_data)
|
15
|
+
resp_data = req_data.merge(:relationships => contact_rel(contact_data))
|
19
16
|
|
20
|
-
flapjack.given("no
|
17
|
+
flapjack.given("no data exists").
|
21
18
|
upon_receiving("a POST request with one contact").
|
22
19
|
with(:method => :post, :path => '/contacts',
|
23
20
|
:headers => {'Content-Type' => 'application/vnd.api+json'},
|
24
|
-
:body => {:
|
21
|
+
:body => {:data => req_data}).
|
25
22
|
will_respond_with(
|
26
23
|
:status => 201,
|
27
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
28
|
-
:body =>
|
24
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
25
|
+
:body => {:data => resp_data})
|
29
26
|
|
30
27
|
result = Flapjack::Diner.create_contacts(contact_data)
|
31
28
|
expect(result).not_to be_nil
|
32
|
-
expect(result).to eq(
|
29
|
+
expect(result).to eq(resultify(resp_data))
|
33
30
|
end
|
34
31
|
|
35
32
|
it "submits a POST request for several contacts" do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
:last_name => 'Smith',
|
44
|
-
:email => 'joans@example.com'}]
|
45
|
-
|
46
|
-
flapjack.given("no contact exists").
|
33
|
+
req_data = [contact_json(contact_data), contact_json(contact_2_data)]
|
34
|
+
resp_data = [
|
35
|
+
req_data[0].merge(:relationships => contact_rel(contact_data)),
|
36
|
+
req_data[1].merge(:relationships => contact_rel(contact_2_data))
|
37
|
+
]
|
38
|
+
|
39
|
+
flapjack.given("no data exists").
|
47
40
|
upon_receiving("a POST request with two contacts").
|
48
41
|
with(:method => :post, :path => '/contacts',
|
49
|
-
:headers => {'Content-Type' => 'application/vnd.api+json'},
|
50
|
-
:body => {:
|
42
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; ext=bulk'},
|
43
|
+
:body => {:data => req_data}).
|
51
44
|
will_respond_with(
|
52
45
|
:status => 201,
|
53
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
54
|
-
:body =>
|
46
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
47
|
+
:body => {:data => resp_data})
|
55
48
|
|
56
|
-
result = Flapjack::Diner.create_contacts(contact_data)
|
49
|
+
result = Flapjack::Diner.create_contacts(contact_data, contact_2_data)
|
57
50
|
expect(result).not_to be_nil
|
58
|
-
expect(result).to eq(
|
51
|
+
expect(result).to eq(resultify(resp_data))
|
59
52
|
end
|
60
53
|
|
61
54
|
it "submits a POST request but a contact with that id exists" do
|
62
|
-
|
63
|
-
:first_name => 'Jim',
|
64
|
-
:last_name => 'Smith',
|
65
|
-
:email => 'jims@example.com',
|
66
|
-
:timezone => 'UTC'}]
|
55
|
+
req_data = contact_json(contact_data)
|
67
56
|
|
68
|
-
flapjack.given("a contact
|
57
|
+
flapjack.given("a contact exists").
|
69
58
|
upon_receiving("a POST request with one contact").
|
70
59
|
with(:method => :post, :path => '/contacts',
|
71
60
|
:headers => {'Content-Type' => 'application/vnd.api+json'},
|
72
|
-
:body => {:
|
61
|
+
:body => {:data => req_data}).
|
73
62
|
will_respond_with(
|
74
63
|
:status => 409,
|
75
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
76
|
-
:body => {:errors => [
|
64
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
65
|
+
:body => {:errors => [{
|
66
|
+
:status => '409',
|
67
|
+
:detail => "Contacts already exist with the following ids: #{contact_data[:id]}"
|
68
|
+
}]}
|
69
|
+
)
|
77
70
|
|
78
71
|
result = Flapjack::Diner.create_contacts(contact_data)
|
79
72
|
expect(result).to be_nil
|
80
|
-
expect(Flapjack::Diner.
|
81
|
-
:
|
73
|
+
expect(Flapjack::Diner.error).to eq([{:status => '409',
|
74
|
+
:detail => "Contacts already exist with the following ids: #{contact_data[:id]}"}])
|
82
75
|
end
|
83
76
|
|
84
77
|
end
|
@@ -88,33 +81,29 @@ describe Flapjack::Diner::Resources::Contacts, :pact => true do
|
|
88
81
|
context 'GET all contacts' do
|
89
82
|
|
90
83
|
it "has some data" do
|
91
|
-
|
92
|
-
:first_name => 'Jim',
|
93
|
-
:last_name => 'Smith',
|
94
|
-
:email => 'jims@example.com',
|
95
|
-
:timezone => 'UTC'}
|
84
|
+
resp_data = [contact_json(contact_data).merge(:relationships => contact_rel(contact_data))]
|
96
85
|
|
97
|
-
flapjack.given("a contact
|
86
|
+
flapjack.given("a contact exists").
|
98
87
|
upon_receiving("a GET request for all contacts").
|
99
88
|
with(:method => :get, :path => '/contacts').
|
100
89
|
will_respond_with(
|
101
90
|
:status => 200,
|
102
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
103
|
-
|
91
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
92
|
+
:body => {:data => resp_data})
|
104
93
|
|
105
94
|
result = Flapjack::Diner.contacts
|
106
95
|
expect(result).not_to be_nil
|
107
|
-
expect(result).to eq(
|
96
|
+
expect(result).to eq(resultify(resp_data))
|
108
97
|
end
|
109
98
|
|
110
99
|
it "has no data" do
|
111
|
-
flapjack.given("no
|
100
|
+
flapjack.given("no data exists").
|
112
101
|
upon_receiving("a GET request for all contacts").
|
113
102
|
with(:method => :get, :path => '/contacts').
|
114
103
|
will_respond_with(
|
115
104
|
:status => 200,
|
116
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
117
|
-
|
105
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
106
|
+
:body => {:data => []})
|
118
107
|
|
119
108
|
result = Flapjack::Diner.contacts
|
120
109
|
expect(result).not_to be_nil
|
@@ -127,170 +116,209 @@ describe Flapjack::Diner::Resources::Contacts, :pact => true do
|
|
127
116
|
context 'GET a single contact' do
|
128
117
|
|
129
118
|
it "finds the contact" do
|
130
|
-
|
131
|
-
:first_name => 'Jim',
|
132
|
-
:last_name => 'Smith',
|
133
|
-
:email => 'jims@example.com',
|
134
|
-
:timezone => 'UTC'}
|
119
|
+
resp_data = contact_json(contact_data).merge(:relationships => contact_rel(contact_data))
|
135
120
|
|
136
|
-
flapjack.given("a contact
|
121
|
+
flapjack.given("a contact exists").
|
137
122
|
upon_receiving("a GET request for a single contact").
|
138
|
-
with(:method => :get, :path =>
|
123
|
+
with(:method => :get, :path => "/contacts/#{contact_data[:id]}").
|
139
124
|
will_respond_with(
|
140
125
|
:status => 200,
|
141
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
142
|
-
|
126
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
127
|
+
:body => {:data => resp_data})
|
143
128
|
|
144
|
-
result = Flapjack::Diner.contacts(
|
129
|
+
result = Flapjack::Diner.contacts(contact_data[:id])
|
145
130
|
expect(result).not_to be_nil
|
146
|
-
expect(result).to eq(
|
131
|
+
expect(result).to eq(resultify(resp_data))
|
147
132
|
end
|
148
133
|
|
149
134
|
it "can't find the contact" do
|
150
|
-
flapjack.given("no
|
135
|
+
flapjack.given("no data exists").
|
151
136
|
upon_receiving("a GET request for a single contact").
|
152
|
-
with(:method => :get, :path =>
|
137
|
+
with(:method => :get, :path => "/contacts/#{contact_data[:id]}").
|
153
138
|
will_respond_with(
|
154
139
|
:status => 404,
|
155
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
156
|
-
:body => {:errors => [
|
157
|
-
|
158
|
-
|
140
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
141
|
+
:body => {:errors => [{
|
142
|
+
:status => '404',
|
143
|
+
:detail => "could not find Contact record, id: '#{contact_data[:id]}'"
|
144
|
+
}]}
|
145
|
+
)
|
146
|
+
|
147
|
+
result = Flapjack::Diner.contacts(contact_data[:id])
|
159
148
|
expect(result).to be_nil
|
160
|
-
expect(Flapjack::Diner.
|
161
|
-
:
|
149
|
+
expect(Flapjack::Diner.error).to eq([{:status => '404',
|
150
|
+
:detail => "could not find Contact record, id: '#{contact_data[:id]}'"}])
|
162
151
|
end
|
163
152
|
|
164
153
|
end
|
165
154
|
|
166
|
-
|
155
|
+
context 'GET a single contact with included data' do
|
167
156
|
|
168
|
-
|
157
|
+
it 'returns a contact with media' do
|
158
|
+
resp_data = contact_json(contact_data).merge(:relationships => contact_rel(contact_data))
|
159
|
+
resp_data[:relationships][:media][:data] = [
|
160
|
+
{:type => 'medium', :id => email_data[:id]}
|
161
|
+
]
|
162
|
+
resp_included = [medium_json(email_data)]
|
169
163
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
:body => '')
|
164
|
+
flapjack.given("a contact with one medium exists").
|
165
|
+
upon_receiving("a GET request for a single contact with media").
|
166
|
+
with(:method => :get, :path => "/contacts/#{contact_data[:id]}",
|
167
|
+
:query => 'include=media').
|
168
|
+
will_respond_with(
|
169
|
+
:status => 200,
|
170
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
171
|
+
:body => {:data => resp_data, :included => resp_included})
|
179
172
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
173
|
+
result = Flapjack::Diner.contacts(contact_data[:id], :include => 'media')
|
174
|
+
expect(result).not_to be_nil
|
175
|
+
expect(result).to eq(resultify(resp_data))
|
176
|
+
expect(Flapjack::Diner.context).to eq(:included => {'medium' => {email_data[:id] => resultify(resp_included.first)}})
|
177
|
+
end
|
184
178
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
179
|
+
it 'returns a contact with media and rules' do
|
180
|
+
resp_data = contact_json(contact_data).merge(:relationships => contact_rel(contact_data))
|
181
|
+
resp_data[:relationships][:media][:data] = [
|
182
|
+
{:type => 'medium', :id => email_data[:id]}
|
183
|
+
]
|
184
|
+
resp_data[:relationships][:rules][:data] = [
|
185
|
+
{:type => 'rule', :id => rule_data[:id]}
|
186
|
+
]
|
187
|
+
resp_included = [
|
188
|
+
medium_json(email_data),
|
189
|
+
rule_json(rule_data)
|
190
|
+
]
|
191
|
+
|
192
|
+
flapjack.given("a contact with one medium and one rule exists").
|
193
|
+
upon_receiving("a GET request for a single contact with media and rules").
|
194
|
+
with(:method => :get, :path => "/contacts/#{contact_data[:id]}",
|
195
|
+
:query => 'include=media%2Crules').
|
196
|
+
will_respond_with(
|
197
|
+
:status => 200,
|
198
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
199
|
+
:body => {:data => resp_data, :included => resp_included})
|
194
200
|
|
195
|
-
|
196
|
-
|
197
|
-
|
201
|
+
result = Flapjack::Diner.contacts(contact_data[:id], :include => ['media', 'rules'])
|
202
|
+
expect(result).not_to be_nil
|
203
|
+
expect(result).to eq(resultify(resp_data))
|
204
|
+
expect(Flapjack::Diner.context).to eq(:included => {
|
205
|
+
'medium' => {email_data[:id] => resultify(resp_included[0])},
|
206
|
+
'rule' => {rule_data[:id] => resultify(resp_included[1])}
|
207
|
+
})
|
208
|
+
|
209
|
+
end
|
198
210
|
end
|
211
|
+
end
|
199
212
|
|
200
|
-
|
201
|
-
|
202
|
-
|
213
|
+
context 'update' do
|
214
|
+
|
215
|
+
it 'submits a PATCH request for a contact' do
|
216
|
+
flapjack.given("a contact exists").
|
217
|
+
upon_receiving("a PATCH request for a single contact").
|
203
218
|
with(:method => :patch,
|
204
|
-
:path =>
|
205
|
-
:body =>
|
206
|
-
:headers => {'Content-Type'=>'application/
|
207
|
-
will_respond_with(
|
208
|
-
|
219
|
+
:path => "/contacts/#{contact_data[:id]}",
|
220
|
+
:body => {:data => {:id => contact_data[:id], :type => 'contact', :attributes => {:name => 'Hello There'}}},
|
221
|
+
:headers => {'Content-Type' => 'application/vnd.api+json'}).
|
222
|
+
will_respond_with(
|
223
|
+
:status => 204,
|
224
|
+
:body => '' )
|
209
225
|
|
210
|
-
result = Flapjack::Diner.update_contacts(
|
211
|
-
expect(result).
|
212
|
-
expect(result).to be_truthy
|
226
|
+
result = Flapjack::Diner.update_contacts(:id => contact_data[:id], :name => 'Hello There')
|
227
|
+
expect(result).to be_a(TrueClass)
|
213
228
|
end
|
214
229
|
|
215
|
-
it
|
216
|
-
flapjack.given("contacts
|
217
|
-
upon_receiving("a PATCH request
|
230
|
+
it 'submits a PATCH request for several contacts' do
|
231
|
+
flapjack.given("two contacts exist").
|
232
|
+
upon_receiving("a PATCH request for two contacts").
|
218
233
|
with(:method => :patch,
|
219
|
-
:path =>
|
220
|
-
:
|
221
|
-
:
|
222
|
-
|
223
|
-
|
234
|
+
:path => "/contacts",
|
235
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; ext=bulk'},
|
236
|
+
:body => {:data => [{:id => contact_data[:id], :type => 'contact', :attributes => {:name => 'Hello There'}},
|
237
|
+
{:id => contact_2_data[:id], :type => 'contact', :attributes => {:name => 'Goodbye Now'}}]}).
|
238
|
+
will_respond_with(
|
239
|
+
:status => 204,
|
240
|
+
:body => '' )
|
224
241
|
|
225
|
-
result = Flapjack::Diner.update_contacts(
|
226
|
-
|
227
|
-
|
242
|
+
result = Flapjack::Diner.update_contacts(
|
243
|
+
{:id => contact_data[:id], :name => 'Hello There'},
|
244
|
+
{:id => contact_2_data[:id], :name => 'Goodbye Now'})
|
245
|
+
expect(result).to be_a(TrueClass)
|
228
246
|
end
|
229
247
|
|
230
|
-
it "can't find
|
231
|
-
flapjack.given("no
|
232
|
-
upon_receiving("a PATCH request
|
248
|
+
it "can't find the contact to update" do
|
249
|
+
flapjack.given("no data exists").
|
250
|
+
upon_receiving("a PATCH request for a single contact").
|
233
251
|
with(:method => :patch,
|
234
|
-
:path =>
|
235
|
-
:body =>
|
236
|
-
:headers => {'Content-Type'=>'application/
|
252
|
+
:path => "/contacts/#{contact_data[:id]}",
|
253
|
+
:body => {:data => {:id => contact_data[:id], :type => 'contact', :attributes => {:name => 'Hello There'}}},
|
254
|
+
:headers => {'Content-Type' => 'application/vnd.api+json'}).
|
237
255
|
will_respond_with(
|
238
256
|
:status => 404,
|
239
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
240
|
-
:body => {:errors => [
|
241
|
-
|
242
|
-
|
257
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
258
|
+
:body => {:errors => [{
|
259
|
+
:status => '404',
|
260
|
+
:detail => "could not find Contact record, id: '#{contact_data[:id]}'"
|
261
|
+
}]}
|
262
|
+
)
|
263
|
+
|
264
|
+
result = Flapjack::Diner.update_contacts(:id => contact_data[:id], :name => 'Hello There')
|
243
265
|
expect(result).to be_nil
|
244
|
-
expect(Flapjack::Diner.
|
245
|
-
:
|
266
|
+
expect(Flapjack::Diner.error).to eq([{:status => '404',
|
267
|
+
:detail => "could not find Contact record, id: '#{contact_data[:id]}'"}])
|
246
268
|
end
|
247
|
-
|
248
269
|
end
|
249
270
|
|
250
271
|
context 'delete' do
|
272
|
+
|
251
273
|
it "submits a DELETE request for one contact" do
|
252
|
-
flapjack.given("a contact
|
274
|
+
flapjack.given("a contact exists").
|
253
275
|
upon_receiving("a DELETE request for a single contact").
|
254
276
|
with(:method => :delete,
|
255
|
-
:path =>
|
277
|
+
:path => "/contacts/#{contact_data[:id]}",
|
256
278
|
:body => nil).
|
257
279
|
will_respond_with(:status => 204,
|
258
280
|
:body => '')
|
259
281
|
|
260
|
-
result = Flapjack::Diner.delete_contacts(
|
261
|
-
expect(result).
|
262
|
-
expect(result).to be_truthy
|
282
|
+
result = Flapjack::Diner.delete_contacts(contact_data[:id])
|
283
|
+
expect(result).to be_a(TrueClass)
|
263
284
|
end
|
264
285
|
|
265
286
|
it "submits a DELETE request for several contacts" do
|
266
|
-
|
287
|
+
contacts_data = [{:type => 'contact', :id => contact_data[:id]},
|
288
|
+
{:type => 'contact', :id => contact_2_data[:id]}]
|
289
|
+
|
290
|
+
flapjack.given("two contacts exist").
|
267
291
|
upon_receiving("a DELETE request for two contacts").
|
268
292
|
with(:method => :delete,
|
269
|
-
:
|
270
|
-
:
|
293
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; ext=bulk'},
|
294
|
+
:path => "/contacts",
|
295
|
+
:body => {:data => contacts_data}).
|
271
296
|
will_respond_with(:status => 204,
|
272
297
|
:body => '')
|
273
298
|
|
274
|
-
result = Flapjack::Diner.delete_contacts(
|
275
|
-
expect(result).
|
276
|
-
expect(result).to be_truthy
|
299
|
+
result = Flapjack::Diner.delete_contacts(contact_data[:id], contact_2_data[:id])
|
300
|
+
expect(result).to be_a(TrueClass)
|
277
301
|
end
|
278
302
|
|
279
303
|
it "can't find the contact to delete" do
|
280
|
-
flapjack.given("no
|
304
|
+
flapjack.given("no data exists").
|
281
305
|
upon_receiving("a DELETE request for a single contact").
|
282
306
|
with(:method => :delete,
|
283
|
-
:path =>
|
307
|
+
:path => "/contacts/#{contact_data[:id]}",
|
284
308
|
:body => nil).
|
285
309
|
will_respond_with(
|
286
310
|
:status => 404,
|
287
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
288
|
-
:body => {:errors => [
|
289
|
-
|
290
|
-
|
311
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
312
|
+
:body => {:errors => [{
|
313
|
+
:status => '404',
|
314
|
+
:detail => "could not find Contact record, id: '#{contact_data[:id]}'"
|
315
|
+
}]}
|
316
|
+
)
|
317
|
+
|
318
|
+
result = Flapjack::Diner.delete_contacts(contact_data[:id])
|
291
319
|
expect(result).to be_nil
|
292
|
-
expect(Flapjack::Diner.
|
293
|
-
:
|
320
|
+
expect(Flapjack::Diner.error).to eq([{:status => '404',
|
321
|
+
:detail => "could not find Contact record, id: '#{contact_data[:id]}'"}])
|
294
322
|
end
|
295
323
|
end
|
296
324
|
|