MuranoCLI 3.0.2 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +30 -59
  3. data/Gemfile +9 -3
  4. data/MuranoCLI.gemspec +11 -4
  5. data/bin/murano +2 -90
  6. data/lib/MrMurano.rb +5 -1
  7. data/lib/MrMurano/{spec_commander.rb → Commander-Entry.rb} +1 -2
  8. data/lib/MrMurano/Solution.rb +12 -15
  9. data/lib/MrMurano/SolutionId.rb +1 -5
  10. data/lib/MrMurano/SyncAllowed.rb +2 -2
  11. data/lib/MrMurano/SyncUpDown.rb +6 -3
  12. data/lib/MrMurano/progress.rb +11 -2
  13. data/lib/MrMurano/verbosing.rb +3 -2
  14. data/lib/MrMurano/version.rb +2 -2
  15. data/spec/Account-Passwords_spec.rb +34 -48
  16. data/spec/Account_spec.rb +58 -63
  17. data/spec/Business_spec.rb +151 -139
  18. data/spec/ConfigFile_spec.rb +15 -11
  19. data/spec/ConfigMigrate_spec.rb +23 -12
  20. data/spec/Config_spec.rb +57 -54
  21. data/spec/Content_spec.rb +233 -201
  22. data/spec/GatewayBase_spec.rb +35 -27
  23. data/spec/GatewayDevice_spec.rb +149 -149
  24. data/spec/GatewayResource_spec.rb +115 -102
  25. data/spec/GatewaySettings_spec.rb +69 -62
  26. data/spec/Http_spec.rb +66 -56
  27. data/spec/MakePretties_spec.rb +82 -73
  28. data/spec/Mock_spec.rb +38 -29
  29. data/spec/ProjectFile_spec.rb +118 -106
  30. data/spec/Setting_spec.rb +24 -15
  31. data/spec/Solution-ServiceConfig_spec.rb +168 -140
  32. data/spec/Solution-ServiceEventHandler_spec.rb +186 -188
  33. data/spec/Solution-ServiceModules_spec.rb +314 -232
  34. data/spec/Solution-UsersRoles_spec.rb +136 -86
  35. data/spec/Solution_spec.rb +78 -50
  36. data/spec/SyncRoot_spec.rb +26 -24
  37. data/spec/SyncUpDown_spec.rb +268 -249
  38. data/spec/Verbosing_spec.rb +95 -93
  39. data/spec/Webservice-Cors_spec.rb +141 -95
  40. data/spec/Webservice-Endpoint_spec.rb +382 -346
  41. data/spec/Webservice-File_spec.rb +148 -109
  42. data/spec/Webservice-Setting_spec.rb +47 -41
  43. data/spec/cmd_business_spec.rb +17 -17
  44. data/spec/cmd_common.rb +27 -7
  45. data/spec/cmd_config_spec.rb +31 -20
  46. data/spec/cmd_content_spec.rb +80 -68
  47. data/spec/cmd_cors_spec.rb +11 -5
  48. data/spec/cmd_device_spec.rb +16 -14
  49. data/spec/cmd_domain_spec.rb +10 -8
  50. data/spec/cmd_exchange_spec.rb +3 -3
  51. data/spec/cmd_init_spec.rb +100 -101
  52. data/spec/cmd_keystore_spec.rb +17 -12
  53. data/spec/cmd_link_spec.rb +22 -37
  54. data/spec/cmd_password_spec.rb +11 -7
  55. data/spec/cmd_setting_application_spec.rb +47 -33
  56. data/spec/cmd_setting_product_spec.rb +32 -27
  57. data/spec/cmd_status_spec.rb +125 -114
  58. data/spec/cmd_syncdown_spec.rb +70 -65
  59. data/spec/cmd_syncup_spec.rb +19 -15
  60. data/spec/cmd_usage_spec.rb +14 -10
  61. metadata +29 -15
@@ -1,3 +1,10 @@
1
+ # Last Modified: 2017.09.13 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
1
8
  require 'fileutils'
2
9
  require 'MrMurano/version'
3
10
  require 'MrMurano/SyncRoot'
@@ -5,7 +12,7 @@ require 'MrMurano/Gateway'
5
12
  require '_workspace'
6
13
 
7
14
  RSpec.describe MrMurano::Gateway::GweBase do
8
- include_context "WORKSPACE"
15
+ include_context 'WORKSPACE'
9
16
  before(:example) do
10
17
  MrMurano::SyncRoot.instance.reset
11
18
  $cfg = MrMurano::Config.new
@@ -14,41 +21,42 @@ RSpec.describe MrMurano::Gateway::GweBase do
14
21
  $cfg['product.id'] = 'XYZ'
15
22
 
16
23
  @gw = MrMurano::Gateway::GweBase.new
17
- allow(@gw).to receive(:token).and_return("TTTTTTTTTT")
24
+ allow(@gw).to receive(:token).and_return('TTTTTTTTTT')
18
25
  end
19
26
 
20
- it "initializes" do
27
+ it 'initializes' do
21
28
  uri = @gw.endpoint('/')
22
- expect(uri.to_s).to eq("https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/")
29
+ expect(uri.to_s).to eq('https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/')
23
30
  end
24
31
 
25
- it "gets info" do
32
+ it 'gets info' do
26
33
  body = {
27
- :name=>"XXXXXXXX",
28
- :protocol=>{:name=>"onep", :auth_type=>"cik"},
29
- :description=>"XXXXXXXX",
30
- :identity_format=> {
31
- :prefix=>"", :type=>"opaque", :options=>{:casing=>"mixed", :length=>0}},
32
- :fqdn=>"XXXXXXXX.m2.exosite-staging.io",
33
- :provisioning=> {
34
- :enabled=>true,
35
- :generate_identity=>true,
36
- :presenter_identity=>true,
37
- :ip_whitelisting=>{:enabled=>false, :allowed=>[]}},
38
- :resources=> {
39
- :bob=>{:format=>"string", :unit=>"c", :settable=>true},
40
- :fuzz=>{:format=>"string", :unit=>"c", :settable=>true},
41
- :gruble=>{:format=>"string", :unit=>"bits", :settable=>true}
42
- }
34
+ name: 'XXXXXXXX',
35
+ protocol: { name: 'onep', auth_type: 'cik' },
36
+ description: 'XXXXXXXX',
37
+ identity_format: {
38
+ prefix: '', type: 'opaque', options: { casing: 'mixed', length: 0 },
39
+ },
40
+ fqdn: 'XXXXXXXX.m2.exosite-staging.io',
41
+ provisioning: {
42
+ enabled: true,
43
+ generate_identity: true,
44
+ presenter_identity: true,
45
+ ip_whitelisting: { enabled: false, allowed: [] },
46
+ },
47
+ resources: {
48
+ bob: { format: 'string', unit: 'c', settable: true },
49
+ fuzz: { format: 'string', unit: 'c', settable: true },
50
+ gruble: { format: 'string', unit: 'bits', settable: true },
51
+ },
43
52
  }
44
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2").
45
- with(:headers => {'Authorization'=>'token TTTTTTTTTT', 'Content-Type'=>'application/json'}).
46
- to_return(:status => 200, :body => body.to_json, :headers => {})
47
-
53
+ stub_request(
54
+ :get, 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2'
55
+ ).with(
56
+ headers: { 'Authorization' => 'token TTTTTTTTTT', 'Content-Type' => 'application/json' }
57
+ ).to_return(status: 200, body: body.to_json, headers: {})
48
58
  ret = @gw.info
49
59
  expect(ret).to eq(body)
50
60
  end
51
-
52
61
  end
53
62
 
54
- # vim: set ai et sw=2 ts=2 :
@@ -1,4 +1,4 @@
1
- # Last Modified: 2017.08.23 /coding: utf-8
1
+ # Last Modified: 2017.09.12 /coding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # Copyright © 2016-2017 Exosite LLC.
@@ -12,7 +12,7 @@ require 'MrMurano/SyncRoot'
12
12
  require '_workspace'
13
13
 
14
14
  RSpec.describe MrMurano::Gateway::Device do
15
- include_context "WORKSPACE"
15
+ include_context 'WORKSPACE'
16
16
  before(:example) do
17
17
  MrMurano::SyncRoot.instance.reset
18
18
  $cfg = MrMurano::Config.new
@@ -21,232 +21,233 @@ RSpec.describe MrMurano::Gateway::Device do
21
21
  $cfg['product.id'] = 'XYZ'
22
22
 
23
23
  @gw = MrMurano::Gateway::Device.new
24
- allow(@gw).to receive(:token).and_return("TTTTTTTTTT")
24
+ allow(@gw).to receive(:token).and_return('TTTTTTTTTT')
25
25
  end
26
26
 
27
- it "initializes" do
27
+ it 'initializes' do
28
28
  uri = @gw.endpoint('/')
29
- expect(uri.to_s).to eq("https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/")
29
+ expect(uri.to_s).to eq('https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/')
30
30
  end
31
31
 
32
- context "listing" do
33
- it "lists" do
32
+ context 'listing' do
33
+ it 'lists' do
34
34
  body = {
35
35
  mayLoadMore: false,
36
36
  devices:
37
- [{identity: "58",
38
- auth: {type: "cik"},
39
- state: {},
40
- locked: false,
41
- reprovision: false,
42
- devmode: false,
43
- lastip: "",
44
- lastseen: 1487021743864000,
45
- status: "provisioned",
46
- online: false},
47
- {identity: "56",
48
- auth: {type: "cik"},
49
- state: {},
50
- locked: false,
51
- reprovision: false,
52
- devmode: false,
53
- lastip: "",
54
- lastseen: 1487021650584000,
55
- status: "provisioned",
56
- online: false},
57
- ]}
58
- stub_request(
59
- :get,
60
- "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/"
61
- ).to_return(body: body.to_json)
37
+ [{ identity: '58',
38
+ auth: { type: 'cik' },
39
+ state: {},
40
+ locked: false,
41
+ reprovision: false,
42
+ devmode: false,
43
+ lastip: '',
44
+ lastseen: 1_487_021_743_864_000,
45
+ status: 'provisioned',
46
+ online: false, },
47
+ { identity: '56',
48
+ auth: { type: 'cik' },
49
+ state: {},
50
+ locked: false,
51
+ reprovision: false,
52
+ devmode: false,
53
+ lastip: '',
54
+ lastseen: 1_487_021_650_584_000,
55
+ status: 'provisioned',
56
+ online: false, },],
57
+ }
58
+ stub_request(
59
+ :get,
60
+ 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/'
61
+ ).to_return(body: body.to_json)
62
62
 
63
63
  ret = @gw.list
64
64
  expect(ret).to eq(body)
65
65
  end
66
66
 
67
- it "lists with limit" do
67
+ it 'lists with limit' do
68
68
  body = {
69
69
  mayLoadMore: false,
70
70
  devices:
71
- [{identity: "58",
72
- auth: {type: "cik"},
73
- state: {},
74
- locked: false,
75
- reprovision: false,
76
- devmode: false,
77
- lastip: "",
78
- lastseen: 1487021743864000,
79
- status: "provisioned",
80
- online: false},
81
- ]}
82
- stub_request(
83
- :get,
84
- "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/"
85
- ).with(query: {limit: '1'}
86
- ).to_return(body: body.to_json)
71
+ [{ identity: '58',
72
+ auth: { type: 'cik' },
73
+ state: {},
74
+ locked: false,
75
+ reprovision: false,
76
+ devmode: false,
77
+ lastip: '',
78
+ lastseen: 1_487_021_743_864_000,
79
+ status: 'provisioned',
80
+ online: false, },],
81
+ }
82
+ stub_request(
83
+ :get,
84
+ 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/'
85
+ ).with(query: { limit: '1' }).to_return(body: body.to_json)
87
86
 
88
87
  ret = @gw.list(1)
89
88
  expect(ret).to eq(body)
90
89
  end
91
90
 
92
- it "lists with before" do
91
+ it 'lists with before' do
93
92
  body = {
94
93
  mayLoadMore: false,
95
94
  devices:
96
- [{identity: "58",
97
- auth: {type: "cik"},
98
- state: {},
99
- locked: false,
100
- reprovision: false,
101
- devmode: false,
102
- lastip: "",
103
- lastseen: 1487021743864000,
104
- status: "provisioned",
105
- online: false},
106
- ]}
107
- stub_request(
108
- :get,
109
- "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/"
110
- ).with(query: { limit: '1', before: '1487021743864000' }
111
- ).to_return(body: body.to_json)
112
-
113
- ret = @gw.list(1, 1487021743864000)
95
+ [{ identity: '58',
96
+ auth: { type: 'cik' },
97
+ state: {},
98
+ locked: false,
99
+ reprovision: false,
100
+ devmode: false,
101
+ lastip: '',
102
+ lastseen: 1_487_021_743_864_000,
103
+ status: 'provisioned',
104
+ online: false, },],
105
+ }
106
+ stub_request(
107
+ :get,
108
+ 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/'
109
+ ).with(query: { limit: '1', before: '1487021743864000' }).to_return(body: body.to_json)
110
+
111
+ ret = @gw.list(1, 1_487_021_743_864_000)
114
112
  expect(ret).to eq(body)
115
113
  end
116
114
  end
117
115
 
118
- it "fetches one" do
116
+ it 'fetches one' do
119
117
  body = {
120
- identity: "58",
121
- auth: {type: "cik"},
118
+ identity: '58',
119
+ auth: { type: 'cik' },
122
120
  state: {},
123
121
  locked: false,
124
122
  reprovision: false,
125
123
  devmode: false,
126
- lastip: "",
127
- lastseen: 1487021743864000,
128
- status: "provisioned",
129
- online: false}
124
+ lastip: '',
125
+ lastseen: 1_487_021_743_864_000,
126
+ status: 'provisioned',
127
+ online: false,
128
+ }
130
129
  stub_request(
131
130
  :get,
132
- "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58"
131
+ 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58'
133
132
  ).to_return(body: body.to_json)
134
133
 
135
134
  ret = @gw.fetch(58)
136
135
  expect(ret).to eq(body)
137
136
  end
138
137
 
139
- it "enables one" do
138
+ it 'enables one' do
140
139
  body = {
141
- identity: "58",
142
- auth: {type: "cik"},
140
+ identity: '58',
141
+ auth: { type: 'cik' },
143
142
  state: {},
144
143
  locked: false,
145
144
  reprovision: false,
146
145
  devmode: false,
147
- lastip: "",
148
- lastseen: 1487021743864000,
149
- status: "provisioned",
150
- online: false}
146
+ lastip: '',
147
+ lastseen: 1_487_021_743_864_000,
148
+ status: 'provisioned',
149
+ online: false,
150
+ }
151
151
  stub_request(
152
152
  :put,
153
- "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58"
153
+ 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58'
154
154
  ).to_return(body: body.to_json)
155
155
 
156
156
  ret = @gw.enable(58)
157
157
  expect(ret).to eq(body)
158
158
  end
159
159
 
160
- it "enables with options" do
160
+ it 'enables with options' do
161
161
  body = {
162
- identity: "58",
163
- auth: {type: "cik"},
162
+ identity: '58',
163
+ auth: { type: 'cik' },
164
164
  state: {},
165
165
  locked: false,
166
166
  reprovision: false,
167
167
  devmode: false,
168
- lastip: "",
169
- lastseen: 1487021743864000,
170
- status: "provisioned",
171
- online: false}
168
+ lastip: '',
169
+ lastseen: 1_487_021_743_864_000,
170
+ status: 'provisioned',
171
+ online: false,
172
+ }
172
173
  stub_request(
173
174
  :put,
174
- "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58"
175
- ). with(body: { auth: { expire: 123456, type: :certificate }, locked: false }.to_json
176
- ).to_return(body: body.to_json)
175
+ 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58'
176
+ ). with(body: { auth: { expire: 123_456, type: :certificate }, locked: false }.to_json).to_return(body: body.to_json)
177
177
 
178
178
  ret = @gw.enable(58, type: :certificate, expire: '123456')
179
179
  expect(ret).to eq(body)
180
180
  end
181
181
 
182
- it "enables with extra options" do
182
+ it 'enables with extra options' do
183
183
  body = {
184
- identity: "58",
185
- auth: {type: "cik"},
184
+ identity: '58',
185
+ auth: { type: 'cik' },
186
186
  state: {},
187
187
  locked: false,
188
188
  reprovision: false,
189
189
  devmode: false,
190
- lastip: "",
191
- lastseen: 1487021743864000,
192
- status: "provisioned",
193
- online: false}
190
+ lastip: '',
191
+ lastseen: 1_487_021_743_864_000,
192
+ status: 'provisioned',
193
+ online: false,
194
+ }
194
195
  stub_request(
195
196
  :put,
196
- "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58"
197
- ).with(body: {auth: { expire: 123456, type: :certificate }, locked: false }.to_json
198
- ).to_return(body: body.to_json)
197
+ 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58'
198
+ ).with(body: { auth: { expire: 123_456, type: :certificate }, locked: false }.to_json).to_return(body: body.to_json)
199
199
 
200
- ret = @gw.enable(58, go: :blueteam, type: :certificate, expire: 123456, bob: :built)
200
+ ret = @gw.enable(58, go: :blueteam, type: :certificate, expire: 123_456, bob: :built)
201
201
  expect(ret).to eq(body)
202
202
  end
203
203
 
204
- it "removes one" do
204
+ it 'removes one' do
205
205
  body = {
206
- identity: "58",
207
- auth: {type: "cik"},
206
+ identity: '58',
207
+ auth: { type: 'cik' },
208
208
  state: {},
209
209
  locked: false,
210
210
  reprovision: false,
211
211
  devmode: false,
212
- lastip: "",
213
- lastseen: 1487021743864000,
214
- status: "provisioned",
215
- online: false}
212
+ lastip: '',
213
+ lastseen: 1_487_021_743_864_000,
214
+ status: 'provisioned',
215
+ online: false,
216
+ }
216
217
  stub_request(
217
218
  :delete,
218
- "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58"
219
+ 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/58'
219
220
  ).to_return(body: body.to_json)
220
221
 
221
222
  ret = @gw.remove(58)
222
223
  expect(ret).to eq(body)
223
224
  end
224
225
 
225
- context "activates" do
226
+ context 'activates' do
226
227
  before(:example) do
227
228
  @bgw = MrMurano::Gateway::GweBase.new
228
- allow(@bgw).to receive(:token).and_return("TTTTTTTTTT")
229
+ allow(@bgw).to receive(:token).and_return('TTTTTTTTTT')
229
230
  expect(MrMurano::Gateway::GweBase).to receive(:new).and_return(@bgw)
230
- allow(@gw).to receive(:token).and_return("TTTTTTTTTT")
231
+ allow(@gw).to receive(:token).and_return('TTTTTTTTTT')
231
232
  stub_request(
232
233
  :get,
233
- "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2"
234
- ).to_return(body: { fqdn: "xxxxx.m2.exosite-staging.io" }.to_json)
234
+ 'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2'
235
+ ).to_return(body: { fqdn: 'xxxxx.m2.exosite-staging.io' }.to_json)
235
236
  end
236
- it "succeeds" do
237
+ it 'succeeds' do
237
238
  stub_request(
238
239
  :post,
239
- "https://xxxxx.m2.exosite-staging.io/provision/activate"
240
+ 'https://xxxxx.m2.exosite-staging.io/provision/activate'
240
241
  ).to_return(body: 'XXXXXXXX')
241
242
 
242
243
  ret = @gw.activate(58)
243
244
  expect(ret).to eq('XXXXXXXX')
244
245
  end
245
246
 
246
- it "was already activated" do
247
+ it 'was already activated' do
247
248
  stub_request(
248
249
  :post,
249
- "https://xxxxx.m2.exosite-staging.io/provision/activate"
250
+ 'https://xxxxx.m2.exosite-staging.io/provision/activate'
250
251
  ).to_return(status: 409)
251
252
 
252
253
  saved = $stderr
@@ -254,16 +255,16 @@ RSpec.describe MrMurano::Gateway::Device do
254
255
 
255
256
  #@gw.activate(58)
256
257
  #expect($stderr.string).to eq("\e[31mRequest Failed: 409: nil\e[0m\n")
257
- expect {
258
+ expect do
258
259
  @gw.activate(58)
259
- }.to raise_error(SystemExit).and output("\e[31mThe specified device is already activated.\e[0m\n").to_stderr
260
+ end.to raise_error(SystemExit).and output("\e[31mThe specified device is already activated.\e[0m\n").to_stderr
260
261
  $stderr = saved
261
262
  end
262
263
 
263
264
  it "wasn't enabled" do
264
265
  stub_request(
265
266
  :post,
266
- "https://xxxxx.m2.exosite-staging.io/provision/activate"
267
+ 'https://xxxxx.m2.exosite-staging.io/provision/activate'
267
268
  ).to_return(status: 404)
268
269
 
269
270
  saved = $stderr
@@ -275,53 +276,53 @@ RSpec.describe MrMurano::Gateway::Device do
275
276
  end
276
277
  end
277
278
 
278
- context "enables batch" do
279
- it "enables from cvs" do
280
- File.open('ids.csv', 'w') {|io| io << "ID\n1\n2\n3\n4\n5"}
279
+ context 'enables batch' do
280
+ it 'enables from cvs' do
281
+ File.open('ids.csv', 'w') { |io| io << "ID\n1\n2\n3\n4\n5" }
281
282
  stub_request(
282
283
  :post,
283
284
  'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identities'
284
285
  ).with(headers: { 'Content-Type' => %r{^multipart/form-data.*} }) do |request|
285
- request.body.to_s =~ %r{Content-Type: text/csv\r\n\r\nID\r?\n1\r?\n2\r?\n3\r?\n4\r?\n5}
286
+ request.body.to_s =~ %r{Content-Type: text/csv\r\n\r\nID\r?\n1\r?\n2\r?\n3\r?\n4\r?\n5}
286
287
  end
287
288
  @gw.enable_batch('ids.csv')
288
289
  end
289
290
 
290
- it "but file is missing" do
291
- expect{@gw.enable_batch('ids.csv')}.to raise_error(Errno::ENOENT)
291
+ it 'but file is missing' do
292
+ expect { @gw.enable_batch('ids.csv') }.to raise_error(Errno::ENOENT)
292
293
  end
293
294
 
294
- it "but file is not text" do
295
- File.open('ids.csv', 'wb') {|io| io << "\0\0\0\0"}
295
+ it 'but file is not text' do
296
+ File.open('ids.csv', 'wb') { |io| io << "\0\0\0\0" }
296
297
  stub_request(
297
298
  :post,
298
299
  'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identities'
299
- ).to_return(status: 400, body: "CSV file format invalid")
300
+ ).to_return(status: 400, body: 'CSV file format invalid')
300
301
  saved = $stderr
301
302
  $stderr = StringIO.new
302
303
  @gw.enable_batch('ids.csv')
303
- expect($stderr.string).to eq(%{\e[31mRequest Failed: 400: CSV file format invalid\e[0m\n})
304
+ expect($stderr.string).to eq(%(\e[31mRequest Failed: 400: CSV file format invalid\e[0m\n))
304
305
  $stderr = saved
305
306
  end
306
307
 
307
- it "but file is missing header" do
308
- File.open('ids.csv', 'w') {|io| io << "1\n2\n3\n4\n5"}
308
+ it 'but file is missing header' do
309
+ File.open('ids.csv', 'w') { |io| io << "1\n2\n3\n4\n5" }
309
310
  stub_request(
310
311
  :post,
311
312
  'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identities'
312
313
  ).with(headers: { 'Content-Type' => %r{^multipart/form-data.*} }) do |request|
313
- request.body.to_s =~ %r{Content-Type: text/csv\r\n\r\n1\r?\n2\r?\n3\r?\n4\r?\n5}
314
- end.to_return(status: 400, body: "CSV file format invalid")
314
+ request.body.to_s =~ %r{Content-Type: text/csv\r\n\r\n1\r?\n2\r?\n3\r?\n4\r?\n5}
315
+ end.to_return(status: 400, body: 'CSV file format invalid')
315
316
  saved = $stderr
316
317
  $stderr = StringIO.new
317
318
  @gw.enable_batch('ids.csv')
318
- expect($stderr.string).to eq(%{\e[31mRequest Failed: 400: CSV file format invalid\e[0m\n})
319
+ expect($stderr.string).to eq(%(\e[31mRequest Failed: 400: CSV file format invalid\e[0m\n))
319
320
  $stderr = saved
320
321
  end
321
322
  end
322
323
 
323
- it "reads state" do
324
- body = {bob: {reported: "9", set: "9", timestamp: 1487021046160363}}
324
+ it 'reads state' do
325
+ body = { bob: { reported: '9', set: '9', timestamp: 1_487_021_046_160_363 } }
325
326
  stub_request(
326
327
  :get,
327
328
  'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/56/state'
@@ -331,9 +332,9 @@ RSpec.describe MrMurano::Gateway::Device do
331
332
  expect(ret).to eq(body)
332
333
  end
333
334
 
334
- context "writes state" do
335
- it "succeeds" do
336
- body = {bob: "fuzz"}
335
+ context 'writes state' do
336
+ it 'succeeds' do
337
+ body = { bob: 'fuzz' }
337
338
  stub_request(
338
339
  :patch,
339
340
  'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/56/state'
@@ -342,13 +343,12 @@ RSpec.describe MrMurano::Gateway::Device do
342
343
  @gw.write(56, bob: 'fuzz')
343
344
  end
344
345
 
345
- it "fails" do
346
- body = {bob: "fuzz"}
346
+ it 'fails' do
347
+ body = { bob: 'fuzz' }
347
348
  stub_request(
348
349
  :patch,
349
350
  'https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/identity/56/state'
350
- ).with(body: body.to_json
351
- ).to_return(status: 400, body: 'Value is not settable')
351
+ ).with(body: body.to_json).to_return(status: 400, body: 'Value is not settable')
352
352
 
353
353
  saved = $stderr
354
354
  $stderr = StringIO.new