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,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 '_workspace'
3
10
  require 'MrMurano/version'
@@ -5,7 +12,7 @@ require 'MrMurano/ProjectFile'
5
12
  require 'MrMurano/Webservice-Endpoint'
6
13
 
7
14
  RSpec.describe MrMurano::Webservice::Endpoint 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,180 +22,192 @@ RSpec.describe MrMurano::Webservice::Endpoint do
15
22
  $cfg['application.id'] = 'XYZ'
16
23
 
17
24
  @srv = MrMurano::Webservice::Endpoint.new
18
- allow(@srv).to receive(:token).and_return("TTTTTTTTTT")
25
+ allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
19
26
 
20
- @baseURI = "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/endpoint"
27
+ @base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/endpoint'
21
28
  end
22
29
 
23
- it "initializes" do
30
+ it 'initializes' do
24
31
  uri = @srv.endpoint('/')
25
- expect(uri.to_s).to eq("#{@baseURI}/")
32
+ expect(uri.to_s).to eq("#{@base_uri}/")
26
33
  end
27
34
 
28
- context "lists" do
29
- it "same content_type" do
30
- body = [{:id=>"9K0",
31
- :method=>"websocket",
32
- :path=>"/api/v1/bar",
33
- :content_type=>"application/json",
34
- :script=>"--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
35
- },
36
- {:id=>"B76",
37
- :method=>"websocket",
38
- :path=>"/api/v1/foo/{id}",
39
- :content_type=>"application/json",
40
- :script=> "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n",
41
- }]
42
- stub_request(:get, @baseURI).
43
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
44
- 'Content-Type'=>'application/json'}).
45
- to_return(body: body.to_json)
35
+ context 'lists' do
36
+ it 'same content_type' do
37
+ body = [
38
+ {
39
+ id: '9K0',
40
+ method: 'websocket',
41
+ path: '/api/v1/bar',
42
+ content_type: 'application/json',
43
+ script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
44
+ },
45
+ { id: 'B76',
46
+ method: 'websocket',
47
+ path: '/api/v1/foo/{id}',
48
+ content_type: 'application/json',
49
+ script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
50
+ ]
51
+ stub_request(:get, @base_uri)
52
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
53
+ 'Content-Type' => 'application/json', })
54
+ .to_return(body: body.to_json)
46
55
 
47
56
  ret = @srv.list
48
57
  expect(ret).to eq(body)
49
58
  end
50
59
 
51
- it "missing headers" do
52
- body = [{:id=>"9K0",
53
- :method=>"websocket",
54
- :path=>"/api/v1/bar",
55
- :content_type=>"application/json",
56
- :script=>"response.message = \"HI\"\n\n",
57
- },
58
- {:id=>"B76",
59
- :method=>"websocket",
60
- :path=>"/api/v1/foo/{id}",
61
- :content_type=>"application/json",
62
- :script=> "response.message = \"HI\"\n\n-- BOB WAS HERE\n",
63
- }]
64
- stub_request(:get, @baseURI).
65
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
66
- 'Content-Type'=>'application/json'}).
67
- to_return(body: body.to_json)
60
+ it 'missing headers' do
61
+ body = [
62
+ {
63
+ id: '9K0',
64
+ method: 'websocket',
65
+ path: '/api/v1/bar',
66
+ content_type: 'application/json',
67
+ script: "response.message = \"HI\"\n\n",
68
+ },
69
+ { id: 'B76',
70
+ method: 'websocket',
71
+ path: '/api/v1/foo/{id}',
72
+ content_type: 'application/json',
73
+ script: "response.message = \"HI\"\n\n-- BOB WAS HERE\n", },
74
+ ]
75
+ stub_request(:get, @base_uri)
76
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
77
+ 'Content-Type' => 'application/json', })
78
+ .to_return(body: body.to_json)
68
79
 
69
80
  ret = @srv.list
70
81
  expect(ret).to eq(body)
71
82
  end
72
83
 
73
- it "not default content_type" do
74
- body = [{:id=>"9K0",
75
- :method=>"websocket",
76
- :path=>"/api/v1/bar",
77
- :content_type=>"text/csv",
78
- :script=>"--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n\n",
79
- },
80
- {:id=>"B76",
81
- :method=>"websocket",
82
- :path=>"/api/v1/foo/{id}",
83
- :content_type=>"image/png",
84
- :script=> "--#ENDPOINT WEBSOCKET /api/v1/foo/{id} image/png\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n",
85
- }]
86
- stub_request(:get, @baseURI).
87
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
88
- 'Content-Type'=>'application/json'}).
89
- to_return(body: body.to_json)
84
+ it 'not default content_type' do
85
+ body = [
86
+ {
87
+ id: '9K0',
88
+ method: 'websocket',
89
+ path: '/api/v1/bar',
90
+ content_type: 'text/csv',
91
+ script: "--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n\n",
92
+ },
93
+ { id: 'B76',
94
+ method: 'websocket',
95
+ path: '/api/v1/foo/{id}',
96
+ content_type: 'image/png',
97
+ script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id} image/png\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
98
+ ]
99
+ stub_request(:get, @base_uri)
100
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
101
+ 'Content-Type' => 'application/json', })
102
+ .to_return(body: body.to_json)
90
103
 
91
104
  ret = @srv.list
92
105
  expect(ret).to eq(body)
93
106
  end
94
107
 
95
- it "mismatched content_type header" do
96
- body = [{:id=>"9K0",
97
- :method=>"websocket",
98
- :path=>"/api/v1/bar",
99
- :content_type=>"text/csv",
100
- :script=>"--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
101
- },
102
- {:id=>"B76",
103
- :method=>"websocket",
104
- :path=>"/api/v1/foo/{id}",
105
- :content_type=>"image/png",
106
- :script=> "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n",
107
- }]
108
- stub_request(:get, @baseURI).
109
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
110
- 'Content-Type'=>'application/json'}).
111
- to_return(body: body.to_json)
108
+ it 'mismatched content_type header' do
109
+ body = [
110
+ {
111
+ id: '9K0',
112
+ method: 'websocket',
113
+ path: '/api/v1/bar',
114
+ content_type: 'text/csv',
115
+ script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
116
+ },
117
+ { id: 'B76',
118
+ method: 'websocket',
119
+ path: '/api/v1/foo/{id}',
120
+ content_type: 'image/png',
121
+ script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
122
+ ]
123
+ stub_request(:get, @base_uri)
124
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
125
+ 'Content-Type' => 'application/json', })
126
+ .to_return(body: body.to_json)
112
127
 
113
128
  ret = @srv.list
114
129
  expect(ret).to eq(body)
115
130
  end
116
131
 
117
- it "returns empty content type" do
118
- body = [{:id=>"9K0",
119
- :method=>"websocket",
120
- :path=>"/api/v1/bar",
121
- :content_type=>"",
122
- :script=>"--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
123
- },
124
- {:id=>"B76",
125
- :method=>"websocket",
126
- :path=>"/api/v1/foo/{id}",
127
- :content_type=>"image/png",
128
- :script=> "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n",
129
- }]
130
- stub_request(:get, @baseURI).
131
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
132
- 'Content-Type'=>'application/json'}).
133
- to_return(body: body.to_json)
132
+ it 'returns empty content type' do
133
+ body = [
134
+ {
135
+ id: '9K0',
136
+ method: 'websocket',
137
+ path: '/api/v1/bar',
138
+ content_type: '',
139
+ script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
140
+ },
141
+ { id: 'B76',
142
+ method: 'websocket',
143
+ path: '/api/v1/foo/{id}',
144
+ content_type: 'image/png',
145
+ script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
146
+ ]
147
+ stub_request(:get, @base_uri)
148
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
149
+ 'Content-Type' => 'application/json', })
150
+ .to_return(body: body.to_json)
134
151
  ret = @srv.list
135
- body.first.merge!({:content_type=>'application/json'})
152
+ body.first[:content_type] = 'application/json'
136
153
  expect(ret).to eq(body)
137
154
  end
138
155
 
139
- it "returns missing content type" do
140
- body = [{:id=>"9K0",
141
- :method=>"websocket",
142
- :path=>"/api/v1/bar",
143
- :script=>"--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
144
- },
145
- {:id=>"B76",
146
- :method=>"websocket",
147
- :path=>"/api/v1/foo/{id}",
148
- :content_type=>"image/png",
149
- :script=> "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n",
150
- }]
151
- stub_request(:get, @baseURI).
152
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
153
- 'Content-Type'=>'application/json'}).
154
- to_return(body: body.to_json)
156
+ it 'returns missing content type' do
157
+ body = [
158
+ {
159
+ id: '9K0',
160
+ method: 'websocket',
161
+ path: '/api/v1/bar',
162
+ script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n\n",
163
+ },
164
+ { id: 'B76',
165
+ method: 'websocket',
166
+ path: '/api/v1/foo/{id}',
167
+ content_type: 'image/png',
168
+ script: "--#ENDPOINT WEBSOCKET /api/v1/foo/{id}\nresponse.message = \"HI\"\n\n-- BOB WAS HERE\n", },
169
+ ]
170
+ stub_request(:get, @base_uri)
171
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
172
+ 'Content-Type' => 'application/json', })
173
+ .to_return(body: body.to_json)
155
174
 
156
175
  ret = @srv.list
157
- body.first.merge!({:content_type=>'application/json'})
176
+ body.first[:content_type] = 'application/json'
158
177
  expect(ret).to eq(body)
159
178
  end
160
-
161
179
  end
162
180
 
163
-
164
- context "fetches" do
165
- it "fetches" do
166
- body = {:id=>"9K0",
167
- :method=>"websocket",
168
- :path=>"/api/v1/bar",
169
- :content_type=>"application/json",
170
- :script=>"--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
181
+ context 'fetches' do
182
+ it 'fetches' do
183
+ body = {
184
+ id: '9K0',
185
+ method: 'websocket',
186
+ path: '/api/v1/bar',
187
+ content_type: 'application/json',
188
+ script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
171
189
  }
172
- stub_request(:get, "#{@baseURI}/9K0").
173
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
174
- 'Content-Type'=>'application/json'}).
175
- to_return(body: body.to_json)
190
+ stub_request(:get, "#{@base_uri}/9K0")
191
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
192
+ 'Content-Type' => 'application/json', })
193
+ .to_return(body: body.to_json)
176
194
 
177
195
  ret = @srv.fetch('9K0')
178
196
  expect(ret).to eq(body[:script])
179
197
  end
180
198
 
181
- it "yields" do
182
- body = {:id=>"9K0",
183
- :method=>"websocket",
184
- :path=>"/api/v1/bar",
185
- :content_type=>"application/json",
186
- :script=>"--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
199
+ it 'yields' do
200
+ body = {
201
+ id: '9K0',
202
+ method: 'websocket',
203
+ path: '/api/v1/bar',
204
+ content_type: 'application/json',
205
+ script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
187
206
  }
188
- stub_request(:get, "#{@baseURI}/9K0").
189
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
190
- 'Content-Type'=>'application/json'}).
191
- to_return(body: body.to_json)
207
+ stub_request(:get, "#{@base_uri}/9K0")
208
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
209
+ 'Content-Type' => 'application/json', })
210
+ .to_return(body: body.to_json)
192
211
 
193
212
  ret = nil
194
213
  @srv.fetch('9K0') do |sc|
@@ -197,82 +216,88 @@ RSpec.describe MrMurano::Webservice::Endpoint do
197
216
  expect(ret).to eq(body[:script])
198
217
  end
199
218
 
200
- it "missing headers" do
201
- body = {:id=>"9K0",
202
- :method=>"websocket",
203
- :path=>"/api/v1/bar",
204
- :content_type=>"application/json",
205
- :script=>"response.message = \"HI\"\n",
219
+ it 'missing headers' do
220
+ body = {
221
+ id: '9K0',
222
+ method: 'websocket',
223
+ path: '/api/v1/bar',
224
+ content_type: 'application/json',
225
+ script: "response.message = \"HI\"\n",
206
226
  }
207
- stub_request(:get, "#{@baseURI}/9K0").
208
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
209
- 'Content-Type'=>'application/json'}).
210
- to_return(body: body.to_json)
227
+ stub_request(:get, "#{@base_uri}/9K0")
228
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
229
+ 'Content-Type' => 'application/json', })
230
+ .to_return(body: body.to_json)
211
231
 
212
232
  ret = @srv.fetch('9K0')
213
233
  expect(ret).to eq("--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n")
214
234
  end
215
235
 
216
- it "not default content_type" do
217
- body = {:id=>"9K0",
218
- :method=>"websocket",
219
- :path=>"/api/v1/bar",
220
- :content_type=>"text/csv",
221
- :script=>"--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n",
236
+ it 'not default content_type' do
237
+ body = {
238
+ id: '9K0',
239
+ method: 'websocket',
240
+ path: '/api/v1/bar',
241
+ content_type: 'text/csv',
242
+ script: "--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n",
222
243
  }
223
- stub_request(:get, "#{@baseURI}/9K0").
224
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
225
- 'Content-Type'=>'application/json'}).
226
- to_return(body: body.to_json)
244
+ stub_request(:get, "#{@base_uri}/9K0")
245
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
246
+ 'Content-Type' => 'application/json', })
247
+ .to_return(body: body.to_json)
227
248
 
228
249
  ret = @srv.fetch('9K0')
229
250
  expect(ret).to eq(body[:script])
230
251
  end
231
252
 
232
- it "missing content_type header" do
233
- body = {:id=>"9K0",
234
- :method=>"websocket",
235
- :path=>"/api/v1/bar",
236
- :content_type=>"text/csv",
237
- :script=>"--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
253
+ it 'missing content_type header' do
254
+ body = {
255
+ id: '9K0',
256
+ method: 'websocket',
257
+ path: '/api/v1/bar',
258
+ content_type: 'text/csv',
259
+ script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
238
260
  }
239
- stub_request(:get, "#{@baseURI}/9K0").
240
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
241
- 'Content-Type'=>'application/json'}).
242
- to_return(body: body.to_json)
261
+ stub_request(:get, "#{@base_uri}/9K0")
262
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
263
+ 'Content-Type' => 'application/json', })
264
+ .to_return(body: body.to_json)
243
265
 
244
266
  ret = @srv.fetch('9K0')
245
267
  expect(ret).to eq("--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n")
246
268
  end
247
269
 
248
- it "mismatched content_type header" do
249
- body = {:id=>"9K0",
250
- :method=>"websocket",
251
- :path=>"/api/v1/bar",
252
- :content_type=>"text/csv",
253
- :script=>"--#ENDPOINT WEBSOCKET /api/v1/bar image/png\nresponse.message = \"HI\"\n",
270
+ it 'mismatched content_type header' do
271
+ body = {
272
+ id: '9K0',
273
+ method: 'websocket',
274
+ path: '/api/v1/bar',
275
+ content_type: 'text/csv',
276
+ script: "--#ENDPOINT WEBSOCKET /api/v1/bar image/png\nresponse.message = \"HI\"\n",
254
277
  }
255
- stub_request(:get, "#{@baseURI}/9K0").
256
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
257
- 'Content-Type'=>'application/json'}).
258
- to_return(body: body.to_json)
278
+ stub_request(:get, "#{@base_uri}/9K0")
279
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
280
+ 'Content-Type' => 'application/json', })
281
+ .to_return(body: body.to_json)
259
282
 
260
283
  ret = @srv.fetch('9K0')
261
- expect(ret).to eq("--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n")
284
+ expect(ret).to eq(
285
+ "--#ENDPOINT WEBSOCKET /api/v1/bar text/csv\nresponse.message = \"HI\"\n"
286
+ )
262
287
  end
263
288
  end
264
289
 
265
- it "removes" do
266
- stub_request(:delete, "#{@baseURI}/9K0").
267
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
268
- 'Content-Type'=>'application/json'}).
269
- to_return(body: "")
290
+ it 'removes' do
291
+ stub_request(:delete, "#{@base_uri}/9K0")
292
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
293
+ 'Content-Type' => 'application/json', })
294
+ .to_return(body: '')
270
295
 
271
296
  ret = @srv.remove('9K0')
272
297
  expect(ret).to eq({})
273
298
  end
274
299
 
275
- context "uploads" do
300
+ context 'uploads' do
276
301
  around(:example) do |ex|
277
302
  Tempfile.open('foo') do |tio|
278
303
  tio << %{-- lua code is here
@@ -286,228 +311,239 @@ RSpec.describe MrMurano::Webservice::Endpoint do
286
311
  end
287
312
  end
288
313
 
289
- it "over old version" do
290
- stub_request(:put, "#{@baseURI}/9K0").
291
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
292
- 'Content-Type'=>'application/json'}).
293
- to_return(body: "")
314
+ it 'over old version' do
315
+ stub_request(:put, "#{@base_uri}/9K0")
316
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
317
+ 'Content-Type' => 'application/json', })
318
+ .to_return(body: '')
294
319
 
295
320
  ret = @srv.upload(@tio_.path,
296
- MrMurano::Webservice::Endpoint::RouteItem.new(
297
- :id=>"9K0",
298
- :method=>"websocket",
299
- :path=>"/api/v1/bar",
300
- :content_type=>"application/json",
301
- ), true)
321
+ MrMurano::Webservice::Endpoint::RouteItem.new(
322
+ id: '9K0',
323
+ method: 'websocket',
324
+ path: '/api/v1/bar',
325
+ content_type: 'application/json',
326
+ ), true)
302
327
  expect(ret)
303
328
  end
304
329
 
305
- it "when nothing is there" do
306
- stub_request(:put, "#{@baseURI}/9K0").
307
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
308
- 'Content-Type'=>'application/json'}).
309
- to_return(status: 404)
310
- stub_request(:post, "#{@baseURI}/").
311
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
312
- 'Content-Type'=>'application/json'}).
313
- to_return(body: "")
330
+ it 'when nothing is there' do
331
+ stub_request(:put, "#{@base_uri}/9K0")
332
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
333
+ 'Content-Type' => 'application/json', })
334
+ .to_return(status: 404)
335
+ stub_request(:post, "#{@base_uri}/")
336
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
337
+ 'Content-Type' => 'application/json', })
338
+ .to_return(body: '')
314
339
 
315
- ret = @srv.upload(@tio_.path,
340
+ ret = @srv.upload(
341
+ @tio_.path,
316
342
  MrMurano::Webservice::Endpoint::RouteItem.new(
317
- :id=>"9K0",
318
- :method=>"websocket",
319
- :path=>"/api/v1/bar",
320
- :content_type=>"application/json",
321
- ), false)
343
+ id: '9K0',
344
+ method: 'websocket',
345
+ path: '/api/v1/bar',
346
+ content_type: 'application/json',
347
+ ), false
348
+ )
322
349
  expect(ret)
323
350
  end
324
351
 
325
- it "without an itemkey" do
326
- stub_request(:post, @baseURI).
327
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
328
- 'Content-Type'=>'application/json'}).
329
- to_return(body: "")
352
+ it 'without an itemkey' do
353
+ stub_request(:post, @base_uri)
354
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
355
+ 'Content-Type' => 'application/json', })
356
+ .to_return(body: '')
330
357
 
331
- ret = @srv.upload(@tio_.path,
358
+ ret = @srv.upload(
359
+ @tio_.path,
332
360
  MrMurano::Webservice::Endpoint::RouteItem.new(
333
- :method=>"websocket",
334
- :path=>"/api/v1/bar",
335
- :content_type=>"application/json",
336
- ), false)
361
+ method: 'websocket',
362
+ path: '/api/v1/bar',
363
+ content_type: 'application/json',
364
+ ), false
365
+ )
337
366
  expect(ret)
338
367
  end
339
368
 
340
- it "Handles others errors" do
341
- stub_request(:put, "#{@baseURI}/9K0").
342
- with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
343
- 'Content-Type'=>'application/json'}).
344
- to_return(status: 502, body: "{}")
369
+ it 'Handles others errors' do
370
+ stub_request(:put, "#{@base_uri}/9K0")
371
+ .with(headers: { 'Authorization' => 'token TTTTTTTTTT',
372
+ 'Content-Type' => 'application/json', })
373
+ .to_return(status: 502, body: '{}')
345
374
 
346
375
  expect(@srv).to receive(:error).and_return(nil)
347
- ret = @srv.upload(@tio_.path,
376
+ ret = @srv.upload(
377
+ @tio_.path,
348
378
  MrMurano::Webservice::Endpoint::RouteItem.new(
349
- :id=>"9K0",
350
- :method=>"websocket",
351
- :path=>"/api/v1/bar",
352
- :content_type=>"application/json",
353
- ), true)
379
+ id: '9K0',
380
+ method: 'websocket',
381
+ path: '/api/v1/bar',
382
+ content_type: 'application/json',
383
+ ), true
384
+ )
354
385
  expect(ret)
355
386
  end
356
387
  end
357
388
 
358
- context "compares" do
389
+ context 'compares' do
359
390
  before(:example) do
360
- @iA = {:id=>"9K0",
361
- :method=>"websocket",
362
- :path=>"/api/v1/bar",
363
- :content_type=>"application/json",
364
- :script=>"--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
365
- }
366
- @iB = {:id=>"9K0",
367
- :method=>"websocket",
368
- :path=>"/api/v1/bar",
369
- :content_type=>"application/json",
370
- :script=>"--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
371
- }
372
- end
373
- it "both have script" do
374
- ret = @srv.docmp(@iA, @iB)
391
+ @i_a = {
392
+ id: '9K0',
393
+ method: 'websocket',
394
+ path: '/api/v1/bar',
395
+ content_type: 'application/json',
396
+ script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
397
+ }
398
+ @i_b = {
399
+ id: '9K0',
400
+ method: 'websocket',
401
+ path: '/api/v1/bar',
402
+ content_type: 'application/json',
403
+ script: "--#ENDPOINT WEBSOCKET /api/v1/bar\nresponse.message = \"HI\"\n",
404
+ }
405
+ end
406
+ it 'both have script' do
407
+ ret = @srv.docmp(@i_a, @i_b)
375
408
  expect(ret).to eq(false)
376
409
  end
377
410
 
378
- it "iA is a local file" do
411
+ it 'i_a is a local file' do
379
412
  Tempfile.open('foo') do |tio|
380
- tio << @iA[:script]
413
+ tio << @i_a[:script]
381
414
  tio.close
382
- iA = @iA.reject{|k,v| k == :script}.merge({
383
- :local_path => Pathname.new(tio.path)
384
- })
385
- ret = @srv.docmp(iA, @iB)
415
+ i_a = @i_a.reject do |k, _v|
416
+ k == :script
417
+ end.merge(local_path: Pathname.new(tio.path))
418
+ ret = @srv.docmp(i_a, @i_b)
386
419
  expect(ret).to eq(false)
387
420
 
388
- iB = @iB.dup
389
- iB[:script] = "BOB"
390
- ret = @srv.docmp(iA, iB)
421
+ i_b = @i_b.dup
422
+ i_b[:script] = 'BOB'
423
+ ret = @srv.docmp(i_a, i_b)
391
424
  expect(ret).to eq(true)
392
425
  end
393
426
  end
394
427
 
395
- it "iB is a local file" do
428
+ it 'i_b is a local file' do
396
429
  Tempfile.open('foo') do |tio|
397
- tio << @iB[:script]
430
+ tio << @i_b[:script]
398
431
  tio.close
399
- iB = @iB.reject{|k,v| k == :script}.merge({
400
- :local_path => Pathname.new(tio.path)
401
- })
402
- ret = @srv.docmp(@iA, iB)
432
+ i_b = @i_b.reject do |k, _v|
433
+ k == :script
434
+ end.merge(local_path: Pathname.new(tio.path))
435
+ ret = @srv.docmp(@i_a, i_b)
403
436
  expect(ret).to eq(false)
404
437
 
405
- iA = @iB.dup
406
- iA[:script] = "BOB"
407
- ret = @srv.docmp(iA, iB)
438
+ i_a = @i_b.dup
439
+ i_a[:script] = 'BOB'
440
+ ret = @srv.docmp(i_a, i_b)
408
441
  expect(ret).to eq(true)
409
442
  end
410
443
  end
411
444
  end
412
445
 
413
- context "Lookup functions" do
414
- it "gets local name" do
415
- ret = @srv.tolocalname({ :method=>'get', :path=>'one/two/three' }, nil)
446
+ context 'Lookup functions' do
447
+ it 'gets local name' do
448
+ ret = @srv.tolocalname({ method: 'get', path: 'one/two/three' }, nil)
416
449
  expect(ret).to eq('one-two-three.get.lua')
417
450
  end
418
451
 
419
- it "gets synckey" do
420
- ret = @srv.synckey({ :method=>'get', :path=>'one/two/three' })
421
- expect(ret).to eq("GET_one/two/three")
452
+ it 'gets synckey' do
453
+ ret = @srv.synckey(method: 'get', path: 'one/two/three')
454
+ expect(ret).to eq('GET_one/two/three')
422
455
  end
423
456
 
424
- it "gets searchfor" do
425
- $cfg['endpoints.searchFor'] = %{a b c/**/d/*.bob}
457
+ it 'gets searchfor' do
458
+ $cfg['endpoints.searchFor'] = %(a b c/**/d/*.bob)
426
459
  ret = @srv.searchFor
427
- expect(ret).to eq(["a", "b", "c/**/d/*.bob"])
460
+ expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
428
461
  end
429
462
 
430
- it "gets ignoring" do
431
- $cfg['endpoints.ignoring'] = %{a b c/**/d/*.bob}
463
+ it 'gets ignoring' do
464
+ $cfg['endpoints.ignoring'] = %(a b c/**/d/*.bob)
432
465
  ret = @srv.ignoring
433
- expect(ret).to eq(["a", "b", "c/**/d/*.bob"])
466
+ expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
434
467
  end
435
468
  end
436
469
 
437
- context "to_remote_item" do
438
- it "reads one" do
439
- Tempfile.open("foo") do |tio|
440
- tio << %{--#ENDPOINT GET /one/two
470
+ context 'to_remote_item' do
471
+ it 'reads one' do
472
+ Tempfile.open('foo') do |tio|
473
+ tio << %(--#ENDPOINT GET /one/two
441
474
  return request
442
475
 
443
- }.gsub(/^\s+/,'')
476
+ ).gsub(/^\s+/, '')
444
477
  tio.close
445
478
 
446
479
  ret = @srv.to_remote_item(nil, tio.path)
447
- e = {:method=>"GET",
448
- :path=>"/one/two",
449
- :content_type=>"application/json",
450
- :local_path=>Pathname.new(tio.path),
451
- :line=>0,
452
- :script=>"--#ENDPOINT GET /one/two\nreturn request\n",
453
- :line_end=>2
480
+ e = {
481
+ method: 'GET',
482
+ path: '/one/two',
483
+ content_type: 'application/json',
484
+ local_path: Pathname.new(tio.path),
485
+ line: 0,
486
+ script: "--#ENDPOINT GET /one/two\nreturn request\n",
487
+ line_end: 2,
454
488
  }
455
489
  expect(ret).to eq([e])
456
490
  end
457
491
  end
458
492
 
459
- it "reads many" do
460
- Tempfile.open("foo") do |tio|
461
- tio << %{--#ENDPOINT GET /one/two
493
+ it 'reads many' do
494
+ Tempfile.open('foo') do |tio|
495
+ tio << %(--#ENDPOINT GET /one/two
462
496
  return request
463
497
  --#ENDPOINT PUT /one/two
464
498
  return request
465
499
 
466
500
  --#ENDPOINT DELETE /three/two
467
501
  return request
468
- }.gsub(/^\s+/,'')
502
+ ).gsub(/^\s+/, '')
469
503
  tio.close
470
504
 
471
505
  ret = @srv.to_remote_item(nil, tio.path)
472
506
 
473
- expect(ret).to eq([
474
- {
475
- :method=>"GET",
476
- :path=>"/one/two",
477
- :content_type=>"application/json",
478
- :local_path=>Pathname.new(tio.path),
479
- :line=>0,
480
- :script=>"--#ENDPOINT GET /one/two\nreturn request\n",
481
- :line_end=>2
482
- },
483
- {
484
- :method=>"PUT",
485
- :path=>"/one/two",
486
- :content_type=>"application/json",
487
- :local_path=>Pathname.new(tio.path),
488
- :line=>2,
489
- :script=>"--#ENDPOINT PUT /one/two\nreturn request\n",
490
- :line_end=>4
491
- },
492
- {
493
- :method=>"DELETE",
494
- :path=>"/three/two",
495
- :content_type=>"application/json",
496
- :local_path=>Pathname.new(tio.path),
497
- :line=>4,
498
- :script=>"--#ENDPOINT DELETE /three/two\nreturn request\n",
499
- :line_end=>6
500
- }
501
- ])
507
+ expect(ret).to eq(
508
+ [
509
+ {
510
+ method: 'GET',
511
+ path: '/one/two',
512
+ content_type: 'application/json',
513
+ local_path: Pathname.new(tio.path),
514
+ line: 0,
515
+ script: "--#ENDPOINT GET /one/two\nreturn request\n",
516
+ line_end: 2,
517
+ },
518
+ {
519
+ method: 'PUT',
520
+ path: '/one/two',
521
+ content_type: 'application/json',
522
+ local_path: Pathname.new(tio.path),
523
+ line: 2,
524
+ script: "--#ENDPOINT PUT /one/two\nreturn request\n",
525
+ line_end: 4,
526
+ },
527
+ {
528
+ method: 'DELETE',
529
+ path: '/three/two',
530
+ content_type: 'application/json',
531
+ local_path: Pathname.new(tio.path),
532
+ line: 4,
533
+ script: "--#ENDPOINT DELETE /three/two\nreturn request\n",
534
+ line_end: 6,
535
+ },
536
+ ]
537
+ )
502
538
  end
503
539
  end
504
540
 
505
- it "skips all when no header found" do
506
- Tempfile.open("foo") do |tio|
507
- tio << %{
541
+ it 'skips all when no header found' do
542
+ Tempfile.open('foo') do |tio|
543
+ tio << %(
508
544
  return request
509
545
 
510
- }.gsub(/^\s+/,'')
546
+ ).gsub(/^\s+/, '')
511
547
  tio.close
512
548
 
513
549
  ret = @srv.to_remote_item(nil, tio.path)
@@ -515,70 +551,71 @@ RSpec.describe MrMurano::Webservice::Endpoint do
515
551
  end
516
552
  end
517
553
 
518
- it "skips junk at begining" do
519
- Tempfile.open("foo") do |tio|
520
- tio << %{
554
+ it 'skips junk at begining' do
555
+ Tempfile.open('foo') do |tio|
556
+ tio << %(
521
557
  return flex
522
558
  --#ENDPOINT GET /one/two
523
559
  return request
524
560
 
525
- }.gsub(/^\s+/,'')
561
+ ).gsub(/^\s+/, '')
526
562
  tio.close
527
563
 
528
564
  ret = @srv.to_remote_item(nil, tio.path)
529
- e = {:method=>"GET",
530
- :path=>"/one/two",
531
- :content_type=>"application/json",
532
- :local_path=>Pathname.new(tio.path),
533
- :line=>1,
534
- :script=>"--#ENDPOINT GET /one/two\nreturn request\n",
535
- :line_end=>3
565
+ e = {
566
+ method: 'GET',
567
+ path: '/one/two',
568
+ content_type: 'application/json',
569
+ local_path: Pathname.new(tio.path),
570
+ line: 1,
571
+ script: "--#ENDPOINT GET /one/two\nreturn request\n",
572
+ line_end: 3,
536
573
  }
537
574
  expect(ret).to eq([e])
538
575
  end
539
576
  end
540
577
  end
541
578
 
542
- context "Matching" do
579
+ context 'Matching' do
543
580
  before(:example) do
544
581
  @an_item = {
545
- :method=>'get',
546
- :path=>'/api/read/stuff',
547
- :local_path=>Pathname.new('a/relative/path.lua'),
582
+ method: 'get',
583
+ path: '/api/read/stuff',
584
+ local_path: Pathname.new('a/relative/path.lua'),
548
585
  }
549
586
  end
550
- context "method" do
551
- it "any path" do
587
+ context 'method' do
588
+ it 'any path' do
552
589
  ret = @srv.match(@an_item, '#get#')
553
590
  expect(ret).to be true
554
591
  ret = @srv.match(@an_item, '#post#')
555
592
  expect(ret).to be false
556
593
  end
557
- it "exact path" do
594
+ it 'exact path' do
558
595
  ret = @srv.match(@an_item, '#get#/api/read/stuff')
559
596
  expect(ret).to be true
560
597
  ret = @srv.match(@an_item, '#post#/api/read/stuff')
561
598
  expect(ret).to be false
562
599
  end
563
- it "path glob" do
600
+ it 'path glob' do
564
601
  ret = @srv.match(@an_item, '#get#/api/*/stuff')
565
602
  expect(ret).to be true
566
603
  ret = @srv.match(@an_item, '#get#/**/stuff')
567
604
  expect(ret).to be true
568
605
  end
569
606
  end
570
- context "any method" do
571
- it "any path" do
607
+ context 'any method' do
608
+ it 'any path' do
572
609
  ret = @srv.match(@an_item, '##')
573
610
  expect(ret).to be true
574
611
  end
575
- it "exact path" do
612
+ it 'exact path' do
576
613
  ret = @srv.match(@an_item, '##/api/read/stuff')
577
614
  expect(ret).to be true
578
615
  ret = @srv.match(@an_item, '##/api/do/stuff')
579
616
  expect(ret).to be false
580
617
  end
581
- it "path glob" do
618
+ it 'path glob' do
582
619
  ret = @srv.match(@an_item, '##/api/*/stuff')
583
620
  expect(ret).to be true
584
621
  ret = @srv.match(@an_item, '##/**/stuff')
@@ -586,6 +623,5 @@ RSpec.describe MrMurano::Webservice::Endpoint do
586
623
  end
587
624
  end
588
625
  end
589
-
590
626
  end
591
- # vim: set ai et sw=2 ts=2 :
627
+