MuranoCLI 3.0.2 → 3.0.4

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.
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,4 +1,4 @@
1
- # Last Modified: 2017.08.17 /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.
@@ -13,7 +13,7 @@ require 'MrMurano/SyncUpDown'
13
13
  require '_workspace'
14
14
 
15
15
  RSpec.describe MrMurano::SyncRoot do
16
- include_context "WORKSPACE"
16
+ include_context 'WORKSPACE'
17
17
 
18
18
  after(:example) do
19
19
  MrMurano::SyncRoot.instance.reset
@@ -27,7 +27,7 @@ RSpec.describe MrMurano::SyncRoot do
27
27
  # warning: method redefined; discarding old description
28
28
  # /exo/clients/exosite/MuranoCLIs/MuranoCLI+landonb/spec/SyncRoot_spec.rb:30:
29
29
  # warning: previous definition of description was here
30
- if !defined?(User)
30
+ unless defined?(User)
31
31
  class User
32
32
  def self.description
33
33
  %(describe user)
@@ -35,7 +35,7 @@ RSpec.describe MrMurano::SyncRoot do
35
35
  end
36
36
  end
37
37
  MrMurano::SyncRoot.instance.add('user', User, 'U', true)
38
- if !defined?(Role)
38
+ unless defined?(Role)
39
39
  class Role
40
40
  def self.description
41
41
  %(describe role)
@@ -52,58 +52,60 @@ RSpec.describe MrMurano::SyncRoot do
52
52
 
53
53
  @options = {}
54
54
  @options.define_singleton_method(:method_missing) do |mid, *args|
55
- if mid.to_s.match(/^(.+)=$/) then
56
- self[$1.to_sym] = args.first
55
+ if mid.to_s =~ /^(.+)=$/
56
+ self[Regexp.last_match(1).to_sym] = args.first
57
57
  else
58
58
  self[mid]
59
59
  end
60
60
  end
61
61
  end
62
62
 
63
- it "has defaults" do
63
+ it 'has defaults' do
64
64
  ret = MrMurano::SyncRoot.instance.bydefault
65
65
  expect(ret).to eq(['user'])
66
66
  end
67
67
 
68
- it "iterates on each" do
69
- ret=[]
68
+ it 'iterates on each' do
69
+ ret = []
70
70
  MrMurano::SyncRoot.instance.each { |a, _b, _c, _d| ret << a }
71
- expect(ret).to eq(["user", "role"])
71
+ expect(ret).to eq(%w[user role])
72
72
  end
73
73
 
74
- it "iterates only on selected" do
74
+ it 'iterates only on selected' do
75
75
  @options.role = true
76
- ret=[]
76
+ ret = []
77
77
  MrMurano::SyncRoot.instance.each_filtered(@options) { |a, _b, _c, _d| ret << a }
78
- expect(ret).to eq(["role"])
78
+ expect(ret).to eq(['role'])
79
79
  end
80
80
 
81
- it "selects all" do
81
+ it 'selects all' do
82
82
  @options.all = true
83
83
  MrMurano::SyncRoot.instance.check_same(@options)
84
- expect(@options).to eq({:all=>true, :user=>true, :role=>true})
84
+ expect(@options).to eq(all: true, user: true, role: true)
85
85
  end
86
86
 
87
- it "selects defaults when none" do
87
+ it 'selects defaults when none' do
88
88
  MrMurano::SyncRoot.instance.check_same(@options)
89
- expect(@options).to eq({:user=>true})
89
+ expect(@options).to eq(user: true)
90
90
  end
91
91
 
92
- it "selects custom defaults when none" do
92
+ it 'selects custom defaults when none' do
93
93
  $cfg['sync.bydefault'] = 'role'
94
94
  MrMurano::SyncRoot.instance.check_same(@options)
95
- expect(@options).to eq({role: true})
95
+ expect(@options).to eq(role: true)
96
96
  end
97
97
 
98
- it "builds option params" do
98
+ it 'builds option params' do
99
99
  ret = []
100
100
  MrMurano::SyncRoot.instance.each_option do |s, l, d|
101
101
  ret << [s, l, d]
102
102
  end
103
- expect(ret).to eq([
104
- ["-U", "--[no-]user", "describe user"],
105
- ["-G", "--[no-]role", "describe role"],
106
- ])
103
+ expect(ret).to eq(
104
+ [
105
+ ['-U', '--[no-]user', 'describe user'],
106
+ ['-G', '--[no-]role', 'describe role'],
107
+ ]
108
+ )
107
109
  end
108
110
  end
109
111
 
@@ -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 'MrMurano/verbosing'
2
9
  require 'MrMurano/version'
3
10
  require 'MrMurano/Config'
@@ -20,9 +27,7 @@ class TSUD
20
27
  @project_section = :routes
21
28
  end
22
29
 
23
- def api_id
24
- @api_id
25
- end
30
+ attr_reader :api_id
26
31
 
27
32
  def api_id?
28
33
  @valid_api_id
@@ -42,10 +47,10 @@ RSpec::Matchers.define :pathname_globs do |glob|
42
47
  end
43
48
  end
44
49
 
45
- ITEM_UPDATED_AT="2017-06-24T00:45:15.564Z"
50
+ ITEM_UPDATED_AT = '2017-06-24T00:45:15.564Z'
46
51
 
47
52
  RSpec.describe MrMurano::SyncUpDown do
48
- include_context "WORKSPACE"
53
+ include_context 'WORKSPACE'
49
54
  before(:example) do
50
55
  MrMurano::SyncRoot.instance.reset
51
56
  $cfg = MrMurano::Config.new
@@ -59,35 +64,37 @@ RSpec.describe MrMurano::SyncUpDown do
59
64
  $cfg['application.id'] = 'XYZ'
60
65
  end
61
66
 
62
- context "status" do
63
- it "warns with missing directory" do
67
+ context 'status' do
68
+ it 'warns with missing directory' do
64
69
  t = TSUD.new
65
70
  expect(t).to receive(:warning).once.with(/Skipping missing location.*/)
66
71
  ret = t.status
67
72
  expect(ret).to eq(
68
- { toadd: [], todel: [], tomod: [], unchg: [], skipd: [], clash: [] }
73
+ toadd: [], todel: [], tomod: [], unchg: [], skipd: [], clash: []
69
74
  )
70
75
  end
71
76
 
72
- it "finds nothing in empty directory" do
77
+ it 'finds nothing in empty directory' do
73
78
  FileUtils.mkpath(@project_dir + '/tsud')
74
79
  t = TSUD.new
75
80
  ret = t.status
76
81
  expect(ret).to eq(
77
- { toadd: [], todel: [], tomod: [], unchg: [], skipd: [], clash: [] }
82
+ toadd: [], todel: [], tomod: [], unchg: [], skipd: [], clash: []
78
83
  )
79
84
  end
80
85
 
81
- it "finds things there but not here" do
86
+ it 'finds things there but not here' do
82
87
  FileUtils.mkpath(@project_dir + '/tsud')
83
88
  t = TSUD.new
84
- expect(t).to receive(:list).once.and_return([
85
- {name: 1},
86
- {name: 2},
87
- {name: 3},
88
- ])
89
+ expect(t).to receive(:list).once.and_return(
90
+ [
91
+ { name: 1 },
92
+ { name: 2 },
93
+ { name: 3 },
94
+ ]
95
+ )
89
96
  ret = t.status
90
- expect(ret).to eq({
97
+ expect(ret).to eq(
91
98
  toadd: [],
92
99
  todel: [
93
100
  {
@@ -104,24 +111,27 @@ RSpec.describe MrMurano::SyncUpDown do
104
111
  name: 3,
105
112
  synckey: 3,
106
113
  synctype: TSUD.description,
107
- }],
114
+ },
115
+ ],
108
116
  tomod: [],
109
117
  unchg: [],
110
118
  skipd: [],
111
- clash: [],
112
- })
119
+ clash: []
120
+ )
113
121
  end
114
122
 
115
- it "finds things there but not here; asdown" do
123
+ it 'finds things there but not here; asdown' do
116
124
  FileUtils.mkpath(@project_dir + '/tsud')
117
125
  t = TSUD.new
118
- expect(t).to receive(:list).once.and_return([
119
- {name: 1},
120
- {name: 2},
121
- {name: 3},
122
- ])
123
- ret = t.status({asdown: true})
124
- expect(ret).to eq({
126
+ expect(t).to receive(:list).once.and_return(
127
+ [
128
+ { name: 1 },
129
+ { name: 2 },
130
+ { name: 3 },
131
+ ]
132
+ )
133
+ ret = t.status(asdown: true)
134
+ expect(ret).to eq(
125
135
  todel: [],
126
136
  toadd: [
127
137
  { name: 1, synckey: 1, synctype: TSUD.description },
@@ -131,21 +141,21 @@ RSpec.describe MrMurano::SyncUpDown do
131
141
  tomod: [],
132
142
  unchg: [],
133
143
  skipd: [],
134
- clash: [],
135
- })
144
+ clash: []
145
+ )
136
146
  end
137
147
 
138
- it "finds things here but not there" do
148
+ it 'finds things here but not there' do
139
149
  FileUtils.mkpath(@project_dir + '/tsud')
140
150
  FileUtils.touch(@project_dir + '/tsud/one.lua')
141
151
  FileUtils.touch(@project_dir + '/tsud/two.lua')
142
152
  t = TSUD.new
143
153
  expect(t).to receive(:to_remote_item).and_return(
144
- {name: 'one.lua'},
145
- {name: 'two.lua'},
154
+ { name: 'one.lua' },
155
+ name: 'two.lua',
146
156
  )
147
157
  ret = t.status
148
- expect(ret).to match({
158
+ expect(ret).to match(
149
159
  toadd: [
150
160
  {
151
161
  name: 'one.lua',
@@ -164,25 +174,27 @@ RSpec.describe MrMurano::SyncUpDown do
164
174
  tomod: [],
165
175
  unchg: [],
166
176
  skipd: [],
167
- clash: [],
168
- })
177
+ clash: []
178
+ )
169
179
  end
170
180
 
171
- it "finds things here and there" do
181
+ it 'finds things here and there' do
172
182
  FileUtils.mkpath(@project_dir + '/tsud')
173
183
  FileUtils.touch(@project_dir + '/tsud/one.lua')
174
184
  FileUtils.touch(@project_dir + '/tsud/two.lua')
175
185
  t = TSUD.new
176
- expect(t).to receive(:list).once.and_return([
177
- {name: 'one.lua'},
178
- {name: 'two.lua'},
179
- ])
186
+ expect(t).to receive(:list).once.and_return(
187
+ [
188
+ { name: 'one.lua' },
189
+ { name: 'two.lua' },
190
+ ]
191
+ )
180
192
  expect(t).to receive(:to_remote_item).and_return(
181
- {name: 'one.lua'},
182
- {name: 'two.lua'},
193
+ { name: 'one.lua' },
194
+ name: 'two.lua',
183
195
  )
184
196
  ret = t.status
185
- expect(ret).to match({
197
+ expect(ret).to match(
186
198
  tomod: [
187
199
  {
188
200
  name: 'one.lua',
@@ -201,25 +213,27 @@ RSpec.describe MrMurano::SyncUpDown do
201
213
  toadd: [],
202
214
  unchg: [],
203
215
  skipd: [],
204
- clash: [],
205
- })
216
+ clash: []
217
+ )
206
218
  end
207
219
  it "finds things here and there; but they're the same" do
208
220
  FileUtils.mkpath(@project_dir + '/tsud')
209
221
  FileUtils.touch(@project_dir + '/tsud/one.lua')
210
222
  FileUtils.touch(@project_dir + '/tsud/two.lua')
211
223
  t = TSUD.new
212
- expect(t).to receive(:list).once.and_return([
213
- {name: 'one.lua'},
214
- {name: 'two.lua'},
215
- ])
224
+ expect(t).to receive(:list).once.and_return(
225
+ [
226
+ { name: 'one.lua' },
227
+ { name: 'two.lua' },
228
+ ]
229
+ )
216
230
  expect(t).to receive(:to_remote_item).and_return(
217
- {name: 'one.lua'},
218
- {name: 'two.lua'},
231
+ { name: 'one.lua' },
232
+ name: 'two.lua',
219
233
  )
220
234
  expect(t).to receive(:docmp).twice.and_return(false)
221
235
  ret = t.status
222
- expect(ret).to match({
236
+ expect(ret).to match(
223
237
  unchg: [
224
238
  {
225
239
  name: 'one.lua',
@@ -238,41 +252,41 @@ RSpec.describe MrMurano::SyncUpDown do
238
252
  toadd: [],
239
253
  tomod: [],
240
254
  skipd: [],
241
- clash: [],
242
- })
255
+ clash: []
256
+ )
243
257
  end
244
258
 
245
- it "calls diff" do
259
+ it 'calls diff' do
246
260
  FileUtils.mkpath(@project_dir + '/tsud')
247
261
  FileUtils.touch(@project_dir + '/tsud/one.lua')
248
262
  t = TSUD.new
249
263
  expect(t).to receive(:list).once.and_return([
250
- {name: 'one.lua'}
251
- ])
264
+ { name: 'one.lua' },
265
+ ])
252
266
  expect(t).to receive(:to_remote_item).and_return(
253
- {name: 'one.lua'}
267
+ name: 'one.lua'
254
268
  )
255
- expect(t).to receive(:dodiff).once.and_return("diffed output")
256
- ret = t.status({diff: true})
257
- expect(ret).to match({
269
+ expect(t).to receive(:dodiff).once.and_return('diffed output')
270
+ ret = t.status(diff: true)
271
+ expect(ret).to match(
258
272
  tomod: [
259
273
  {
260
274
  name: 'one.lua',
261
275
  synckey: 'one.lua',
262
276
  synctype: TSUD.description,
263
277
  local_path: an_instance_of(Pathname),
264
- diff: "diffed output",
278
+ diff: 'diffed output',
265
279
  },
266
280
  ],
267
281
  todel: [],
268
282
  toadd: [],
269
283
  unchg: [],
270
284
  skipd: [],
271
- clash: [],
272
- })
285
+ clash: []
286
+ )
273
287
  end
274
288
 
275
- context "Filtering" do
289
+ context 'Filtering' do
276
290
  before(:example) do
277
291
  FileUtils.mkpath(@project_dir + '/tsud/ga')
278
292
  FileUtils.mkpath(@project_dir + '/tsud/gb')
@@ -283,113 +297,107 @@ RSpec.describe MrMurano::SyncUpDown do
283
297
  FileUtils.touch(@project_dir + '/tsud/five.lua') # toadd
284
298
  FileUtils.touch(@project_dir + '/tsud/ga/six.lua') # toadd
285
299
  @t = TSUD.new
286
- expect(@t).to receive(:list).once.and_return([
287
- MrMurano::SyncUpDown::Item.new({name: 'eight.lua', updated_at: ITEM_UPDATED_AT}), # todel
288
- MrMurano::SyncUpDown::Item.new({name: 'four.lua', updated_at: ITEM_UPDATED_AT}), # unchg
289
- MrMurano::SyncUpDown::Item.new({name: 'one.lua', updated_at: ITEM_UPDATED_AT}), # tomod
290
- MrMurano::SyncUpDown::Item.new({name: 'seven.lua', updated_at: ITEM_UPDATED_AT}), # todel
291
- MrMurano::SyncUpDown::Item.new({name: 'three.lua', updated_at: ITEM_UPDATED_AT}), # unchg
292
- MrMurano::SyncUpDown::Item.new({name: 'two.lua', updated_at: ITEM_UPDATED_AT}), # tomod
293
- ])
294
- expect(@t).to receive(:to_remote_item).
295
- with(anything(), pathname_globs('**/one.lua')).
296
- and_return(MrMurano::SyncUpDown::Item.new({name: 'one.lua', updated_at: ITEM_UPDATED_AT}))
297
- expect(@t).to receive(:to_remote_item).
298
- with(anything(), pathname_globs('**/two.lua')).
299
- and_return(MrMurano::SyncUpDown::Item.new({name: 'two.lua', updated_at: ITEM_UPDATED_AT}))
300
- expect(@t).to receive(:to_remote_item).
301
- with(anything(), pathname_globs('**/three.lua')).
302
- and_return(MrMurano::SyncUpDown::Item.new({name: 'three.lua', updated_at: ITEM_UPDATED_AT}))
303
- expect(@t).to receive(:to_remote_item).
304
- with(anything(), pathname_globs('**/four.lua')).
305
- and_return(MrMurano::SyncUpDown::Item.new({name: 'four.lua', updated_at: ITEM_UPDATED_AT}))
306
- expect(@t).to receive(:to_remote_item).
307
- with(anything(), pathname_globs('**/five.lua')).
308
- and_return(MrMurano::SyncUpDown::Item.new({name: 'five.lua', updated_at: ITEM_UPDATED_AT}))
309
- expect(@t).to receive(:to_remote_item).
310
- with(anything(), pathname_globs('**/six.lua')).
311
- and_return(MrMurano::SyncUpDown::Item.new({name: 'six.lua', updated_at: ITEM_UPDATED_AT}))
312
-
313
- expect(@t).to receive(:docmp).with(have_attributes({name: 'one.lua'}),anything()).and_return(true)
314
- expect(@t).to receive(:docmp).with(have_attributes({name: 'two.lua'}),anything()).and_return(true)
315
- expect(@t).to receive(:docmp).with(have_attributes({name: 'three.lua'}),anything()).and_return(false)
316
- expect(@t).to receive(:docmp).with(have_attributes({name: 'four.lua'}),anything()).and_return(false)
300
+ expect(@t).to receive(:list).once.and_return(
301
+ [
302
+ MrMurano::SyncUpDown::Item.new(name: 'eight.lua', updated_at: ITEM_UPDATED_AT), # todel
303
+ MrMurano::SyncUpDown::Item.new(name: 'four.lua', updated_at: ITEM_UPDATED_AT), # unchg
304
+ MrMurano::SyncUpDown::Item.new(name: 'one.lua', updated_at: ITEM_UPDATED_AT), # tomod
305
+ MrMurano::SyncUpDown::Item.new(name: 'seven.lua', updated_at: ITEM_UPDATED_AT), # todel
306
+ MrMurano::SyncUpDown::Item.new(name: 'three.lua', updated_at: ITEM_UPDATED_AT), # unchg
307
+ MrMurano::SyncUpDown::Item.new(name: 'two.lua', updated_at: ITEM_UPDATED_AT), # tomod
308
+ ]
309
+ )
310
+ expect(@t).to receive(:to_remote_item)
311
+ .with(anything, pathname_globs('**/one.lua'))
312
+ .and_return(MrMurano::SyncUpDown::Item.new(name: 'one.lua', updated_at: ITEM_UPDATED_AT))
313
+ expect(@t).to receive(:to_remote_item)
314
+ .with(anything, pathname_globs('**/two.lua'))
315
+ .and_return(MrMurano::SyncUpDown::Item.new(name: 'two.lua', updated_at: ITEM_UPDATED_AT))
316
+ expect(@t).to receive(:to_remote_item)
317
+ .with(anything, pathname_globs('**/three.lua'))
318
+ .and_return(MrMurano::SyncUpDown::Item.new(name: 'three.lua', updated_at: ITEM_UPDATED_AT))
319
+ expect(@t).to receive(:to_remote_item)
320
+ .with(anything, pathname_globs('**/four.lua'))
321
+ .and_return(MrMurano::SyncUpDown::Item.new(name: 'four.lua', updated_at: ITEM_UPDATED_AT))
322
+ expect(@t).to receive(:to_remote_item)
323
+ .with(anything, pathname_globs('**/five.lua'))
324
+ .and_return(MrMurano::SyncUpDown::Item.new(name: 'five.lua', updated_at: ITEM_UPDATED_AT))
325
+ expect(@t).to receive(:to_remote_item)
326
+ .with(anything, pathname_globs('**/six.lua'))
327
+ .and_return(MrMurano::SyncUpDown::Item.new(name: 'six.lua', updated_at: ITEM_UPDATED_AT))
328
+
329
+ expect(@t).to receive(:docmp).with(have_attributes(name: 'one.lua'), anything).and_return(true)
330
+ expect(@t).to receive(:docmp).with(have_attributes(name: 'two.lua'), anything).and_return(true)
331
+ expect(@t).to receive(:docmp).with(have_attributes(name: 'three.lua'), anything).and_return(false)
332
+ expect(@t).to receive(:docmp).with(have_attributes(name: 'four.lua'), anything).and_return(false)
317
333
  end
318
334
 
319
- it "Returns all with no filter" do
335
+ it 'Returns all with no filter' do
320
336
  ret = @t.status
321
- expect(ret).to match({
337
+ expect(ret).to match(
322
338
  unchg: [
323
339
  have_attributes(
324
- {
325
- name: 'four.lua',
326
- synckey: 'four.lua',
327
- synctype: TSUD.description,
328
- local_path: pathname_globs('**/four.lua'),
329
- }),
340
+ name: 'four.lua',
341
+ synckey: 'four.lua',
342
+ synctype: TSUD.description,
343
+ local_path: pathname_globs('**/four.lua')
344
+ ),
330
345
  have_attributes(
331
- {
332
- name: 'three.lua',
333
- synckey: 'three.lua',
334
- synctype: TSUD.description,
335
- local_path: pathname_globs('**/three.lua'),
336
- }),
346
+ name: 'three.lua',
347
+ synckey: 'three.lua',
348
+ synctype: TSUD.description,
349
+ local_path: pathname_globs('**/three.lua')
350
+ ),
337
351
  ],
338
352
  toadd: [
339
353
  have_attributes(
340
- {
341
- name: 'five.lua',
342
- synckey: 'five.lua',
343
- synctype: TSUD.description,
344
- local_path: pathname_globs('**/five.lua'),
345
- }),
354
+ name: 'five.lua',
355
+ synckey: 'five.lua',
356
+ synctype: TSUD.description,
357
+ local_path: pathname_globs('**/five.lua')
358
+ ),
346
359
  have_attributes(
347
- {
348
- name: 'six.lua',
349
- synckey: 'six.lua',
350
- synctype: TSUD.description,
351
- local_path: pathname_globs('**/six.lua'),
352
- }),
360
+ name: 'six.lua',
361
+ synckey: 'six.lua',
362
+ synctype: TSUD.description,
363
+ local_path: pathname_globs('**/six.lua')
364
+ ),
353
365
  ],
354
366
  todel: [
355
367
  have_attributes(
356
- {
357
- name: 'eight.lua',
358
- synckey: 'eight.lua',
359
- synctype: TSUD.description,
360
- }),
368
+ name: 'eight.lua',
369
+ synckey: 'eight.lua',
370
+ synctype: TSUD.description
371
+ ),
361
372
  have_attributes(
362
- {
363
- name: 'seven.lua',
364
- synckey: 'seven.lua',
365
- synctype: TSUD.description,
366
- }),
373
+ name: 'seven.lua',
374
+ synckey: 'seven.lua',
375
+ synctype: TSUD.description
376
+ ),
367
377
  ],
368
378
  tomod: [
369
379
  have_attributes(
370
- {
371
- name: 'one.lua',
372
- synckey: 'one.lua',
373
- synctype: TSUD.description,
374
- local_path: pathname_globs('**/one.lua'),
375
- }),
380
+ name: 'one.lua',
381
+ synckey: 'one.lua',
382
+ synctype: TSUD.description,
383
+ local_path: pathname_globs('**/one.lua')
384
+ ),
376
385
  have_attributes(
377
- {
378
- name: 'two.lua',
379
- synckey: 'two.lua',
380
- synctype: TSUD.description,
381
- local_path: pathname_globs('**/two.lua'),
382
- }),
386
+ name: 'two.lua',
387
+ synckey: 'two.lua',
388
+ synctype: TSUD.description,
389
+ local_path: pathname_globs('**/two.lua')
390
+ ),
383
391
  ],
384
392
  skipd: [],
385
- clash: [],
386
- })
393
+ clash: []
394
+ )
387
395
  end
388
396
 
389
- it "Finds local path globs" do
397
+ it 'Finds local path globs' do
390
398
  ret = @t.status({}, ['**/ga/*.lua'])
391
- expect(ret).to match({
392
- unchg: [ ],
399
+ expect(ret).to match(
400
+ unchg: [],
393
401
  toadd: [
394
402
  have_attributes(
395
403
  name: 'six.lua',
@@ -398,7 +406,7 @@ RSpec.describe MrMurano::SyncUpDown do
398
406
  local_path: an_instance_of(Pathname)
399
407
  ),
400
408
  ],
401
- todel: [ ],
409
+ todel: [],
402
410
  tomod: [
403
411
  have_attributes(
404
412
  name: 'two.lua',
@@ -408,25 +416,25 @@ RSpec.describe MrMurano::SyncUpDown do
408
416
  ),
409
417
  ],
410
418
  skipd: [],
411
- clash: [],
412
- })
419
+ clash: []
420
+ )
413
421
  end
414
422
 
415
- it "Finds nothing with specific matcher" do
423
+ it 'Finds nothing with specific matcher' do
416
424
  ret = @t.status({}, ['#foo'])
417
- expect(ret).to match({
425
+ expect(ret).to match(
418
426
  unchg: [],
419
427
  toadd: [],
420
428
  todel: [],
421
429
  tomod: [],
422
430
  skipd: [],
423
- clash: [],
424
- })
431
+ clash: []
432
+ )
425
433
  end
426
434
 
427
- it "gets all the details" do
428
- ret = @t.status({unselected: true})
429
- expect(ret).to match({
435
+ it 'gets all the details' do
436
+ ret = @t.status(unselected: true)
437
+ expect(ret).to match(
430
438
  unchg: [
431
439
  have_attributes(
432
440
  name: 'four.lua',
@@ -434,7 +442,7 @@ RSpec.describe MrMurano::SyncUpDown do
434
442
  synctype: TSUD.description,
435
443
  selected: true,
436
444
  local_path: pathname_globs('**/four.lua')
437
- ),
445
+ ),
438
446
  have_attributes(
439
447
  name: 'three.lua',
440
448
  synckey: 'three.lua',
@@ -490,92 +498,96 @@ RSpec.describe MrMurano::SyncUpDown do
490
498
  ),
491
499
  ],
492
500
  skipd: [],
493
- clash: [],
494
- })
501
+ clash: []
502
+ )
495
503
  end
496
504
  end
497
505
  end
498
506
 
499
- context "localitems" do
507
+ context 'localitems' do
500
508
  before(:example) do
501
509
  FileUtils.mkpath('tsud')
502
510
  FileUtils.touch('tsud/one.lua')
503
511
  FileUtils.touch('tsud/two.lua')
504
512
  @t = TSUD.new
505
513
  end
506
- it "finds local items" do
514
+ it 'finds local items' do
507
515
  expect(@t).to receive(:to_remote_item).and_return(
508
- {name: 'one.lua'},
509
- {name: 'two.lua'},
516
+ { name: 'one.lua' },
517
+ name: 'two.lua',
510
518
  )
511
519
  ret = @t.localitems(Pathname.new(@project_dir + '/tsud').realpath)
512
- expect(ret).to match([
513
- {
514
- name: 'one.lua',
515
- local_path: an_instance_of(Pathname)
516
- },
517
- {
518
- name: 'two.lua',
519
- local_path: an_instance_of(Pathname)
520
- },
521
- ])
520
+ expect(ret).to match(
521
+ [
522
+ {
523
+ name: 'one.lua',
524
+ local_path: an_instance_of(Pathname),
525
+ },
526
+ {
527
+ name: 'two.lua',
528
+ local_path: an_instance_of(Pathname),
529
+ },
530
+ ]
531
+ )
522
532
  end
523
533
 
524
- it "takes an array from to_remote_item" do
534
+ it 'takes an array from to_remote_item' do
525
535
  expect(@t).to receive(:to_remote_item).and_return(
526
536
  [
527
- {name: 'one:1'},
528
- {name: 'one:2'},
537
+ { name: 'one:1' },
538
+ { name: 'one:2' },
529
539
  ],
530
540
  [
531
- {name: 'two:1'},
532
- {name: 'two:2'},
541
+ { name: 'two:1' },
542
+ { name: 'two:2' },
533
543
  ],
534
544
  )
535
545
  ret = @t.localitems(Pathname.new(@project_dir + '/tsud').realpath)
536
- expect(ret).to match([
537
- {
538
- name: 'one:1',
539
- local_path: an_instance_of(Pathname),
540
- },
541
- {
542
- name: 'one:2',
543
- local_path: an_instance_of(Pathname),
544
- },
545
- {
546
- name: 'two:1',
547
- local_path: an_instance_of(Pathname),
548
- },
549
- {
550
- name: 'two:2',
551
- local_path: an_instance_of(Pathname),
552
- },
553
- ])
546
+ expect(ret).to match(
547
+ [
548
+ {
549
+ name: 'one:1',
550
+ local_path: an_instance_of(Pathname),
551
+ },
552
+ {
553
+ name: 'one:2',
554
+ local_path: an_instance_of(Pathname),
555
+ },
556
+ {
557
+ name: 'two:1',
558
+ local_path: an_instance_of(Pathname),
559
+ },
560
+ {
561
+ name: 'two:2',
562
+ local_path: an_instance_of(Pathname),
563
+ },
564
+ ]
565
+ )
554
566
  end
555
567
  end
556
568
 
557
- context "download" do
558
- it "defaults to :id if @itemkey missing" do
569
+ context 'download' do
570
+ it 'defaults to :id if @itemkey missing' do
559
571
  FileUtils.mkpath(@project_dir + '/tsud')
560
572
  FileUtils.touch(@project_dir + '/tsud/one.lua')
561
573
  lp = Pathname.new(@project_dir + '/tsud/one.lua').realpath
562
574
  t = TSUD.new
563
- expect(t).to receive(:fetch).once.with(1).and_yield("foo")
564
- t.download(lp, {id: 1, updated_at: ITEM_UPDATED_AT})
575
+ expect(t).to receive(:fetch).once.with(1).and_yield('foo')
576
+ t.download(lp, id: 1, updated_at: ITEM_UPDATED_AT)
565
577
  end
566
578
  end
567
579
 
568
- context "doing diffs" do
580
+ context 'doing diffs' do
569
581
  before(:example) do
570
582
  FileUtils.mkpath(@project_dir + '/tsud')
571
583
  @t = TSUD.new
572
584
  @scpt = Pathname.new(@project_dir + '/tsud/one.lua')
573
- @scpt.open('w'){|io| io << %{-- fake lua\nreturn 0\n}}
585
+ @scpt.open('w') { |io| io << %(-- fake lua\nreturn 0\n) }
574
586
  @scpt = @scpt.realpath
575
587
  end
576
588
 
577
- it "nothing when same." do
578
- expect(@t).to receive(:fetch).and_yield(%{-- fake lua\nreturn 0\n})
589
+ it 'nothing when same.' do
590
+ expect(@t).to receive(:fetch).and_yield(%(-- fake lua\nreturn 0\n))
579
591
  ret = @t.dodiff(
580
592
  {
581
593
  name: 'one.lua',
@@ -584,15 +596,15 @@ RSpec.describe MrMurano::SyncUpDown do
584
596
  },
585
597
  nil
586
598
  )
587
- if Gem.win_platform? then
599
+ if Gem.win_platform?
588
600
  expect(ret).to match(/FC: no differences encountered/)
589
601
  else
590
602
  expect(ret).to eq('')
591
603
  end
592
604
  end
593
605
 
594
- it "something when different." do
595
- expect(@t).to receive(:fetch).and_yield(%{-- fake lua\nreturn 2\n})
606
+ it 'something when different.' do
607
+ expect(@t).to receive(:fetch).and_yield(%(-- fake lua\nreturn 2\n))
596
608
  ret = @t.dodiff(
597
609
  {
598
610
  name: 'one.lua',
@@ -604,8 +616,8 @@ RSpec.describe MrMurano::SyncUpDown do
604
616
  expect(ret).not_to eq('')
605
617
  end
606
618
 
607
- it "uses script in item" do
608
- script = %{-- fake lua\nreturn 2\n}
619
+ it 'uses script in item' do
620
+ script = %(-- fake lua\nreturn 2\n)
609
621
  expect(@t).to receive(:fetch).and_yield(script)
610
622
  ret = @t.dodiff(
611
623
  {
@@ -616,7 +628,7 @@ RSpec.describe MrMurano::SyncUpDown do
616
628
  },
617
629
  nil
618
630
  )
619
- if Gem.win_platform? then
631
+ if Gem.win_platform?
620
632
  expect(ret).to match(/FC: no differences encountered/)
621
633
  else
622
634
  expect(ret).to eq('')
@@ -624,56 +636,61 @@ RSpec.describe MrMurano::SyncUpDown do
624
636
  end
625
637
  end
626
638
 
627
- context "syncup" do
639
+ context 'syncup' do
628
640
  before(:example) do
629
641
  FileUtils.mkpath(@project_dir + '/tsud')
630
642
  @t = TSUD.new
631
643
  end
632
644
 
633
- it "removes" do
634
- expect(@t).to receive(:list).once.and_return([
635
- {name: 1},
636
- {name: 2},
637
- {name: 3},
638
- ])
645
+ it 'removes' do
646
+ expect(@t).to receive(:list).once.and_return(
647
+ [
648
+ { name: 1 },
649
+ { name: 2 },
650
+ { name: 3 },
651
+ ]
652
+ )
639
653
  expect(@t).to receive(:remove).exactly(3).times
640
- @t.syncup({delete: true})
654
+ @t.syncup(delete: true)
641
655
  end
642
656
 
643
- it "creates" do
657
+ it 'creates' do
644
658
  FileUtils.touch(@project_dir + '/tsud/one.lua')
645
659
  FileUtils.touch(@project_dir + '/tsud/two.lua')
646
660
 
647
- expect(@t).to receive(:upload).twice.with(kind_of(Pathname), kind_of(MrMurano::SyncUpDown::Item), false)
648
- @t.syncup({create: true})
661
+ expect(@t).to receive(:upload).twice
662
+ .with(kind_of(Pathname), kind_of(MrMurano::SyncUpDown::Item), false)
663
+ @t.syncup(create: true)
649
664
  end
650
665
 
651
- it "updates" do
666
+ it 'updates' do
652
667
  FileUtils.touch(@project_dir + '/tsud/one.lua')
653
668
  FileUtils.touch(@project_dir + '/tsud/two.lua')
654
- expect(@t).to receive(:list).once.and_return([
655
- MrMurano::SyncUpDown::Item.new({name: 'one.lua', updated_at: ITEM_UPDATED_AT}),
656
- MrMurano::SyncUpDown::Item.new({name: 'two.lua', updated_at: ITEM_UPDATED_AT})
657
- ])
669
+ expect(@t).to receive(:list).once.and_return(
670
+ [
671
+ MrMurano::SyncUpDown::Item.new(name: 'one.lua', updated_at: ITEM_UPDATED_AT),
672
+ MrMurano::SyncUpDown::Item.new(name: 'two.lua', updated_at: ITEM_UPDATED_AT),
673
+ ]
674
+ )
658
675
 
659
676
  expect(@t).to receive(:upload).twice.with(
660
677
  kind_of(Pathname), kind_of(MrMurano::SyncUpDown::Item), true
661
678
  )
662
679
  expect(@t).to receive(:to_remote_item).and_return(
663
- {name: 'one.lua'},
664
- {name: 'two.lua'},
680
+ { name: 'one.lua' },
681
+ name: 'two.lua',
665
682
  )
666
- @t.syncup({update: true})
683
+ @t.syncup(update: true)
667
684
  end
668
685
  end
669
686
 
670
- context "syncdown" do
687
+ context 'syncdown' do
671
688
  before(:example) do
672
689
  FileUtils.mkpath(@project_dir + '/tsud')
673
690
  @t = TSUD.new
674
691
  end
675
692
 
676
- it "removes" do
693
+ it 'removes' do
677
694
  FileUtils.touch(@project_dir + '/tsud/one.lua')
678
695
  FileUtils.touch(@project_dir + '/tsud/two.lua')
679
696
 
@@ -682,11 +699,13 @@ RSpec.describe MrMurano::SyncUpDown do
682
699
  expect(FileTest.exist?(@project_dir + '/tsud/two.lua')).to be false
683
700
  end
684
701
 
685
- it "creates" do
686
- expect(@t).to receive(:list).once.and_return([
687
- MrMurano::SyncUpDown::Item.new({name: 'one.lua', updated_at: ITEM_UPDATED_AT}),
688
- MrMurano::SyncUpDown::Item.new({name: 'two.lua', updated_at: ITEM_UPDATED_AT})
689
- ])
702
+ it 'creates' do
703
+ expect(@t).to receive(:list).once.and_return(
704
+ [
705
+ MrMurano::SyncUpDown::Item.new(name: 'one.lua', updated_at: ITEM_UPDATED_AT),
706
+ MrMurano::SyncUpDown::Item.new(name: 'two.lua', updated_at: ITEM_UPDATED_AT),
707
+ ]
708
+ )
690
709
 
691
710
  expect(@t).to receive(:fetch).twice.and_yield("--foo\n")
692
711
  @t.syncdown(create: true)
@@ -694,18 +713,20 @@ RSpec.describe MrMurano::SyncUpDown do
694
713
  expect(FileTest.exist?(@project_dir + '/tsud/two.lua')).to be true
695
714
  end
696
715
 
697
- it "updates" do
716
+ it 'updates' do
698
717
  FileUtils.touch(@project_dir + '/tsud/one.lua')
699
718
  FileUtils.touch(@project_dir + '/tsud/two.lua')
700
- expect(@t).to receive(:list).once.and_return([
701
- MrMurano::SyncUpDown::Item.new({name: 'one.lua', updated_at: ITEM_UPDATED_AT}),
702
- MrMurano::SyncUpDown::Item.new({name: 'two.lua', updated_at: ITEM_UPDATED_AT})
703
- ])
719
+ expect(@t).to receive(:list).once.and_return(
720
+ [
721
+ MrMurano::SyncUpDown::Item.new(name: 'one.lua', updated_at: ITEM_UPDATED_AT),
722
+ MrMurano::SyncUpDown::Item.new(name: 'two.lua', updated_at: ITEM_UPDATED_AT),
723
+ ]
724
+ )
704
725
 
705
726
  expect(@t).to receive(:fetch).twice.and_yield("--foo\n")
706
727
  expect(@t).to receive(:to_remote_item).and_return(
707
- MrMurano::SyncUpDown::Item.new({name: 'one.lua', updated_at: ITEM_UPDATED_AT}),
708
- MrMurano::SyncUpDown::Item.new({name: 'two.lua', updated_at: ITEM_UPDATED_AT})
728
+ MrMurano::SyncUpDown::Item.new(name: 'one.lua', updated_at: ITEM_UPDATED_AT),
729
+ MrMurano::SyncUpDown::Item.new(name: 'two.lua', updated_at: ITEM_UPDATED_AT)
709
730
  )
710
731
  @t.syncdown(update: true)
711
732
  expect(FileTest.exist?(@project_dir + '/tsud/one.lua')).to be true
@@ -748,5 +769,3 @@ RSpec.describe MrMurano::SyncUpDown do
748
769
  # end
749
770
  end
750
771
 
751
- # vim: set ai et sw=2 ts=2 :
752
-