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,6 @@
1
1
  # Last Modified: 2017.07.03 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  # frozen_string_literal: probably not yet
3
5
 
4
6
  # Copyright © 2016-2017 Exosite LLC.
@@ -19,7 +21,7 @@ class VTst
19
21
  end
20
22
  end
21
23
  RSpec.describe MrMurano::Verbose do
22
- include_context "WORKSPACE"
24
+ include_context 'WORKSPACE'
23
25
 
24
26
  before(:example) do
25
27
  $cfg = MrMurano::Config.new
@@ -27,53 +29,53 @@ RSpec.describe MrMurano::Verbose do
27
29
  @tst = VTst.new
28
30
  end
29
31
 
30
- it "verboses" do
32
+ it 'verboses' do
31
33
  $cfg['tool.verbose'] = true
32
34
  expect($terminal).to receive(:say).with('hello').once
33
- @tst.verbose "hello"
35
+ @tst.verbose 'hello'
34
36
  end
35
37
 
36
- it "is quiet" do
38
+ it 'is quiet' do
37
39
  expect($terminal).to_not receive(:say)
38
- @tst.verbose "hello"
40
+ @tst.verbose 'hello'
39
41
  end
40
42
 
41
- it "debugs" do
43
+ it 'debugs' do
42
44
  $cfg['tool.debug'] = true
43
45
  expect($terminal).to receive(:say).with('hello').once
44
- @tst.debug "hello"
46
+ @tst.debug 'hello'
45
47
  end
46
48
 
47
- it "warns" do
49
+ it 'warns' do
48
50
  expect($stderr).to receive(:puts).with("\e[33mhello\e[0m").once
49
- @tst.warning "hello"
51
+ @tst.warning 'hello'
50
52
  end
51
53
 
52
- it "errors" do
54
+ it 'errors' do
53
55
  expect($stderr).to receive(:puts).with("\e[31mhello\e[0m").once
54
- @tst.error "hello"
56
+ @tst.error 'hello'
55
57
  end
56
58
 
57
- context "tabularize" do
58
- context "generating CSV" do
59
+ context 'tabularize' do
60
+ context 'generating CSV' do
59
61
  before(:example) do
60
62
  $cfg['tool.outformat'] = 'csv'
61
63
  end
62
64
 
63
- it "takes Array" do
65
+ it 'takes Array' do
64
66
  $stdout = StringIO.new
65
67
 
66
- @tst.tabularize([[1,2,3,4,5,6,7],[10,20,30,40,50,60,70]])
68
+ @tst.tabularize([[1, 2, 3, 4, 5, 6, 7], [10, 20, 30, 40, 50, 60, 70]])
67
69
 
68
70
  expect($stdout.string).to eq("1,2,3,4,5,6,7\n10,20,30,40,50,60,70\n")
69
71
  end
70
72
 
71
- it "ducks to_a" do
73
+ it 'ducks to_a' do
72
74
  $stdout = StringIO.new
73
75
 
74
76
  class DuckToATest
75
77
  def to_a
76
- [[12],[13]]
78
+ [[12], [13]]
77
79
  end
78
80
  end
79
81
  @tst.tabularize(DuckToATest.new)
@@ -81,11 +83,11 @@ RSpec.describe MrMurano::Verbose do
81
83
  expect($stdout.string).to eq("12\n13\n")
82
84
  end
83
85
 
84
- it "ducks each" do
86
+ it 'ducks each' do
85
87
  $stdout = StringIO.new
86
88
 
87
89
  class DuckEachTest
88
- def each(&block)
90
+ def each
89
91
  yield [22]
90
92
  yield [44]
91
93
  end
@@ -95,38 +97,38 @@ RSpec.describe MrMurano::Verbose do
95
97
  expect($stdout.string).to eq("22\n44\n")
96
98
  end
97
99
 
98
- context "takes Hash" do
100
+ context 'takes Hash' do
99
101
  before(:example) do
100
102
  @hsh = {
101
- :headers => [:one, :two, :three],
102
- :title => "Test output",
103
- :rows => [[1,2,3], [10,20,30]]
103
+ headers: %i[one two three],
104
+ title: 'Test output',
105
+ rows: [[1, 2, 3], [10, 20, 30]],
104
106
  }
105
107
  $stdout = StringIO.new
106
108
  end
107
- it "has all" do
109
+ it 'has all' do
108
110
  @tst.tabularize(@hsh)
109
111
  expect($stdout.string).to eq("one,two,three\n1,2,3\n10,20,30\n")
110
112
  end
111
113
 
112
- it "is empty" do
114
+ it 'is empty' do
113
115
  @tst.tabularize({})
114
116
  expect($stdout.string).to eq("\n")
115
117
  end
116
118
 
117
- it "no headers" do
119
+ it 'no headers' do
118
120
  @hsh.delete :headers
119
121
  @tst.tabularize(@hsh)
120
122
  expect($stdout.string).to eq("1,2,3\n10,20,30\n")
121
123
  end
122
124
 
123
- it "no title" do
125
+ it 'no title' do
124
126
  @hsh.delete :title
125
127
  @tst.tabularize(@hsh)
126
128
  expect($stdout.string).to eq("one,two,three\n1,2,3\n10,20,30\n")
127
129
  end
128
130
 
129
- it "no rows" do
131
+ it 'no rows' do
130
132
  @hsh.delete :rows
131
133
  @tst.tabularize(@hsh)
132
134
  expect($stdout.string).to eq("one,two,three\n\n")
@@ -141,144 +143,144 @@ RSpec.describe MrMurano::Verbose do
141
143
  @tst.tabularize(12)
142
144
  end
143
145
 
144
- it "takes Array, to custom stream" do
146
+ it 'takes Array, to custom stream' do
145
147
  $stdout = StringIO.new
146
148
  outer = StringIO.new
147
149
 
148
- @tst.tabularize([[1,2,3,4,5,6,7],[10,20,30,40,50,60,70]], outer)
150
+ @tst.tabularize([[1, 2, 3, 4, 5, 6, 7], [10, 20, 30, 40, 50, 60, 70]], outer)
149
151
 
150
152
  expect(outer.string).to eq("1,2,3,4,5,6,7\n10,20,30,40,50,60,70\n")
151
153
  expect($stdout.string).to eq('')
152
154
  end
153
155
  end
154
156
 
155
- context "generating a table" do
156
- it "takes Array" do
157
+ context 'generating a table' do
158
+ it 'takes Array' do
157
159
  $stdout = StringIO.new
158
- @tst.tabularize([[1,2,3,4,5,6,7],[10,20,30,40,50,60,70]])
160
+ @tst.tabularize([[1, 2, 3, 4, 5, 6, 7], [10, 20, 30, 40, 50, 60, 70]])
159
161
  expect($stdout.string).to eq(
160
- %{+----+----+----+----+----+----+----+
161
- | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
162
- | 10 | 20 | 30 | 40 | 50 | 60 | 70 |
163
- +----+----+----+----+----+----+----+
164
- }.gsub(/^\s+/,'')
162
+ %(+----+----+----+----+----+----+----+
163
+ | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
164
+ | 10 | 20 | 30 | 40 | 50 | 60 | 70 |
165
+ +----+----+----+----+----+----+----+
166
+ ).gsub(/^\s+/, '')
165
167
  )
166
168
  end
167
169
 
168
- context "takes Hash" do
170
+ context 'takes Hash' do
169
171
  before(:example) do
170
172
  @hsh = {
171
- :headers => [:one, :two, :three],
172
- :title => "Test output",
173
- :rows => [[1,2,3], [10,20,30]]
173
+ headers: %i[one two three],
174
+ title: 'Test output',
175
+ rows: [[1, 2, 3], [10, 20, 30]],
174
176
  }
175
177
  $stdout = StringIO.new
176
178
  end
177
- it "has all" do
179
+ it 'has all' do
178
180
  @tst.tabularize(@hsh)
179
181
  expect($stdout.string).to eq(
180
- %{+-----+-----+-------+
181
- | Test output |
182
- +-----+-----+-------+
183
- | one | two | three |
184
- +-----+-----+-------+
185
- | 1 | 2 | 3 |
186
- | 10 | 20 | 30 |
187
- +-----+-----+-------+
188
- }.gsub(/^\s+/,'')
189
- )
182
+ %(+-----+-----+-------+
183
+ | Test output |
184
+ +-----+-----+-------+
185
+ | one | two | three |
186
+ +-----+-----+-------+
187
+ | 1 | 2 | 3 |
188
+ | 10 | 20 | 30 |
189
+ +-----+-----+-------+
190
+ ).gsub(/^\s+/, '')
191
+ )
190
192
  end
191
193
 
192
- it "is empty" do
194
+ it 'is empty' do
193
195
  @tst.tabularize({})
194
196
  expect($stdout.string).to eq("++\n++\n")
195
197
  end
196
198
 
197
- it "no headers" do
199
+ it 'no headers' do
198
200
  @hsh.delete :headers
199
201
  @tst.tabularize(@hsh)
200
202
  expect($stdout.string).to eq(
201
- %{+----+----+----+
202
- | Test output |
203
- +----+----+----+
204
- | 1 | 2 | 3 |
205
- | 10 | 20 | 30 |
206
- +----+----+----+
207
- }.gsub(/^\s+/,'')
208
- )
203
+ %(+----+----+----+
204
+ | Test output |
205
+ +----+----+----+
206
+ | 1 | 2 | 3 |
207
+ | 10 | 20 | 30 |
208
+ +----+----+----+
209
+ ).gsub(/^\s+/, '')
210
+ )
209
211
  end
210
212
 
211
- it "no title" do
213
+ it 'no title' do
212
214
  @hsh.delete :title
213
215
  @tst.tabularize(@hsh)
214
216
  expect($stdout.string).to eq(
215
- %{+-----+-----+-------+
216
- | one | two | three |
217
- +-----+-----+-------+
218
- | 1 | 2 | 3 |
219
- | 10 | 20 | 30 |
220
- +-----+-----+-------+
221
- }.gsub(/^\s+/,'')
222
- )
217
+ %(+-----+-----+-------+
218
+ | one | two | three |
219
+ +-----+-----+-------+
220
+ | 1 | 2 | 3 |
221
+ | 10 | 20 | 30 |
222
+ +-----+-----+-------+
223
+ ).gsub(/^\s+/, '')
224
+ )
223
225
  end
224
226
 
225
- it "no rows" do
227
+ it 'no rows' do
226
228
  @hsh.delete :rows
227
229
  @tst.tabularize(@hsh)
228
230
  expect($stdout.string).to eq(
229
- %{+-----+-----+-------+
230
- | Test output |
231
- +-----+-----+-------+
232
- | one | two | three |
233
- +-----+-----+-------+
234
- +-----+-----+-------+
235
- }
236
- )
231
+ %(+-----+-----+-------+
232
+ | Test output |
233
+ +-----+-----+-------+
234
+ | one | two | three |
235
+ +-----+-----+-------+
236
+ +-----+-----+-------+
237
+ ).gsub(/^\s+/, '')
238
+ )
237
239
  end
238
240
  end
239
241
  end
240
242
  end
241
243
 
242
- context "outf" do
244
+ context 'outf' do
243
245
  before(:example) do
244
246
  @data = {
245
- :one => "three",
246
- :two => [ { :one => 3 }, { :one => 4} ]
247
+ one: 'three',
248
+ two: [{ one: 3 }, { one: 4 }],
247
249
  }
248
250
  $stdout = StringIO.new
249
251
  end
250
252
 
251
- it "outputs yaml" do
253
+ it 'outputs yaml' do
252
254
  $cfg['tool.outformat'] = 'yaml'
253
255
  @tst.outf(@data)
254
256
  expect($stdout.string).to eq("---\none: three\ntwo:\n- one: 3\n- one: 4\n")
255
257
  end
256
258
 
257
- it "outputs json" do
259
+ it 'outputs json' do
258
260
  $cfg['tool.outformat'] = 'json'
259
261
  @tst.outf(@data)
260
262
  expect($stdout.string).to eq("{\"one\":\"three\",\"two\":[{\"one\":3},{\"one\":4}]}\n")
261
263
  end
262
264
 
263
- it "outputs ruby" do
265
+ it 'outputs ruby' do
264
266
  $cfg['tool.outformat'] = 'pp'
265
267
  @tst.outf(@data)
266
268
  expect($stdout.string).to eq("{:one=>\"three\", :two=>[{:one=>3}, {:one=>4}]}\n")
267
269
  end
268
270
 
269
- it "outputs as String" do
271
+ it 'outputs as String' do
270
272
  @tst.outf(@data)
271
273
  expect($stdout.string).to eq("{:one=>\"three\", :two=>[{:one=>3}, {:one=>4}]}\n")
272
274
  end
273
275
 
274
- it "outputs as Array" do
275
- @tst.outf([1,2,3,4,5])
276
+ it 'outputs as Array' do
277
+ @tst.outf([1, 2, 3, 4, 5])
276
278
  expect($stdout.string).to eq("1\n2\n3\n4\n5\n")
277
279
  end
278
280
 
279
- it "returns to block" do
280
- @tst.outf(@data) do |dd, ios|
281
- ios.puts "pop"
281
+ it 'returns to block' do
282
+ @tst.outf(@data) do |_dd, ios|
283
+ ios.puts 'pop'
282
284
  end
283
285
  expect($stdout.string).to eq("pop\n")
284
286
  end
@@ -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 'yaml'
3
10
  require 'MrMurano/version'
@@ -7,7 +14,7 @@ require 'MrMurano/Webservice-Cors'
7
14
  require '_workspace'
8
15
 
9
16
  RSpec.describe MrMurano::Webservice::Cors do
10
- include_context "WORKSPACE"
17
+ include_context 'WORKSPACE'
11
18
  before(:example) do
12
19
  MrMurano::SyncRoot.instance.reset
13
20
  $cfg = MrMurano::Config.new
@@ -16,48 +23,60 @@ RSpec.describe MrMurano::Webservice::Cors do
16
23
  $cfg['application.id'] = 'XYZ'
17
24
 
18
25
  @srv = MrMurano::Webservice::Cors.new
19
- allow(@srv).to receive(:token).and_return("TTTTTTTTTT")
26
+ allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
20
27
 
21
- @baseURI = "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/cors"
28
+ @base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/cors'
22
29
  end
23
30
 
24
- it "initializes" do
31
+ it 'initializes' do
25
32
  uri = @srv.endpoint('/')
26
- expect(uri.to_s).to eq("#{@baseURI}/")
33
+ expect(uri.to_s).to eq("#{@base_uri}/")
27
34
  end
28
35
 
29
- context "when server gives string" do
30
- context "fetches" do
31
- it "as a hash" do
32
- cors = {:origin=>true,
33
- :methods=>["HEAD","GET","POST","PUT","DELETE","OPTIONS","PATCH"],
34
- :headers=>["Content-Type","Cookie","Authorization"],
35
- :credentials=>true}
36
- body = {:cors=>cors.to_json}
37
- stub_request(:get, "#{@baseURI}").
38
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
39
- 'Content-Type'=>'application/json'}).
40
- to_return(body: body.to_json)
41
-
42
- ret = @srv.fetch()
36
+ context 'when server gives string' do
37
+ context 'fetches' do
38
+ it 'as a hash' do
39
+ cors = {
40
+ origin: true,
41
+ methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
42
+ headers: ['Content-Type', 'Cookie', 'Authorization'],
43
+ credentials: true,
44
+ }
45
+ body = { cors: cors.to_json }
46
+ stub_request(
47
+ :get, @base_uri.to_s
48
+ ).with(
49
+ headers: {
50
+ 'Authorization' => 'token TTTTTTTTTT',
51
+ 'Content-Type' => 'application/json',
52
+ }
53
+ ).to_return(body: body.to_json)
54
+
55
+ ret = @srv.fetch
43
56
  expect(ret).to eq(cors)
44
57
  end
45
- it "as a block" do
46
- cors = {:origin=>true,
47
- :methods=>["HEAD","GET","POST","PUT","DELETE","OPTIONS","PATCH"],
48
- :headers=>["Content-Type","Cookie","Authorization"],
49
- :credentials=>true}
50
- body = {:cors=>cors.to_json}
51
- stub_request(:get, "#{@baseURI}").
52
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
53
- 'Content-Type'=>'application/json'}).
54
- to_return(body: body.to_json)
58
+ it 'as a block' do
59
+ cors = {
60
+ origin: true,
61
+ methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
62
+ headers: ['Content-Type', 'Cookie', 'Authorization'],
63
+ credentials: true,
64
+ }
65
+ body = { cors: cors.to_json }
66
+ stub_request(
67
+ :get, @base_uri.to_s
68
+ ).with(
69
+ headers: {
70
+ 'Authorization' => 'token TTTTTTTTTT',
71
+ 'Content-Type' => 'application/json',
72
+ }
73
+ ).to_return(body: body.to_json)
55
74
 
56
75
  ret = ''
57
76
  loops = 0
58
- @srv.fetch() do |chunk|
77
+ @srv.fetch do |chunk|
59
78
  loops += 1
60
- ret << chunk
79
+ ret += chunk
61
80
  expect(loops).to be <= 1
62
81
  end
63
82
  expect(ret).to eq(Hash.transform_keys_to_strings(cors).to_yaml)
@@ -65,38 +84,50 @@ RSpec.describe MrMurano::Webservice::Cors do
65
84
  end
66
85
  end
67
86
 
68
- context "when server gives object" do
69
- context "fetches" do
70
- it "as a hash" do
71
- cors = {:origin=>true,
72
- :methods=>["HEAD","GET","POST","PUT","DELETE","OPTIONS","PATCH"],
73
- :headers=>["Content-Type","Cookie","Authorization"],
74
- :credentials=>true}
87
+ context 'when server gives object' do
88
+ context 'fetches' do
89
+ it 'as a hash' do
90
+ cors = {
91
+ origin: true,
92
+ methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
93
+ headers: ['Content-Type', 'Cookie', 'Authorization'],
94
+ credentials: true,
95
+ }
75
96
  body = cors
76
- stub_request(:get, "#{@baseURI}").
77
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
78
- 'Content-Type'=>'application/json'}).
79
- to_return(body: body.to_json)
80
-
81
- ret = @srv.fetch()
97
+ stub_request(
98
+ :get, @base_uri.to_s
99
+ ).with(
100
+ headers: {
101
+ 'Authorization' => 'token TTTTTTTTTT',
102
+ 'Content-Type' => 'application/json',
103
+ }
104
+ ).to_return(body: body.to_json)
105
+
106
+ ret = @srv.fetch
82
107
  expect(ret).to eq(cors)
83
108
  end
84
- it "as a block" do
85
- cors = {:origin=>true,
86
- :methods=>["HEAD","GET","POST","PUT","DELETE","OPTIONS","PATCH"],
87
- :headers=>["Content-Type","Cookie","Authorization"],
88
- :credentials=>true}
109
+ it 'as a block' do
110
+ cors = {
111
+ origin: true,
112
+ methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
113
+ headers: ['Content-Type', 'Cookie', 'Authorization'],
114
+ credentials: true,
115
+ }
89
116
  body = cors
90
- stub_request(:get, "#{@baseURI}").
91
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
92
- 'Content-Type'=>'application/json'}).
93
- to_return(body: body.to_json)
117
+ stub_request(
118
+ :get, @base_uri.to_s
119
+ ).with(
120
+ headers: {
121
+ 'Authorization' => 'token TTTTTTTTTT',
122
+ 'Content-Type' => 'application/json',
123
+ }
124
+ ).to_return(body: body.to_json)
94
125
 
95
126
  ret = ''
96
127
  loops = 0
97
- @srv.fetch() do |chunk|
128
+ @srv.fetch do |chunk|
98
129
  loops += 1
99
- ret << chunk
130
+ ret += chunk
100
131
  expect(loops).to be <= 1
101
132
  end
102
133
  expect(ret).to eq(Hash.transform_keys_to_strings(cors).to_yaml)
@@ -104,64 +135,79 @@ RSpec.describe MrMurano::Webservice::Cors do
104
135
  end
105
136
  end
106
137
 
107
- context "uploads" do
138
+ context 'uploads' do
108
139
  before(:example) do
109
140
  $project = MrMurano::ProjectFile.new
110
141
  $project.load
111
- @cors = {:origin=>true,
112
- :methods=>["HEAD","GET","POST","PUT","DELETE","OPTIONS","PATCH"],
113
- :headers=>["Content-Type","Cookie","Authorization"],
114
- :credentials=>true}
142
+ @cors = {
143
+ origin: true,
144
+ methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
145
+ headers: ['Content-Type', 'Cookie', 'Authorization'],
146
+ credentials: true,
147
+ }
115
148
  end
116
- it "specified file" do
117
- File.open(File.join(@project_dir, 'bob.yaml'), 'w'){|io| io << @cors.to_yaml}
118
- stub_request(:put, "#{@baseURI}").
119
- with(:body=>@cors.to_json,
120
- :headers=>{'Authorization'=>'token TTTTTTTTTT',
121
- 'Content-Type'=>'application/json'}).
122
- to_return(body: "")
149
+ it 'specified file' do
150
+ File.open(File.join(@project_dir, 'bob.yaml'), 'w') { |io| io << @cors.to_yaml }
151
+ stub_request(
152
+ :put, @base_uri.to_s
153
+ ).with(
154
+ body: @cors.to_json,
155
+ headers: {
156
+ 'Authorization' => 'token TTTTTTTTTT',
157
+ 'Content-Type' => 'application/json',
158
+ }
159
+ ).to_return(body: '')
123
160
 
124
161
  ret = @srv.upload('bob.yaml')
125
162
  expect(ret).to eq({})
126
163
  end
127
164
 
128
- it "file in $project" do
129
- File.open(File.join(@project_dir, 'bob.yaml'), 'w'){|io| io << @cors.to_yaml}
165
+ it 'file in $project' do
166
+ File.open(File.join(@project_dir, 'bob.yaml'), 'w') { |io| io << @cors.to_yaml }
130
167
  $project['routes.cors'] = 'bob.yaml'
131
- stub_request(:put, "#{@baseURI}").
132
- with(:body=>@cors.to_json,
133
- :headers=>{'Authorization'=>'token TTTTTTTTTT',
134
- 'Content-Type'=>'application/json'}).
135
- to_return(body: "")
136
-
137
- ret = @srv.upload()
168
+ stub_request(
169
+ :put, @base_uri.to_s
170
+ ).with(body: @cors.to_json,
171
+ headers: {
172
+ 'Authorization' => 'token TTTTTTTTTT',
173
+ 'Content-Type' => 'application/json',
174
+ }).to_return(body: '')
175
+
176
+ ret = @srv.upload
138
177
  expect(ret).to eq({})
139
178
  end
140
179
 
141
- it "file defaults thru $project" do
142
- File.open(File.join(@project_dir, 'cors.yaml'), 'w'){|io| io << @cors.to_yaml}
143
- stub_request(:put, "#{@baseURI}").
144
- with(:body=>@cors.to_json,
145
- :headers=>{'Authorization'=>'token TTTTTTTTTT',
146
- 'Content-Type'=>'application/json'}).
147
- to_return(body: "")
148
-
149
- ret = @srv.upload()
180
+ it 'file defaults thru $project' do
181
+ File.open(File.join(@project_dir, 'cors.yaml'), 'w') { |io| io << @cors.to_yaml }
182
+ stub_request(
183
+ :put, @base_uri.to_s
184
+ ).with(
185
+ body: @cors.to_json,
186
+ headers: {
187
+ 'Authorization' => 'token TTTTTTTTTT',
188
+ 'Content-Type' => 'application/json',
189
+ }
190
+ ).to_return(body: '')
191
+
192
+ ret = @srv.upload
150
193
  expect(ret).to eq({})
151
194
  end
152
195
 
153
- it "cors in $project" do
196
+ it 'cors in $project' do
154
197
  $project['routes.cors'] = @cors
155
- stub_request(:put, "#{@baseURI}").
156
- with(:body=>@cors.to_json,
157
- :headers=>{'Authorization'=>'token TTTTTTTTTT',
158
- 'Content-Type'=>'application/json'}).
159
- to_return(body: "")
160
-
161
- ret = @srv.upload()
198
+ stub_request(
199
+ :put, @base_uri.to_s
200
+ ).with(
201
+ body: @cors.to_json,
202
+ headers: {
203
+ 'Authorization' => 'token TTTTTTTTTT',
204
+ 'Content-Type' => 'application/json',
205
+ }
206
+ ).to_return(body: '')
207
+
208
+ ret = @srv.upload
162
209
  expect(ret).to eq({})
163
210
  end
164
211
  end
165
-
166
212
  end
167
- # vim: set ai et sw=2 ts=2 :
213
+