flapjack-diner 2.0.0.pre.alpha.2 → 2.0.0.pre.alpha.3

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.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flapjack-diner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.alpha.2
4
+ version: 2.0.0.pre.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Graham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-09 00:00:00.000000000 Z
11
+ date: 2015-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -58,15 +58,15 @@ files:
58
58
  - lib/flapjack-diner.rb
59
59
  - lib/flapjack-diner/argument_validator.rb
60
60
  - lib/flapjack-diner/index_range.rb
61
- - lib/flapjack-diner/resources/blackholes.rb
61
+ - lib/flapjack-diner/resources/acceptors.rb
62
62
  - lib/flapjack-diner/resources/checks.rb
63
63
  - lib/flapjack-diner/resources/contacts.rb
64
64
  - lib/flapjack-diner/resources/events.rb
65
65
  - lib/flapjack-diner/resources/maintenance_periods.rb
66
66
  - lib/flapjack-diner/resources/media.rb
67
67
  - lib/flapjack-diner/resources/metrics.rb
68
+ - lib/flapjack-diner/resources/rejectors.rb
68
69
  - lib/flapjack-diner/resources/relationships.rb
69
- - lib/flapjack-diner/resources/rules.rb
70
70
  - lib/flapjack-diner/resources/states.rb
71
71
  - lib/flapjack-diner/resources/statistics.rb
72
72
  - lib/flapjack-diner/resources/tags.rb
@@ -75,15 +75,15 @@ files:
75
75
  - log/.gitkeep
76
76
  - spec/argument_validator_spec.rb
77
77
  - spec/flapjack-diner_spec.rb
78
- - spec/resources/blackholes_spec.rb
78
+ - spec/resources/acceptors_spec.rb
79
79
  - spec/resources/checks_spec.rb
80
80
  - spec/resources/contacts_spec.rb
81
81
  - spec/resources/events_spec.rb
82
82
  - spec/resources/maintenance_periods_spec.rb
83
83
  - spec/resources/media_spec.rb
84
84
  - spec/resources/metrics_spec.rb
85
+ - spec/resources/rejectors_spec.rb
85
86
  - spec/resources/relationships_spec.rb
86
- - spec/resources/rules_spec.rb
87
87
  - spec/resources/states_spec.rb
88
88
  - spec/resources/statistics_spec.rb
89
89
  - spec/resources/tags_spec.rb
@@ -115,15 +115,15 @@ summary: Access the API of a Flapjack system monitoring server
115
115
  test_files:
116
116
  - spec/argument_validator_spec.rb
117
117
  - spec/flapjack-diner_spec.rb
118
- - spec/resources/blackholes_spec.rb
118
+ - spec/resources/acceptors_spec.rb
119
119
  - spec/resources/checks_spec.rb
120
120
  - spec/resources/contacts_spec.rb
121
121
  - spec/resources/events_spec.rb
122
122
  - spec/resources/maintenance_periods_spec.rb
123
123
  - spec/resources/media_spec.rb
124
124
  - spec/resources/metrics_spec.rb
125
+ - spec/resources/rejectors_spec.rb
125
126
  - spec/resources/relationships_spec.rb
126
- - spec/resources/rules_spec.rb
127
127
  - spec/resources/states_spec.rb
128
128
  - spec/resources/statistics_spec.rb
129
129
  - spec/resources/tags_spec.rb
@@ -1,278 +0,0 @@
1
- require 'spec_helper'
2
- require 'flapjack-diner'
3
-
4
- describe Flapjack::Diner::Resources::Blackholes, :pact => true do
5
-
6
- before(:each) do
7
- Flapjack::Diner.base_uri('localhost:19081')
8
- Flapjack::Diner.logger = nil
9
- end
10
-
11
- context 'create' do
12
-
13
- it "submits a POST request for a blackhole" do
14
- req_data = blackhole_json(blackhole_data).merge(
15
- :relationships => {
16
- :contact => {
17
- :data => {
18
- :type => 'contact',
19
- :id => contact_data[:id]
20
- }
21
- }
22
- }
23
- )
24
- resp_data = blackhole_json(blackhole_data).merge(:relationships => blackhole_rel(blackhole_data))
25
-
26
- flapjack.given("a contact exists").
27
- upon_receiving("a POST request with one blackhole").
28
- with(:method => :post, :path => '/blackholes',
29
- :headers => {'Content-Type' => 'application/vnd.api+json'},
30
- :body => {:data => req_data}).
31
- will_respond_with(
32
- :status => 201,
33
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
34
- :body => {:data => resp_data}
35
- )
36
-
37
- result = Flapjack::Diner.create_blackholes(blackhole_data.merge(:contact => contact_data[:id]))
38
- expect(result).not_to be_nil
39
- expect(result).to eq(resultify(resp_data))
40
- end
41
-
42
- it "submits a POST request for several blackholes" do
43
- req_data = [blackhole_json(blackhole_data).merge(
44
- :relationships => {
45
- :contact => {
46
- :data => {
47
- :type => 'contact',
48
- :id => contact_data[:id]
49
- }
50
- }
51
- }
52
- ), blackhole_json(blackhole_2_data).merge(
53
- :relationships => {
54
- :contact => {
55
- :data => {
56
- :type => 'contact',
57
- :id => contact_data[:id]
58
- }
59
- }
60
- }
61
- )]
62
- resp_data = [
63
- blackhole_json(blackhole_data).merge(:relationships => blackhole_rel(blackhole_data)),
64
- blackhole_json(blackhole_2_data).merge(:relationships => blackhole_rel(blackhole_2_data))
65
- ]
66
-
67
- flapjack.given("a contact exists").
68
- upon_receiving("a POST request with two blackholes").
69
- with(:method => :post, :path => '/blackholes',
70
- :headers => {'Content-Type' => 'application/vnd.api+json; ext=bulk'},
71
- :body => {:data => req_data}).
72
- will_respond_with(
73
- :status => 201,
74
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
75
- :body => {:data => resp_data}
76
- )
77
-
78
- result = Flapjack::Diner.create_blackholes(blackhole_data.merge(:contact => contact_data[:id]),
79
- blackhole_2_data.merge(:contact => contact_data[:id]))
80
- expect(result).not_to be_nil
81
- expect(result).to eq(resultify(resp_data))
82
- end
83
-
84
- # TODO error due to invalid data
85
-
86
- end
87
-
88
- context 'read' do
89
-
90
- it "submits a GET request for all blackholes" do
91
- resp_data = [blackhole_json(blackhole_data).merge(:relationships => blackhole_rel(blackhole_data))]
92
-
93
- flapjack.given("a blackhole exists").
94
- upon_receiving("a GET request for all blackholes").
95
- with(:method => :get, :path => '/blackholes').
96
- will_respond_with(
97
- :status => 200,
98
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
99
- :body => {:data => resp_data} )
100
-
101
- result = Flapjack::Diner.blackholes
102
- expect(result).not_to be_nil
103
- expect(result).to eq(resultify(resp_data))
104
- end
105
-
106
- it "submits a GET request for one blackhole" do
107
- resp_data = blackhole_json(blackhole_data).merge(:relationships => blackhole_rel(blackhole_data))
108
-
109
- flapjack.given("a blackhole exists").
110
- upon_receiving("a GET request for a single blackhole").
111
- with(:method => :get, :path => "/blackholes/#{blackhole_data[:id]}").
112
- will_respond_with(
113
- :status => 200,
114
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
115
- :body => {:data => resp_data}
116
- )
117
-
118
- result = Flapjack::Diner.blackholes(blackhole_data[:id])
119
- expect(result).not_to be_nil
120
- expect(result).to eq(resultify(resp_data))
121
- end
122
-
123
- it "submits a GET request for several blackholes" do
124
- resp_data = [
125
- blackhole_json(blackhole_data).merge(:relationships => blackhole_rel(blackhole_data)),
126
- blackhole_json(blackhole_2_data).merge(:relationships => blackhole_rel(blackhole_2_data))
127
- ]
128
-
129
- blackholes_data = [blackhole_data.merge(:type => 'blackhole'), blackhole_2_data.merge(:type => 'blackhole')]
130
-
131
- flapjack.given("two blackholes exist").
132
- upon_receiving("a GET request for two blackholes").
133
- with(:method => :get, :path => "/blackholes",
134
- :query => "filter%5B%5D=id%3A#{blackhole_data[:id]}%7C#{blackhole_2_data[:id]}").
135
- will_respond_with(
136
- :status => 200,
137
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
138
- :body => {:data => resp_data} )
139
-
140
- result = Flapjack::Diner.blackholes(blackhole_data[:id], blackhole_2_data[:id])
141
- expect(result).not_to be_nil
142
- expect(result).to eq(resultify(resp_data))
143
- end
144
-
145
- it "can't find the blackhole to read" do
146
- flapjack.given("no data exists").
147
- upon_receiving("a GET request for a single blackhole").
148
- with(:method => :get, :path => "/blackholes/#{blackhole_data[:id]}").
149
- will_respond_with(
150
- :status => 404,
151
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
152
- :body => {:errors => [{
153
- :status => '404',
154
- :detail => "could not find Blackhole record, id: '#{blackhole_data[:id]}'"
155
- }]}
156
- )
157
-
158
- result = Flapjack::Diner.blackholes(blackhole_data[:id])
159
- expect(result).to be_nil
160
- expect(Flapjack::Diner.last_error).to eq([{:status => '404',
161
- :detail => "could not find Blackhole record, id: '#{blackhole_data[:id]}'"}])
162
- end
163
-
164
- end
165
-
166
- # # Not immediately relevant, no data fields to update until time_restrictions are fixed
167
- # context 'update' do
168
- # it 'submits a PUT request for a blackhole' do
169
- # flapjack.given("a blackhole exists").
170
- # upon_receiving("a PUT request for a single blackhole").
171
- # with(:method => :put,
172
- # :path => "/blackholes/#{blackhole_data[:id]}",
173
- # :body => {:blackholes => {:id => blackhole_data[:id], :time_restrictions => []}},
174
- # :headers => {'Content-Type' => 'application/vnd.api+json'}).
175
- # will_respond_with(
176
- # :status => 204,
177
- # :body => '' )
178
-
179
- # result = Flapjack::Diner.update_blackholes(:id => blackhole_data[:id], :time_restrictions => [])
180
- # expect(result).to be_a(TrueClass)
181
- # end
182
-
183
- # it 'submits a PUT request for several blackholes' do
184
- # flapjack.given("two blackholes exist").
185
- # upon_receiving("a PUT request for two blackholes").
186
- # with(:method => :put,
187
- # :path => "/blackholes/#{blackhole_data[:id]},#{blackhole_2_data[:id]}",
188
- # :body => {:blackholes => [{:id => blackhole_data[:id], :time_restrictions => []},
189
- # {:id => blackhole_2_data[:id], :enabled => true}]},
190
- # :headers => {'Content-Type' => 'application/vnd.api+json'}).
191
- # will_respond_with(
192
- # :status => 204,
193
- # :body => '' )
194
-
195
- # result = Flapjack::Diner.update_blackholes(
196
- # {:id => blackhole_data[:id], :time_restrictions => []},
197
- # {:id => blackhole_2_data[:id], :enabled => true})
198
- # expect(result).to be_a(TrueClass)
199
- # end
200
-
201
- # it "can't find the blackhole to update" do
202
- # flapjack.given("no data exists").
203
- # upon_receiving("a PUT request for a single blackhole").
204
- # with(:method => :put,
205
- # :path => "/blackholes/#{blackhole_data[:id]}",
206
- # :body => {:blackholes => {:id => blackhole_data[:id], :time_restrictions => []}},
207
- # :headers => {'Content-Type' => 'application/vnd.api+json'}).
208
- # will_respond_with(
209
- # :status => 404,
210
- # :headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
211
- # :body => {:errors => [{
212
- # :status => '404',
213
- # :detail => "could not find Blackhole records, ids: '#{blackhole_data[:id]}'"
214
- # }]}
215
- # )
216
-
217
- # result = Flapjack::Diner.update_blackholes(:id => blackhole_data[:id], :time_restrictions => [])
218
- # expect(result).to be_nil
219
- # expect(Flapjack::Diner.last_error).to eq([{:status => '404',
220
- # :detail => "could not find Blackhole records, ids: '#{blackhole_data[:id]}'"}])
221
- # end
222
- # end
223
-
224
- context 'delete' do
225
-
226
- it "submits a DELETE request for a blackhole" do
227
- flapjack.given("a blackhole exists").
228
- upon_receiving("a DELETE request for a single blackhole").
229
- with(:method => :delete,
230
- :path => "/blackholes/#{blackhole_data[:id]}",
231
- :body => nil).
232
- will_respond_with(:status => 204,
233
- :body => '')
234
-
235
- result = Flapjack::Diner.delete_blackholes(blackhole_data[:id])
236
- expect(result).to be_a(TrueClass)
237
- end
238
-
239
- it "submits a DELETE request for several blackholes" do
240
- blackholes_data = [{:type => 'blackhole', :id => blackhole_data[:id]},
241
- {:type => 'blackhole', :id => blackhole_2_data[:id]}]
242
-
243
- flapjack.given("two blackholes exist").
244
- upon_receiving("a DELETE request for two blackholes").
245
- with(:method => :delete,
246
- :headers => {'Content-Type' => 'application/vnd.api+json; ext=bulk'},
247
- :path => "/blackholes",
248
- :body => {:data => blackholes_data}).
249
- will_respond_with(:status => 204,
250
- :body => '')
251
-
252
- result = Flapjack::Diner.delete_blackholes(blackhole_data[:id], blackhole_2_data[:id])
253
- expect(result).to be_a(TrueClass)
254
- end
255
-
256
- it "can't find the blackhole to delete" do
257
- flapjack.given("no data exists").
258
- upon_receiving("a DELETE request for a single blackhole").
259
- with(:method => :delete,
260
- :path => "/blackholes/#{blackhole_data[:id]}",
261
- :body => nil).
262
- will_respond_with(
263
- :status => 404,
264
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
265
- :body => {:errors => [{
266
- :status => '404',
267
- :detail => "could not find Blackhole record, id: '#{blackhole_data[:id]}'"
268
- }]}
269
- )
270
-
271
- result = Flapjack::Diner.delete_blackholes(blackhole_data[:id])
272
- expect(result).to be_nil
273
- expect(Flapjack::Diner.last_error).to eq([{:status => '404',
274
- :detail => "could not find Blackhole record, id: '#{blackhole_data[:id]}'"}])
275
- end
276
- end
277
-
278
- end
@@ -1,278 +0,0 @@
1
- require 'spec_helper'
2
- require 'flapjack-diner'
3
-
4
- describe Flapjack::Diner::Resources::Rules, :pact => true do
5
-
6
- before(:each) do
7
- Flapjack::Diner.base_uri('localhost:19081')
8
- Flapjack::Diner.logger = nil
9
- end
10
-
11
- context 'create' do
12
-
13
- it "submits a POST request for a rule" do
14
- req_data = rule_json(rule_data).merge(
15
- :relationships => {
16
- :contact => {
17
- :data => {
18
- :type => 'contact',
19
- :id => contact_data[:id]
20
- }
21
- }
22
- }
23
- )
24
- resp_data = rule_json(rule_data).merge(:relationships => rule_rel(rule_data))
25
-
26
- flapjack.given("a contact exists").
27
- upon_receiving("a POST request with one rule").
28
- with(:method => :post, :path => '/rules',
29
- :headers => {'Content-Type' => 'application/vnd.api+json'},
30
- :body => {:data => req_data}).
31
- will_respond_with(
32
- :status => 201,
33
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
34
- :body => {:data => resp_data}
35
- )
36
-
37
- result = Flapjack::Diner.create_rules(rule_data.merge(:contact => contact_data[:id]))
38
- expect(result).not_to be_nil
39
- expect(result).to eq(resultify(resp_data))
40
- end
41
-
42
- it "submits a POST request for several rules" do
43
- req_data = [rule_json(rule_data).merge(
44
- :relationships => {
45
- :contact => {
46
- :data => {
47
- :type => 'contact',
48
- :id => contact_data[:id]
49
- }
50
- }
51
- }
52
- ), rule_json(rule_2_data).merge(
53
- :relationships => {
54
- :contact => {
55
- :data => {
56
- :type => 'contact',
57
- :id => contact_data[:id]
58
- }
59
- }
60
- }
61
- )]
62
- resp_data = [
63
- rule_json(rule_data).merge(:relationships => rule_rel(rule_data)),
64
- rule_json(rule_2_data).merge(:relationships => rule_rel(rule_2_data))
65
- ]
66
-
67
- flapjack.given("a contact exists").
68
- upon_receiving("a POST request with two rules").
69
- with(:method => :post, :path => '/rules',
70
- :headers => {'Content-Type' => 'application/vnd.api+json; ext=bulk'},
71
- :body => {:data => req_data}).
72
- will_respond_with(
73
- :status => 201,
74
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
75
- :body => {:data => resp_data}
76
- )
77
-
78
- result = Flapjack::Diner.create_rules(rule_data.merge(:contact => contact_data[:id]),
79
- rule_2_data.merge(:contact => contact_data[:id]))
80
- expect(result).not_to be_nil
81
- expect(result).to eq(resultify(resp_data))
82
- end
83
-
84
- # TODO error due to invalid data
85
-
86
- end
87
-
88
- context 'read' do
89
-
90
- it "submits a GET request for all rules" do
91
- resp_data = [rule_json(rule_data).merge(:relationships => rule_rel(rule_data))]
92
-
93
- flapjack.given("a rule exists").
94
- upon_receiving("a GET request for all rules").
95
- with(:method => :get, :path => '/rules').
96
- will_respond_with(
97
- :status => 200,
98
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
99
- :body => {:data => resp_data} )
100
-
101
- result = Flapjack::Diner.rules
102
- expect(result).not_to be_nil
103
- expect(result).to eq(resultify(resp_data))
104
- end
105
-
106
- it "submits a GET request for one rule" do
107
- resp_data = rule_json(rule_data).merge(:relationships => rule_rel(rule_data))
108
-
109
- flapjack.given("a rule exists").
110
- upon_receiving("a GET request for a single rule").
111
- with(:method => :get, :path => "/rules/#{rule_data[:id]}").
112
- will_respond_with(
113
- :status => 200,
114
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
115
- :body => {:data => resp_data}
116
- )
117
-
118
- result = Flapjack::Diner.rules(rule_data[:id])
119
- expect(result).not_to be_nil
120
- expect(result).to eq(resultify(resp_data))
121
- end
122
-
123
- it "submits a GET request for several rules" do
124
- resp_data = [
125
- rule_json(rule_data).merge(:relationships => rule_rel(rule_data)),
126
- rule_json(rule_2_data).merge(:relationships => rule_rel(rule_2_data))
127
- ]
128
-
129
- rules_data = [rule_data.merge(:type => 'rule'), rule_2_data.merge(:type => 'rule')]
130
-
131
- flapjack.given("two rules exist").
132
- upon_receiving("a GET request for two rules").
133
- with(:method => :get, :path => "/rules",
134
- :query => "filter%5B%5D=id%3A#{rule_data[:id]}%7C#{rule_2_data[:id]}").
135
- will_respond_with(
136
- :status => 200,
137
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
138
- :body => {:data => resp_data} )
139
-
140
- result = Flapjack::Diner.rules(rule_data[:id], rule_2_data[:id])
141
- expect(result).not_to be_nil
142
- expect(result).to eq(resultify(resp_data))
143
- end
144
-
145
- it "can't find the rule to read" do
146
- flapjack.given("no data exists").
147
- upon_receiving("a GET request for a single rule").
148
- with(:method => :get, :path => "/rules/#{rule_data[:id]}").
149
- will_respond_with(
150
- :status => 404,
151
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
152
- :body => {:errors => [{
153
- :status => '404',
154
- :detail => "could not find Rule record, id: '#{rule_data[:id]}'"
155
- }]}
156
- )
157
-
158
- result = Flapjack::Diner.rules(rule_data[:id])
159
- expect(result).to be_nil
160
- expect(Flapjack::Diner.last_error).to eq([{:status => '404',
161
- :detail => "could not find Rule record, id: '#{rule_data[:id]}'"}])
162
- end
163
-
164
- end
165
-
166
- # # Not immediately relevant, no data fields to update until time_restrictions are fixed
167
- # context 'update' do
168
- # it 'submits a PUT request for a rule' do
169
- # flapjack.given("a rule exists").
170
- # upon_receiving("a PUT request for a single rule").
171
- # with(:method => :put,
172
- # :path => "/rules/#{rule_data[:id]}",
173
- # :body => {:rules => {:id => rule_data[:id], :time_restrictions => []}},
174
- # :headers => {'Content-Type' => 'application/vnd.api+json'}).
175
- # will_respond_with(
176
- # :status => 204,
177
- # :body => '' )
178
-
179
- # result = Flapjack::Diner.update_rules(:id => rule_data[:id], :time_restrictions => [])
180
- # expect(result).to be_a(TrueClass)
181
- # end
182
-
183
- # it 'submits a PUT request for several rules' do
184
- # flapjack.given("two rules exist").
185
- # upon_receiving("a PUT request for two rules").
186
- # with(:method => :put,
187
- # :path => "/rules/#{rule_data[:id]},#{rule_2_data[:id]}",
188
- # :body => {:rules => [{:id => rule_data[:id], :time_restrictions => []},
189
- # {:id => rule_2_data[:id], :enabled => true}]},
190
- # :headers => {'Content-Type' => 'application/vnd.api+json'}).
191
- # will_respond_with(
192
- # :status => 204,
193
- # :body => '' )
194
-
195
- # result = Flapjack::Diner.update_rules(
196
- # {:id => rule_data[:id], :time_restrictions => []},
197
- # {:id => rule_2_data[:id], :enabled => true})
198
- # expect(result).to be_a(TrueClass)
199
- # end
200
-
201
- # it "can't find the rule to update" do
202
- # flapjack.given("no data exists").
203
- # upon_receiving("a PUT request for a single rule").
204
- # with(:method => :put,
205
- # :path => "/rules/#{rule_data[:id]}",
206
- # :body => {:rules => {:id => rule_data[:id], :time_restrictions => []}},
207
- # :headers => {'Content-Type' => 'application/vnd.api+json'}).
208
- # will_respond_with(
209
- # :status => 404,
210
- # :headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
211
- # :body => {:errors => [{
212
- # :status => '404',
213
- # :detail => "could not find Rule records, ids: '#{rule_data[:id]}'"
214
- # }]}
215
- # )
216
-
217
- # result = Flapjack::Diner.update_rules(:id => rule_data[:id], :time_restrictions => [])
218
- # expect(result).to be_nil
219
- # expect(Flapjack::Diner.last_error).to eq([{:status => '404',
220
- # :detail => "could not find Rule records, ids: '#{rule_data[:id]}'"}])
221
- # end
222
- # end
223
-
224
- context 'delete' do
225
-
226
- it "submits a DELETE request for a rule" do
227
- flapjack.given("a rule exists").
228
- upon_receiving("a DELETE request for a single rule").
229
- with(:method => :delete,
230
- :path => "/rules/#{rule_data[:id]}",
231
- :body => nil).
232
- will_respond_with(:status => 204,
233
- :body => '')
234
-
235
- result = Flapjack::Diner.delete_rules(rule_data[:id])
236
- expect(result).to be_a(TrueClass)
237
- end
238
-
239
- it "submits a DELETE request for several rules" do
240
- rules_data = [{:type => 'rule', :id => rule_data[:id]},
241
- {:type => 'rule', :id => rule_2_data[:id]}]
242
-
243
- flapjack.given("two rules exist").
244
- upon_receiving("a DELETE request for two rules").
245
- with(:method => :delete,
246
- :headers => {'Content-Type' => 'application/vnd.api+json; ext=bulk'},
247
- :path => "/rules",
248
- :body => {:data => rules_data}).
249
- will_respond_with(:status => 204,
250
- :body => '')
251
-
252
- result = Flapjack::Diner.delete_rules(rule_data[:id], rule_2_data[:id])
253
- expect(result).to be_a(TrueClass)
254
- end
255
-
256
- it "can't find the rule to delete" do
257
- flapjack.given("no data exists").
258
- upon_receiving("a DELETE request for a single rule").
259
- with(:method => :delete,
260
- :path => "/rules/#{rule_data[:id]}",
261
- :body => nil).
262
- will_respond_with(
263
- :status => 404,
264
- :headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
265
- :body => {:errors => [{
266
- :status => '404',
267
- :detail => "could not find Rule record, id: '#{rule_data[:id]}'"
268
- }]}
269
- )
270
-
271
- result = Flapjack::Diner.delete_rules(rule_data[:id])
272
- expect(result).to be_nil
273
- expect(Flapjack::Diner.last_error).to eq([{:status => '404',
274
- :detail => "could not find Rule record, id: '#{rule_data[:id]}'"}])
275
- end
276
- end
277
-
278
- end