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.12 /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 'tempfile'
2
9
  require 'MrMurano/version'
3
10
  require 'MrMurano/ProjectFile'
@@ -5,7 +12,7 @@ require 'MrMurano/Solution-Services'
5
12
  require '_workspace'
6
13
 
7
14
  RSpec.describe MrMurano::Module do
8
- include_context "WORKSPACE"
15
+ include_context 'WORKSPACE'
9
16
  before(:example) do
10
17
  $cfg = MrMurano::Config.new
11
18
  $cfg.load
@@ -15,127 +22,166 @@ RSpec.describe MrMurano::Module do
15
22
  $cfg['application.id'] = 'XYZ'
16
23
 
17
24
  @srv = MrMurano::Module.new
18
- allow(@srv).to receive(:token).and_return("TTTTTTTTTT")
25
+ allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
19
26
  end
20
27
 
21
- it "initializes" do
28
+ it 'initializes' do
22
29
  uri = @srv.endpoint('/')
23
- expect(uri.to_s).to eq("https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/")
30
+ expect(uri.to_s).to eq(
31
+ 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/'
32
+ )
24
33
  end
25
34
 
26
- it "lists" do
27
- body = {:items=>[{:id=>"9K0",
28
- :name=>"debug",
29
- :alias=>"XYZ_debug",
30
- :solution_id=>"XYZ",
31
- :created_at=>"2016-07-07T19:16:19.479Z",
32
- :updated_at=>"2016-09-12T13:26:55.868Z"}],
33
- :total=>1}
34
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module").
35
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
36
- 'Content-Type'=>'application/json'}).
37
- to_return(body: body.to_json)
35
+ it 'lists' do
36
+ body = {
37
+ items: [
38
+ {
39
+ id: '9K0',
40
+ name: 'debug',
41
+ alias: 'XYZ_debug',
42
+ solution_id: 'XYZ',
43
+ created_at: '2016-07-07T19:16:19.479Z',
44
+ updated_at: '2016-09-12T13:26:55.868Z',
45
+ },
46
+ ],
47
+ total: 1,
48
+ }
49
+ stub_request(
50
+ :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module'
51
+ ).with(
52
+ headers: {
53
+ 'Authorization' => 'token TTTTTTTTTT',
54
+ 'Content-Type' => 'application/json',
55
+ }
56
+ ).to_return(body: body.to_json)
38
57
 
39
58
  ret = @srv.list
40
59
  expect(ret).to eq(body[:items])
41
60
  end
42
61
 
43
- context "fetching" do
44
- it "fetches" do
45
- body = {:id=>"9K0",
46
- :name=>"debug",
47
- :alias=>"XYZ_debug",
48
- :solution_id=>"XYZ",
49
- :created_at=>"2016-07-07T19:16:19.479Z",
50
- :updated_at=>"2016-09-12T13:26:55.868Z",
51
- :script=>%{-- lua code is here
62
+ context 'fetching' do
63
+ it 'fetches' do
64
+ body = {
65
+ id: '9K0',
66
+ name: 'debug',
67
+ alias: 'XYZ_debug',
68
+ solution_id: 'XYZ',
69
+ created_at: '2016-07-07T19:16:19.479Z',
70
+ updated_at: '2016-09-12T13:26:55.868Z',
71
+ script: %{-- lua code is here
52
72
  function foo(bar)
53
73
  return bar + 1
54
74
  end
75
+ },
55
76
  }
56
- }
57
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0").
58
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
59
- 'Content-Type'=>'application/json'}).
60
- to_return(body: body.to_json)
77
+ stub_request(
78
+ :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
79
+ ).with(
80
+ headers: {
81
+ 'Authorization' => 'token TTTTTTTTTT',
82
+ 'Content-Type' => 'application/json',
83
+ }
84
+ ).to_return(body: body.to_json)
61
85
 
62
86
  ret = @srv.fetch('9K0')
63
87
  expect(ret).to eq(body[:script])
64
88
  end
65
89
 
66
- it "fetches with block" do
67
- body = {:id=>"9K0",
68
- :name=>"debug",
69
- :alias=>"XYZ_debug",
70
- :solution_id=>"XYZ",
71
- :created_at=>"2016-07-07T19:16:19.479Z",
72
- :updated_at=>"2016-09-12T13:26:55.868Z",
73
- :script=>%{-- lua code is here
90
+ it 'fetches with block' do
91
+ body = {
92
+ id: '9K0',
93
+ name: 'debug',
94
+ alias: 'XYZ_debug',
95
+ solution_id: 'XYZ',
96
+ created_at: '2016-07-07T19:16:19.479Z',
97
+ updated_at: '2016-09-12T13:26:55.868Z',
98
+ script: %{-- lua code is here
74
99
  function foo(bar)
75
100
  return bar + 1
76
101
  end
102
+ },
77
103
  }
78
- }
79
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0").
80
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
81
- 'Content-Type'=>'application/json'}).
82
- to_return(body: body.to_json)
104
+ stub_request(
105
+ :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
106
+ ).with(
107
+ headers: {
108
+ 'Authorization' => 'token TTTTTTTTTT',
109
+ 'Content-Type' => 'application/json',
110
+ }
111
+ ).to_return(body: body.to_json)
83
112
 
84
113
  ret = nil
85
- @srv.fetch('9K0') {|sc| ret = sc}
114
+ @srv.fetch('9K0') { |sc| ret = sc }
86
115
  expect(ret).to eq(body[:script])
87
116
  end
88
117
 
89
- it "Returns empty if script missing" do
90
- body = {:id=>"9K0",
91
- :name=>"debug",
92
- :alias=>"XYZ_debug",
93
- :solution_id=>"XYZ",
94
- :created_at=>"2016-07-07T19:16:19.479Z",
95
- :updated_at=>"2016-09-12T13:26:55.868Z",
118
+ it 'Returns empty if script missing' do
119
+ body = {
120
+ id: '9K0',
121
+ name: 'debug',
122
+ alias: 'XYZ_debug',
123
+ solution_id: 'XYZ',
124
+ created_at: '2016-07-07T19:16:19.479Z',
125
+ updated_at: '2016-09-12T13:26:55.868Z',
96
126
  }
97
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0").
98
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
99
- 'Content-Type'=>'application/json'}).
100
- to_return(body: body.to_json)
127
+ stub_request(
128
+ :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
129
+ ).with(
130
+ headers: {
131
+ 'Authorization' => 'token TTTTTTTTTT',
132
+ 'Content-Type' => 'application/json',
133
+ }
134
+ ).to_return(body: body.to_json)
101
135
 
102
136
  ret = @srv.fetch('9K0')
103
137
  expect(ret).to eq('')
104
138
  end
105
139
 
106
- it "Displays error if wrong result type" do
107
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0").
108
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
109
- 'Content-Type'=>'application/json'}).
110
- to_return(body: "this isn't what we expected")
140
+ it 'Displays error if wrong result type' do
141
+ stub_request(
142
+ :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
143
+ ).with(
144
+ headers: {
145
+ 'Authorization' => 'token TTTTTTTTTT',
146
+ 'Content-Type' => 'application/json',
147
+ }
148
+ ).to_return(body: "this isn't what we expected")
111
149
 
112
150
  saved = $stderr
113
151
  $stderr = StringIO.new
114
152
  ret = @srv.fetch('9K0')
115
153
  expect(ret).to eq('')
116
154
  expect($stderr.string).to start_with(
117
- %{\e[31m#{MrMurano::SolutionId::UNEXPECTED_TYPE_OR_ERROR_MSG}}
155
+ %(\e[31m#{MrMurano::SolutionId::UNEXPECTED_TYPE_OR_ERROR_MSG})
118
156
  )
119
157
  $stderr = saved
120
158
  end
121
159
  end
122
160
 
123
- it "removes" do
124
- stub_request(:delete, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0").
125
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
126
- 'Content-Type'=>'application/json'}).
127
- to_return(body: "")
161
+ it 'removes' do
162
+ stub_request(
163
+ :delete, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
164
+ ).with(
165
+ headers: {
166
+ 'Authorization' => 'token TTTTTTTTTT',
167
+ 'Content-Type' => 'application/json',
168
+ }
169
+ ).to_return(body: '')
128
170
 
129
171
  ret = @srv.remove('9K0')
130
172
  expect(ret).to eq({})
131
173
  end
132
174
 
133
- context "uploads" do
134
- it "over old version" do
135
- stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug").
136
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
137
- 'Content-Type'=>'application/json'}).
138
- to_return(body: "")
175
+ context 'uploads' do
176
+ it 'over old version' do
177
+ stub_request(
178
+ :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
179
+ ).with(
180
+ headers: {
181
+ 'Authorization' => 'token TTTTTTTTTT',
182
+ 'Content-Type' => 'application/json',
183
+ }
184
+ ).to_return(body: '')
139
185
 
140
186
  Tempfile.open('foo') do |tio|
141
187
  tio << %{-- lua code is here
@@ -145,26 +191,36 @@ RSpec.describe MrMurano::Module do
145
191
  }
146
192
  tio.close
147
193
 
148
- ret = @srv.upload(tio.path,
194
+ ret = @srv.upload(
195
+ tio.path,
149
196
  MrMurano::Module::ModuleItem.new(
150
- :id=>"9K0",
151
- :name=>"debug",
152
- :alias=>"XYZ_debug",
153
- :solution_id=>"XYZ",
154
- ))
197
+ id: '9K0',
198
+ name: 'debug',
199
+ alias: 'XYZ_debug',
200
+ solution_id: 'XYZ',
201
+ )
202
+ )
155
203
  expect(ret)
156
204
  end
157
205
  end
158
206
 
159
- it "when nothing is there" do
160
- stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug").
161
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
162
- 'Content-Type'=>'application/json'}).
163
- to_return(status: 404)
164
- stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/").
165
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
166
- 'Content-Type'=>'application/json'}).
167
- to_return(body: "")
207
+ it 'when nothing is there' do
208
+ stub_request(
209
+ :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
210
+ ).with(
211
+ headers: {
212
+ 'Authorization' => 'token TTTTTTTTTT',
213
+ 'Content-Type' => 'application/json',
214
+ }
215
+ ).to_return(status: 404)
216
+ stub_request(
217
+ :post, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/'
218
+ ).with(
219
+ headers: {
220
+ 'Authorization' => 'token TTTTTTTTTT',
221
+ 'Content-Type' => 'application/json',
222
+ }
223
+ ).to_return(body: '')
168
224
 
169
225
  Tempfile.open('foo') do |tio|
170
226
  tio << %{-- lua code is here
@@ -177,20 +233,25 @@ RSpec.describe MrMurano::Module do
177
233
  ret = @srv.upload(
178
234
  tio.path,
179
235
  MrMurano::Module::ModuleItem.new(
180
- :id=>"9K0",
181
- :name=>"debug",
182
- :alias=>"XYZ_debug",
183
- :solution_id=>"XYZ",
184
- ))
236
+ id: '9K0',
237
+ name: 'debug',
238
+ alias: 'XYZ_debug',
239
+ solution_id: 'XYZ',
240
+ )
241
+ )
185
242
  expect(ret)
186
243
  end
187
244
  end
188
245
 
189
- it "shows other errors" do
190
- stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug").
191
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
192
- 'Content-Type'=>'application/json'}).
193
- to_return(status: 418, body: %{{"teapot":true}})
246
+ it 'shows other errors' do
247
+ stub_request(
248
+ :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
249
+ ).with(
250
+ headers: {
251
+ 'Authorization' => 'token TTTTTTTTTT',
252
+ 'Content-Type' => 'application/json',
253
+ }
254
+ ).to_return(status: 418, body: %({"teapot":true}))
194
255
 
195
256
  Tempfile.open('foo') do |tio|
196
257
  tio << %{-- lua code is here
@@ -201,22 +262,28 @@ RSpec.describe MrMurano::Module do
201
262
  tio.close
202
263
 
203
264
  expect(@srv).to receive(:error).and_return(nil)
204
- ret = @srv.upload(tio.path,
265
+ ret = @srv.upload(
266
+ tio.path,
205
267
  MrMurano::Module::ModuleItem.new(
206
- :id=>"9K0",
207
- :name=>"debug",
208
- :alias=>"XYZ_debug",
209
- :solution_id=>"XYZ",
210
- ))
268
+ id: '9K0',
269
+ name: 'debug',
270
+ alias: 'XYZ_debug',
271
+ solution_id: 'XYZ',
272
+ )
273
+ )
211
274
  expect(ret)
212
275
  end
213
276
  end
214
277
 
215
- it "over old version; replacing cache miss" do
216
- stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug").
217
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
218
- 'Content-Type'=>'application/json'}).
219
- to_return(body: "")
278
+ it 'over old version; replacing cache miss' do
279
+ stub_request(
280
+ :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
281
+ ).with(
282
+ headers: {
283
+ 'Authorization' => 'token TTTTTTTTTT',
284
+ 'Content-Type' => 'application/json',
285
+ }
286
+ ).to_return(body: '')
220
287
 
221
288
  Tempfile.open('foo') do |tio|
222
289
  tio << %{-- lua code is here
@@ -226,24 +293,30 @@ RSpec.describe MrMurano::Module do
226
293
  }
227
294
  tio.close
228
295
 
229
- cacheFile = $cfg.file_at(@srv.cache_file_name)
230
- FileUtils.touch(cacheFile.to_path)
231
- ret = @srv.upload(tio.path,
296
+ cache_file = $cfg.file_at(@srv.cache_file_name)
297
+ FileUtils.touch(cache_file.to_path)
298
+ ret = @srv.upload(
299
+ tio.path,
232
300
  MrMurano::Module::ModuleItem.new(
233
- :id=>"9K0",
234
- :name=>"debug",
235
- :alias=>"XYZ_debug",
236
- :solution_id=>"XYZ",
237
- ))
301
+ id: '9K0',
302
+ name: 'debug',
303
+ alias: 'XYZ_debug',
304
+ solution_id: 'XYZ',
305
+ )
306
+ )
238
307
  expect(ret)
239
308
  end
240
309
  end
241
310
 
242
- it "over old version; replacing cache hit" do
243
- stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug").
244
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
245
- 'Content-Type'=>'application/json'}).
246
- to_return(body: "")
311
+ it 'over old version; replacing cache hit' do
312
+ stub_request(
313
+ :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
314
+ ).with(
315
+ headers: {
316
+ 'Authorization' => 'token TTTTTTTTTT',
317
+ 'Content-Type' => 'application/json',
318
+ }
319
+ ).to_return(body: '')
247
320
 
248
321
  Tempfile.open('foo') do |tio|
249
322
  tio << %{-- lua code is here
@@ -253,217 +326,226 @@ RSpec.describe MrMurano::Module do
253
326
  }
254
327
  tio.close
255
328
 
256
- cacheFile = $cfg.file_at(@srv.cache_file_name)
257
- cacheFile.open('w') do |cfio|
258
- cfio << {tio.path=>{:sha1=>"6",
259
- :updated_at=>Time.now.getutc.to_datetime.iso8601(3)}
329
+ cache_file = $cfg.file_at(@srv.cache_file_name)
330
+ cache_file.open('w') do |cfio|
331
+ cfio << {
332
+ tio.path => {
333
+ sha1: '6',
334
+ updated_at: Time.now.getutc.to_datetime.iso8601(3),
335
+ },
260
336
  }.to_yaml
261
337
  end
262
- ret = @srv.upload(tio.path,
338
+ ret = @srv.upload(
339
+ tio.path,
263
340
  MrMurano::Module::ModuleItem.new(
264
- :id=>"9K0",
265
- :name=>"debug",
266
- :alias=>"XYZ_debug",
267
- :solution_id=>"XYZ",
268
- ))
341
+ id: '9K0',
342
+ name: 'debug',
343
+ alias: 'XYZ_debug',
344
+ solution_id: 'XYZ',
345
+ )
346
+ )
269
347
  expect(ret)
270
348
  end
271
349
  end
272
350
  end
273
351
 
274
- context "compares" do
352
+ context 'compares' do
275
353
  before(:example) do
276
- @iA = {:id=>"9K0",
277
- :name=>"debug",
278
- :alias=>"XYZ_debug",
279
- :solution_id=>"XYZ",
280
- :created_at=>"2016-07-07T19:16:19.479Z",
281
- :updated_at=>"2016-09-12T13:26:55.868Z"}
282
- @iB = {:id=>"9K0",
283
- :name=>"debug",
284
- :alias=>"XYZ_debug",
285
- :solution_id=>"XYZ",
286
- :created_at=>"2016-07-07T19:16:19.479Z",
287
- :updated_at=>"2016-09-12T13:26:55.868Z"}
354
+ @i_a = {
355
+ id: '9K0',
356
+ name: 'debug',
357
+ alias: 'XYZ_debug',
358
+ solution_id: 'XYZ',
359
+ created_at: '2016-07-07T19:16:19.479Z',
360
+ updated_at: '2016-09-12T13:26:55.868Z',
361
+ }
362
+ @i_b = {
363
+ id: '9K0',
364
+ name: 'debug',
365
+ alias: 'XYZ_debug',
366
+ solution_id: 'XYZ',
367
+ created_at: '2016-07-07T19:16:19.479Z',
368
+ updated_at: '2016-09-12T13:26:55.868Z',
369
+ }
288
370
  end
289
- it "both have updated_at" do
290
- ret = @srv.docmp(@iA, @iB)
371
+ it 'both have updated_at' do
372
+ ret = @srv.docmp(@i_a, @i_b)
291
373
  expect(ret).to eq(false)
292
374
  end
293
375
 
294
- context "iA is a local file" do
295
- it "no cacheFile" do
376
+ context 'i_a is a local file' do
377
+ it 'no cache_file' do
296
378
  Tempfile.open('foo') do |tio|
297
- tio << "something"
379
+ tio << 'something'
298
380
  tio.close
299
- iA = @iA.reject{|k,v| k == :updated_at}.merge({
300
- :local_path => Pathname.new(tio.path)
301
- })
302
- ret = @srv.docmp(iA, @iB)
381
+ i_a = @i_a.reject do |k, _v|
382
+ k == :updated_at
383
+ end.merge(local_path: Pathname.new(tio.path))
384
+ ret = @srv.docmp(i_a, @i_b)
303
385
  expect(ret).to eq(true)
304
386
 
305
- iB = @iB.merge({:updated_at=>Pathname.new(tio.path).mtime.getutc})
306
- ret = @srv.docmp(iA, iB)
387
+ i_b = @i_b.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
388
+ ret = @srv.docmp(i_a, i_b)
307
389
  expect(ret).to eq(false)
308
390
  end
309
391
  end
310
392
 
311
- it "cache miss" do
312
- cacheFile = $cfg.file_at(@srv.cache_file_name)
313
- FileUtils.touch(cacheFile.to_path)
393
+ it 'cache miss' do
394
+ cache_file = $cfg.file_at(@srv.cache_file_name)
395
+ FileUtils.touch(cache_file.to_path)
314
396
  Tempfile.open('foo') do |tio|
315
- tio << "something"
397
+ tio << 'something'
316
398
  tio.close
317
- iA = @iA.reject{|k,v| k == :updated_at}.merge({
318
- :local_path => Pathname.new(tio.path)
319
- })
320
- ret = @srv.docmp(iA, @iB)
399
+ i_a = @i_a.reject do |k, _v|
400
+ k == :updated_at
401
+ end.merge(local_path: Pathname.new(tio.path))
402
+ ret = @srv.docmp(i_a, @i_b)
321
403
  expect(ret).to eq(true)
322
404
 
323
- iB = @iB.merge({:updated_at=>Pathname.new(tio.path).mtime.getutc})
324
- ret = @srv.docmp(iA, iB)
405
+ i_b = @i_b.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
406
+ ret = @srv.docmp(i_a, i_b)
325
407
  expect(ret).to eq(false)
326
408
  end
327
409
  end
328
410
 
329
- it "cache hit" do
330
- cacheFile = $cfg.file_at(@srv.cache_file_name)
411
+ it 'cache hit' do
412
+ cache_file = $cfg.file_at(@srv.cache_file_name)
331
413
  Tempfile.open('foo') do |tio|
332
- tio << "something"
414
+ tio << 'something'
333
415
  tio.close
334
416
  tio_mtime = Pathname.new(tio.path).mtime.getutc
335
417
  entry = {
336
- :sha1=>Digest::SHA1.file(tio.path).hexdigest,
337
- :updated_at=>tio_mtime.to_datetime.iso8601(3)
418
+ sha1: Digest::SHA1.file(tio.path).hexdigest,
419
+ updated_at: tio_mtime.to_datetime.iso8601(3),
338
420
  }
339
- cacheFile.open('w') do |io|
421
+ cache_file.open('w') do |io|
340
422
  cache = {}
341
423
  cache[tio.path] = entry
342
424
  io << cache.to_yaml
343
425
  end
344
426
 
345
- iA = @iA.reject{|k,v| k == :updated_at}.merge({
346
- :local_path => Pathname.new(tio.path)
347
- })
348
- ret = @srv.docmp(iA, @iB)
427
+ i_a = @i_a.reject do |k, _v|
428
+ k == :updated_at
429
+ end.merge(local_path: Pathname.new(tio.path))
430
+ ret = @srv.docmp(i_a, @i_b)
349
431
  expect(ret).to eq(true)
350
432
 
351
- iB = @iB.merge({:updated_at=>tio_mtime})
352
- ret = @srv.docmp(iA, iB)
433
+ i_b = @i_b.merge(updated_at: tio_mtime)
434
+ ret = @srv.docmp(i_a, i_b)
353
435
  expect(ret).to eq(false)
354
436
  end
355
437
  end
356
438
  end
357
439
 
358
- context "iB is a local file" do
359
- it "no cacheFile" do
440
+ context 'i_b is a local file' do
441
+ it 'no cache_file' do
360
442
  Tempfile.open('foo') do |tio|
361
- tio << "something"
443
+ tio << 'something'
362
444
  tio.close
363
- iB = @iB.reject{|k,v| k == :updated_at}.merge({
364
- :local_path => Pathname.new(tio.path)
365
- })
366
- ret = @srv.docmp(@iA, iB)
445
+ i_b = @i_b.reject do |k, _v|
446
+ k == :updated_at
447
+ end.merge(local_path: Pathname.new(tio.path))
448
+ ret = @srv.docmp(@i_a, i_b)
367
449
  expect(ret).to eq(true)
368
450
 
369
- iA = @iA.merge({:updated_at=>Pathname.new(tio.path).mtime.getutc})
370
- ret = @srv.docmp(iA, iB)
451
+ i_a = @i_a.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
452
+ ret = @srv.docmp(i_a, i_b)
371
453
  expect(ret).to eq(false)
372
454
  end
373
455
  end
374
456
 
375
- it "cache miss" do
376
- cacheFile = $cfg.file_at(@srv.cache_file_name)
377
- FileUtils.touch(cacheFile.to_path)
457
+ it 'cache miss' do
458
+ cache_file = $cfg.file_at(@srv.cache_file_name)
459
+ FileUtils.touch(cache_file.to_path)
378
460
  Tempfile.open('foo') do |tio|
379
- tio << "something"
461
+ tio << 'something'
380
462
  tio.close
381
- iB = @iB.reject{|k,v| k == :updated_at}.merge({
382
- :local_path => Pathname.new(tio.path)
383
- })
384
- ret = @srv.docmp(@iA, iB)
463
+ i_b = @i_b.reject do |k, _v|
464
+ k == :updated_at
465
+ end.merge(local_path: Pathname.new(tio.path))
466
+ ret = @srv.docmp(@i_a, i_b)
385
467
  expect(ret).to eq(true)
386
468
 
387
- iA = @iA.merge({:updated_at=>Pathname.new(tio.path).mtime.getutc})
388
- ret = @srv.docmp(iA, iB)
469
+ i_a = @i_a.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
470
+ ret = @srv.docmp(i_a, i_b)
389
471
  expect(ret).to eq(false)
390
472
  end
391
473
  end
392
474
 
393
- it "cache hit" do
394
- cacheFile = $cfg.file_at(@srv.cache_file_name)
475
+ it 'cache hit' do
476
+ cache_file = $cfg.file_at(@srv.cache_file_name)
395
477
  Tempfile.open('foo') do |tio|
396
- tio << "something"
478
+ tio << 'something'
397
479
  tio.close
398
480
  tio_mtime = Pathname.new(tio.path).mtime.getutc
399
481
  entry = {
400
- :sha1=>Digest::SHA1.file(tio.path).hexdigest,
401
- :updated_at=>tio_mtime.to_datetime.iso8601(3)
482
+ sha1: Digest::SHA1.file(tio.path).hexdigest,
483
+ updated_at: tio_mtime.to_datetime.iso8601(3),
402
484
  }
403
- cacheFile.open('w') do |io|
485
+ cache_file.open('w') do |io|
404
486
  cache = {}
405
487
  cache[tio.path] = entry
406
488
  io << cache.to_yaml
407
489
  end
408
490
 
409
- iB = @iB.reject{|k,v| k == :updated_at}.merge({
410
- :local_path => Pathname.new(tio.path)
411
- })
412
- ret = @srv.docmp(@iA, iB)
491
+ i_b = @i_b.reject do |k, _v|
492
+ k == :updated_at
493
+ end.merge(local_path: Pathname.new(tio.path))
494
+ ret = @srv.docmp(@i_a, i_b)
413
495
  expect(ret).to eq(true)
414
496
 
415
- iA = @iA.merge({:updated_at=>tio_mtime})
416
- ret = @srv.docmp(iA, iB)
497
+ i_a = @i_a.merge(updated_at: tio_mtime)
498
+ ret = @srv.docmp(i_a, i_b)
417
499
  expect(ret).to eq(false)
418
500
  end
419
501
  end
420
502
  end
421
503
  end
422
504
 
423
- context "Lookup functions" do
424
- it "gets local name" do
425
- ret = @srv.tolocalname({ :name=>"bob" }, nil)
505
+ context 'Lookup functions' do
506
+ it 'gets local name' do
507
+ ret = @srv.tolocalname({ name: 'bob' }, nil)
426
508
  expect(ret).to eq('bob.lua')
427
509
  end
428
510
 
429
- it "gets synckey" do
430
- ret = @srv.synckey({ :name=>'device' })
431
- expect(ret).to eq("device")
511
+ it 'gets synckey' do
512
+ ret = @srv.synckey(name: 'device')
513
+ expect(ret).to eq('device')
432
514
  end
433
515
 
434
- it "gets searchfor" do
435
- $cfg['modules.searchFor'] = %{a b c/**/d/*.bob}
516
+ it 'gets searchfor' do
517
+ $cfg['modules.searchFor'] = %(a b c/**/d/*.bob)
436
518
  ret = @srv.searchFor
437
- expect(ret).to eq(["a", "b", "c/**/d/*.bob"])
519
+ expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
438
520
  end
439
521
 
440
- it "gets ignoring" do
441
- $cfg['modules.ignoring'] = %{a b c/**/d/*.bob}
522
+ it 'gets ignoring' do
523
+ $cfg['modules.ignoring'] = %(a b c/**/d/*.bob)
442
524
  ret = @srv.ignoring
443
- expect(ret).to eq(["a", "b", "c/**/d/*.bob"])
525
+ expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
444
526
  end
445
527
 
446
- it "raises on alias without name" do
447
- expect {
448
- @srv.mkname(MrMurano::Module::EventHandlerItem.new())
449
- }.to raise_error(NameError)
528
+ it 'raises on alias without name' do
529
+ expect do
530
+ @srv.mkname(MrMurano::Module::EventHandlerItem.new)
531
+ end.to raise_error(NameError)
450
532
  end
451
533
 
452
- it "raises on name without name" do
453
- expect {
454
- @srv.mkalias(MrMurano::Module::EventHandlerItem.new())
455
- }.to raise_error(NameError)
534
+ it 'raises on name without name' do
535
+ expect do
536
+ @srv.mkalias(MrMurano::Module::EventHandlerItem.new)
537
+ end.to raise_error(NameError)
456
538
  end
457
539
  end
458
540
 
459
- context "to_remote_item" do
460
- it "reads one" do
541
+ context 'to_remote_item' do
542
+ it 'reads one' do
461
543
  root = Pathname.new(@project_dir)
462
544
  path = Pathname.new(@project_dir) + 'test.lua'
463
545
  ret = @srv.to_remote_item(root, path)
464
546
  expect(ret).to eq(name: 'test')
465
547
  end
466
- it "reads sub folder one" do
548
+ it 'reads sub folder one' do
467
549
  root = Pathname.new(@project_dir)
468
550
  path = Pathname.new(@project_dir) + 'src/test.lua'
469
551
  ret = @srv.to_remote_item(root, path)
@@ -471,4 +553,4 @@ RSpec.describe MrMurano::Module do
471
553
  end
472
554
  end
473
555
  end
474
- # vim: set ai et sw=2 ts=2 :
556
+