MuranoCLI 3.2.1.pre.beta.6 → 3.2.1.pre.beta.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +10 -0
  3. data/MuranoCLI.gemspec +37 -6
  4. data/Rakefile +38 -11
  5. data/lib/MrMurano/commands/business.rb +0 -4
  6. data/lib/MrMurano/version.rb +1 -1
  7. metadata +2 -251
  8. data/dockers/Dockerfile.2.2.9 +0 -40
  9. data/dockers/Dockerfile.2.3.6 +0 -40
  10. data/dockers/Dockerfile.2.4.3 +0 -40
  11. data/dockers/Dockerfile.2.5.0 +0 -40
  12. data/dockers/Dockerfile.GemRelease +0 -49
  13. data/dockers/Dockerfile.m4 +0 -122
  14. data/dockers/README.rst +0 -362
  15. data/dockers/RELEASE.rst +0 -135
  16. data/dockers/docker-test.sh +0 -163
  17. data/dockers/gem-release.sh +0 -4
  18. data/docs/basic_example.rst +0 -436
  19. data/docs/ci/.trustme.plugin +0 -140
  20. data/docs/ci/.trustme.sh +0 -516
  21. data/docs/ci/.trustme.vim +0 -55
  22. data/docs/completions/murano_completion-bash +0 -4484
  23. data/docs/demo.md +0 -109
  24. data/docs/develop.rst +0 -392
  25. data/docs/release.rst +0 -295
  26. data/spec/Account-Passwords_spec.rb +0 -245
  27. data/spec/Account_spec.rb +0 -256
  28. data/spec/Business_spec.rb +0 -307
  29. data/spec/ConfigFile_spec.rb +0 -55
  30. data/spec/ConfigMigrate_spec.rb +0 -108
  31. data/spec/Config_spec.rb +0 -440
  32. data/spec/Content_spec.rb +0 -422
  33. data/spec/GatewayBase_spec.rb +0 -65
  34. data/spec/GatewayDevice_spec.rb +0 -403
  35. data/spec/GatewayResource_spec.rb +0 -283
  36. data/spec/GatewaySettings_spec.rb +0 -130
  37. data/spec/HttpAuthed_spec.rb +0 -87
  38. data/spec/Http_spec.rb +0 -220
  39. data/spec/MakePretties_spec.rb +0 -127
  40. data/spec/Mock_spec.rb +0 -62
  41. data/spec/ProjectFile_spec.rb +0 -381
  42. data/spec/Setting_spec.rb +0 -120
  43. data/spec/Solution-ServiceConfig_spec.rb +0 -272
  44. data/spec/Solution-ServiceEventHandler_spec.rb +0 -442
  45. data/spec/Solution-ServiceModules_spec.rb +0 -562
  46. data/spec/Solution-UsersRoles_spec.rb +0 -269
  47. data/spec/Solution_spec.rb +0 -140
  48. data/spec/SyncRoot_spec.rb +0 -111
  49. data/spec/SyncUpDown_spec.rb +0 -868
  50. data/spec/Verbosing_spec.rb +0 -332
  51. data/spec/Webservice-Cors_spec.rb +0 -225
  52. data/spec/Webservice-Endpoint_spec.rb +0 -650
  53. data/spec/Webservice-File_spec.rb +0 -282
  54. data/spec/Webservice-Setting_spec.rb +0 -105
  55. data/spec/_workspace.rb +0 -43
  56. data/spec/cmd_business_spec.rb +0 -64
  57. data/spec/cmd_common.rb +0 -507
  58. data/spec/cmd_config_spec.rb +0 -73
  59. data/spec/cmd_content_spec.rb +0 -109
  60. data/spec/cmd_cors_spec.rb +0 -54
  61. data/spec/cmd_device_spec.rb +0 -130
  62. data/spec/cmd_domain_spec.rb +0 -62
  63. data/spec/cmd_element_spec.rb +0 -401
  64. data/spec/cmd_exchange_spec.rb +0 -114
  65. data/spec/cmd_help_spec.rb +0 -72
  66. data/spec/cmd_init_spec.rb +0 -475
  67. data/spec/cmd_keystore_spec.rb +0 -97
  68. data/spec/cmd_link_spec.rb +0 -105
  69. data/spec/cmd_logs_spec.rb +0 -162
  70. data/spec/cmd_password_spec.rb +0 -64
  71. data/spec/cmd_setting_application_spec.rb +0 -300
  72. data/spec/cmd_setting_product_spec.rb +0 -246
  73. data/spec/cmd_status_spec.rb +0 -300
  74. data/spec/cmd_syncdown_application_spec.rb +0 -128
  75. data/spec/cmd_syncdown_both_spec.rb +0 -178
  76. data/spec/cmd_syncdown_unit_spec.rb +0 -861
  77. data/spec/cmd_syncup_spec.rb +0 -148
  78. data/spec/cmd_token_spec.rb +0 -53
  79. data/spec/cmd_usage_spec.rb +0 -79
  80. data/spec/dry_run_formatter.rb +0 -28
  81. data/spec/fixtures/.mrmuranorc +0 -9
  82. data/spec/fixtures/ProjectFiles/invalid.yaml +0 -9
  83. data/spec/fixtures/ProjectFiles/only_meta.yaml +0 -24
  84. data/spec/fixtures/ProjectFiles/with_routes.yaml +0 -27
  85. data/spec/fixtures/SolutionFiles/0.2.0.json +0 -20
  86. data/spec/fixtures/SolutionFiles/0.2.0_invalid.json +0 -18
  87. data/spec/fixtures/SolutionFiles/0.2.json +0 -21
  88. data/spec/fixtures/SolutionFiles/0.3.0.json +0 -20
  89. data/spec/fixtures/SolutionFiles/0.3.0_invalid.json +0 -19
  90. data/spec/fixtures/SolutionFiles/0.3.json +0 -20
  91. data/spec/fixtures/SolutionFiles/basic.json +0 -20
  92. data/spec/fixtures/SolutionFiles/secret.json +0 -6
  93. data/spec/fixtures/configfile +0 -9
  94. data/spec/fixtures/dumped_config +0 -57
  95. data/spec/fixtures/exchange_element/element-show.json +0 -1
  96. data/spec/fixtures/exchange_element/swagger-mur-6407__10k.yaml +0 -282
  97. data/spec/fixtures/exchange_element/swagger-mur-6407__20k.yaml +0 -588
  98. data/spec/fixtures/gateway_resource_files/resources.notyaml +0 -12
  99. data/spec/fixtures/gateway_resource_files/resources.yaml +0 -13
  100. data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +0 -13
  101. data/spec/fixtures/mrmuranorc_deleted_bob +0 -6
  102. data/spec/fixtures/mrmuranorc_tool_bob +0 -3
  103. data/spec/fixtures/product_spec_files/example.exoline.spec.yaml +0 -116
  104. data/spec/fixtures/product_spec_files/example.murano.spec.yaml +0 -14
  105. data/spec/fixtures/product_spec_files/gwe.exoline.spec.yaml +0 -21
  106. data/spec/fixtures/product_spec_files/gwe.murano.spec.yaml +0 -16
  107. data/spec/fixtures/product_spec_files/lightbulb-no-state.yaml +0 -11
  108. data/spec/fixtures/product_spec_files/lightbulb.yaml +0 -21
  109. data/spec/fixtures/roles-three.yaml +0 -11
  110. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 0.webmock +0 -98
  111. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 1.webmock +0 -98
  112. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value No.webmock +0 -98
  113. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value Yes.webmock +0 -98
  114. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value bob.webmock +0 -72
  115. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value false.webmock +0 -98
  116. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value off.webmock +0 -98
  117. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on STDIN.webmock +0 -98
  118. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on.webmock +0 -98
  119. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value true.webmock +0 -98
  120. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob with STDIN.webmock +0 -98
  121. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob.webmock +0 -98
  122. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) an array.webmock +0 -98
  123. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) appends an array.webmock +0 -98
  124. data/spec/fixtures/snapshots/murano application setting reads Webservice.cors to a file.webmock +0 -72
  125. data/spec/fixtures/snapshots/murano application setting reads Webservice.cors.webmock +0 -72
  126. data/spec/fixtures/snapshots/murano business list as json.webmock +0 -27
  127. data/spec/fixtures/snapshots/murano business list as table.webmock +0 -27
  128. data/spec/fixtures/snapshots/murano business list fewer fields.webmock +0 -27
  129. data/spec/fixtures/snapshots/murano business list only ids.webmock +0 -27
  130. data/spec/fixtures/snapshots/murano business list output to file.webmock +0 -27
  131. data/spec/fixtures/snapshots/murano business without project help.webmock +0 -9
  132. data/spec/fixtures/snapshots/murano config Needs a key.webmock +0 -9
  133. data/spec/fixtures/snapshots/murano config Reads a key.webmock +0 -9
  134. data/spec/fixtures/snapshots/murano config Removes a key.webmock +0 -9
  135. data/spec/fixtures/snapshots/murano config Sets a key.webmock +0 -9
  136. data/spec/fixtures/snapshots/murano config Sets a user key.webmock +0 -9
  137. data/spec/fixtures/snapshots/murano content life cycle.webmock +0 -144
  138. data/spec/fixtures/snapshots/murano cors sets CORS.webmock +0 -78
  139. data/spec/fixtures/snapshots/murano cors show CORS.webmock +0 -64
  140. data/spec/fixtures/snapshots/murano device activates.webmock +0 -86
  141. data/spec/fixtures/snapshots/murano device enables a batch.webmock +0 -76
  142. data/spec/fixtures/snapshots/murano device enables and lists.webmock +0 -78
  143. data/spec/fixtures/snapshots/murano device writes and reads.webmock +0 -136
  144. data/spec/fixtures/snapshots/murano domain show domain.webmock +0 -101
  145. data/spec/fixtures/snapshots/murano element edit unknown as unknown element.webmock +0 -43
  146. data/spec/fixtures/snapshots/murano element show --help.webmock +0 -9
  147. data/spec/fixtures/snapshots/murano element show as csv.webmock +0 -43
  148. data/spec/fixtures/snapshots/murano element show as default-table.webmock +0 -43
  149. data/spec/fixtures/snapshots/murano element show as json.webmock +0 -43
  150. data/spec/fixtures/snapshots/murano element show as table truncate.webmock +0 -43
  151. data/spec/fixtures/snapshots/murano element show as table wrap.webmock +0 -43
  152. data/spec/fixtures/snapshots/murano element show as yaml.webmock +0 -43
  153. data/spec/fixtures/snapshots/murano element show using ambiguous name.webmock +0 -43
  154. data/spec/fixtures/snapshots/murano element without project usage.webmock +0 -9
  155. data/spec/fixtures/snapshots/murano exchange with project list as json.webmock +0 -59
  156. data/spec/fixtures/snapshots/murano exchange with project list as table.webmock +0 -59
  157. data/spec/fixtures/snapshots/murano exchange with project list fewer fields.webmock +0 -59
  158. data/spec/fixtures/snapshots/murano exchange with project list only ids.webmock +0 -59
  159. data/spec/fixtures/snapshots/murano exchange with project list output to file.webmock +0 -59
  160. data/spec/fixtures/snapshots/murano exchange with project list purchase is already added ID.webmock +0 -83
  161. data/spec/fixtures/snapshots/murano exchange with project list purchase is ambiguous name.webmock +0 -59
  162. data/spec/fixtures/snapshots/murano exchange without project help.webmock +0 -9
  163. data/spec/fixtures/snapshots/murano help using commander as --help.webmock +0 -9
  164. data/spec/fixtures/snapshots/murano help using commander no args.webmock +0 -9
  165. data/spec/fixtures/snapshots/murano help using subshell no args.webmock +0 -9
  166. data/spec/fixtures/snapshots/murano help using subshell with --help.webmock +0 -9
  167. data/spec/fixtures/snapshots/murano init Won't init in HOME (gracefully).webmock +0 -9
  168. data/spec/fixtures/snapshots/murano init in empty directory with existing project.webmock +0 -201
  169. data/spec/fixtures/snapshots/murano init in empty directory without existing project.webmock +0 -193
  170. data/spec/fixtures/snapshots/murano init in existing project directory with ProjectFile.webmock +0 -213
  171. data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.2.0.webmock +0 -213
  172. data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.3.0.webmock +0 -213
  173. data/spec/fixtures/snapshots/murano init in existing project directory without ProjectFile.webmock +0 -213
  174. data/spec/fixtures/snapshots/murano keystore can call other commands.webmock +0 -108
  175. data/spec/fixtures/snapshots/murano keystore clearAll.webmock +0 -124
  176. data/spec/fixtures/snapshots/murano keystore deletes.webmock +0 -112
  177. data/spec/fixtures/snapshots/murano keystore gets.webmock +0 -96
  178. data/spec/fixtures/snapshots/murano keystore infos.webmock +0 -96
  179. data/spec/fixtures/snapshots/murano keystore lists.webmock +0 -96
  180. data/spec/fixtures/snapshots/murano link with project links and lists.webmock +0 -149
  181. data/spec/fixtures/snapshots/murano link with project unlinks.webmock +0 -165
  182. data/spec/fixtures/snapshots/murano link without project help.webmock +0 -9
  183. data/spec/fixtures/snapshots/murano link without project subshell vs inline using commander will not list.webmock +0 -27
  184. data/spec/fixtures/snapshots/murano link without project subshell vs inline using subshell will not list.webmock +0 -27
  185. data/spec/fixtures/snapshots/murano logs when project is setup tail log.webmock +0 -9
  186. data/spec/fixtures/snapshots/murano password Lists when no file.webmock +0 -9
  187. data/spec/fixtures/snapshots/murano password deletes a password.webmock +0 -9
  188. data/spec/fixtures/snapshots/murano password sets a password.webmock +0 -9
  189. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value on STDIN.webmock +0 -90
  190. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value.webmock +0 -90
  191. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value fiftyHalf.webmock +0 -64
  192. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value float 12.67.webmock +0 -90
  193. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value integer 12.webmock +0 -90
  194. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value on STDIN.webmock +0 -90
  195. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a string value.webmock +0 -90
  196. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) merges into a dictionary.webmock +0 -90
  197. data/spec/fixtures/snapshots/murano single sync without ProjectFile syncdown.webmock +0 -322
  198. data/spec/fixtures/snapshots/murano status with ProjectFile status.webmock +0 -153
  199. data/spec/fixtures/snapshots/murano status with Solutionfile 0.2.0 status.webmock +0 -153
  200. data/spec/fixtures/snapshots/murano status with Solutionfile 0.3.0 status.webmock +0 -153
  201. data/spec/fixtures/snapshots/murano status without ProjectFile matches file path.webmock +0 -153
  202. data/spec/fixtures/snapshots/murano status without ProjectFile matches route.webmock +0 -153
  203. data/spec/fixtures/snapshots/murano status without ProjectFile status.webmock +0 -153
  204. data/spec/fixtures/snapshots/murano syncdown stubbed without ProjectFile syncdown.webmock +0 -151
  205. data/spec/fixtures/snapshots/murano syncdown without ProjectFile syncdown.webmock +0 -479
  206. data/spec/fixtures/snapshots/murano syncup without ProjectFile syncup.webmock +0 -357
  207. data/spec/fixtures/snapshots/murano token with project list as table.webmock +0 -9
  208. data/spec/fixtures/snapshots/murano token without project help.webmock +0 -9
  209. data/spec/fixtures/snapshots/murano usage show usage.webmock +0 -93
  210. data/spec/fixtures/syncable_conflict/services/devdata.lua +0 -18
  211. data/spec/fixtures/syncable_conflict/services/timers.lua +0 -4
  212. data/spec/fixtures/syncable_content/assets/icon.png +0 -0
  213. data/spec/fixtures/syncable_content/assets/index.html +0 -0
  214. data/spec/fixtures/syncable_content/assets/js/script.js +0 -0
  215. data/spec/fixtures/syncable_content/modules/table_util.lua +0 -58
  216. data/spec/fixtures/syncable_content/routes/manyRoutes.lua +0 -11
  217. data/spec/fixtures/syncable_content/routes/singleRoute.lua +0 -5
  218. data/spec/fixtures/websocket/README.rst +0 -110
  219. data/spec/fixtures/websocket/logs_blather.rb +0 -27
  220. data/spec/fixtures/websocket/logs_faker.rb +0 -153
  221. data/spec/fixtures/websocket/simple_connection.rb +0 -45
  222. data/spec/fixtures/websocket/simple_options.rb +0 -77
  223. data/spec/fixtures/websocket/simple_server.rb +0 -69
  224. data/spec/fixtures/websocket/wss-echo.rb +0 -48
  225. data/spec/fixtures/websocket/wss-fake-logs.rb +0 -20
  226. data/spec/spec_helper.rb +0 -131
  227. data/spec/variegated_TruthyFalsey_spec.rb +0 -29
  228. data/spec/webmock_snapshot.rb +0 -296
@@ -1,332 +0,0 @@
1
- # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
- # License: PROPRIETARY. See LICENSE.txt.
3
- # frozen_string_literal: true
4
-
5
- # vim:tw=0:ts=2:sw=2:et:ai
6
- # Unauthorized copying of this file is strictly prohibited.
7
-
8
- require 'highline/import'
9
- require 'MrMurano/hash'
10
- require 'MrMurano/version'
11
- require 'MrMurano/verbosing'
12
- require 'MrMurano/Config'
13
- require '_workspace'
14
-
15
- class VTst
16
- include MrMurano::Verbose
17
- def initialize
18
- @token = nil
19
- end
20
- end
21
-
22
- RSpec.describe MrMurano::Verbose do
23
- include_context 'WORKSPACE'
24
-
25
- before(:example) do
26
- $cfg = MrMurano::Config.new
27
- $cfg.load
28
- @tst = VTst.new
29
- end
30
-
31
- it 'verboses' do
32
- $cfg['tool.verbose'] = true
33
- expect($terminal).to receive(:say).with('hello').once
34
- @tst.verbose 'hello'
35
- end
36
-
37
- it 'is quiet' do
38
- expect($terminal).to_not receive(:say)
39
- @tst.verbose 'hello'
40
- end
41
-
42
- it 'debugs' do
43
- $cfg['tool.debug'] = true
44
- expect($terminal).to receive(:say).with('hello').once
45
- @tst.debug 'hello'
46
- end
47
-
48
- it 'warns' do
49
- # 2017-12-14 (landonb): Not sure what changed, but this stopped working:
50
- # expect($stderr).to receive(:say).with("\e[33mhello\e[0m").once
51
- # @tst.warning 'hello'
52
- # I tried receive(:warn), and expect($terminal), but for naught.
53
- # Wrapping the call in the expect does the trick, though.
54
- expect { @tst.warning 'hello' }.to output("\e[33mhello\e[0m\n").to_stderr
55
- end
56
-
57
- it 'errors' do
58
- expect { @tst.error 'hello' }.to output("\e[31mhello\e[0m\n").to_stderr
59
- end
60
-
61
- context 'tabularize' do
62
- context 'generating CSV' do
63
- before(:example) do
64
- $cfg['tool.outformat'] = 'csv'
65
- end
66
-
67
- it 'takes Array' do
68
- stdout_saved = $stdout
69
- $stdout = StringIO.new
70
-
71
- @tst.tabularize([[1, 2, 3, 4, 5, 6, 7], [10, 20, 30, 40, 50, 60, 70]])
72
-
73
- expect($stdout.string).to eq(
74
- %("1","2","3","4","5","6","7"\n"10","20","30","40","50","60","70"\n)
75
- )
76
- $stdout = stdout_saved
77
- end
78
-
79
- it 'ducks to_a' do
80
- stdout_saved = $stdout
81
- $stdout = StringIO.new
82
-
83
- class DuckToATest
84
- def to_a
85
- [[12], [13]]
86
- end
87
- end
88
- @tst.tabularize(DuckToATest.new)
89
-
90
- expect($stdout.string).to eq(%("12"\n"13"\n))
91
- $stdout = stdout_saved
92
- end
93
-
94
- it 'ducks each' do
95
- stdout_saved = $stdout
96
- $stdout = StringIO.new
97
-
98
- class DuckEachTest
99
- def each
100
- yield [22]
101
- yield [44]
102
- end
103
- end
104
- @tst.tabularize(DuckEachTest.new)
105
-
106
- expect($stdout.string).to eq(%("22"\n"44"\n))
107
-
108
- $stdout = stdout_saved
109
- end
110
-
111
- context 'takes Hash' do
112
- before(:example) do
113
- @hsh = {
114
- headers: %i[one two three],
115
- title: 'Test output',
116
- rows: [[1, 2, 3], [10, 20, 30]],
117
- }
118
- @stdout_saved = $stdout
119
- $stdout = StringIO.new
120
- end
121
-
122
- after(:example) do
123
- $stdout = @stdout_saved
124
- end
125
-
126
- it 'has all' do
127
- @tst.tabularize(@hsh)
128
- expect($stdout.string).to eq(
129
- %("one","two","three"\n"1","2","3"\n"10","20","30"\n)
130
- )
131
- end
132
-
133
- it 'not quoted' do
134
- @tst.tabularize(@hsh, no_quotes: true)
135
- expect($stdout.string).to eq(
136
- %(one,two,three\n1,2,3\n10,20,30\n)
137
- )
138
- end
139
-
140
- it 'is empty' do
141
- @tst.tabularize({})
142
- expect($stdout.string).to eq("\n")
143
- end
144
-
145
- it 'no headers' do
146
- @hsh.delete :headers
147
- @tst.tabularize(@hsh)
148
- expect($stdout.string).to eq(%("1","2","3"\n"10","20","30"\n))
149
- end
150
-
151
- it 'no title' do
152
- @hsh.delete :title
153
- @tst.tabularize(@hsh)
154
- expect($stdout.string).to eq(%("one","two","three"\n"1","2","3"\n"10","20","30"\n))
155
- end
156
-
157
- it 'no rows' do
158
- @hsh.delete :rows
159
- @tst.tabularize(@hsh)
160
- expect($stdout.string).to eq(%("one","two","three"\n\n))
161
- end
162
- end
163
-
164
- it "errors if it can't" do
165
- stdout_saved = $stdout
166
- $stdout = StringIO.new
167
- # 2017-07-03: [lb] converted to class func.
168
- #expect(@tst).to receive(:error).with(MrMurano::Verbose::TABULARIZE_DATA_FORMAT_ERROR).once
169
- expect(MrMurano::Verbose).to receive(:error).with(MrMurano::Verbose::TABULARIZE_DATA_FORMAT_ERROR).once
170
- @tst.tabularize(12)
171
- $stdout = stdout_saved
172
- end
173
-
174
- it 'takes Array, to custom stream' do
175
- stdout_saved = $stdout
176
- $stdout = StringIO.new
177
- outer = StringIO.new
178
-
179
- @tst.tabularize([[1, 2, 3, 4, 5, 6, 7], [10, 20, 30, 40, 50, 60, 70]], outer)
180
-
181
- expect(outer.string).to eq(%("1","2","3","4","5","6","7"\n"10","20","30","40","50","60","70"\n))
182
- expect($stdout.string).to eq('')
183
- $stdout = stdout_saved
184
- end
185
- end
186
-
187
- context 'generating a table' do
188
- it 'takes Array' do
189
- stdout_saved = $stdout
190
- $stdout = StringIO.new
191
- @tst.tabularize([[1, 2, 3, 4, 5, 6, 7], [10, 20, 30, 40, 50, 60, 70]])
192
- expect($stdout.string).to eq(
193
- %(+----+----+----+----+----+----+----+
194
- | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
195
- | 10 | 20 | 30 | 40 | 50 | 60 | 70 |
196
- +----+----+----+----+----+----+----+
197
- ).gsub(/^\s+/, '')
198
- )
199
- $stdout = stdout_saved
200
- end
201
-
202
- context 'takes Hash' do
203
- before(:example) do
204
- @hsh = {
205
- headers: %i[one two three],
206
- title: 'Test output',
207
- rows: [[1, 2, 3], [10, 20, 30]],
208
- }
209
- @stdout_saved = $stdout
210
- $stdout = StringIO.new
211
- end
212
-
213
- after(:example) do
214
- $stdout = @stdout_saved
215
- end
216
-
217
- it 'has all' do
218
- @tst.tabularize(@hsh)
219
- expect($stdout.string).to eq(
220
- %(+-----+-----+-------+
221
- | Test output |
222
- +-----+-----+-------+
223
- | one | two | three |
224
- +-----+-----+-------+
225
- | 1 | 2 | 3 |
226
- | 10 | 20 | 30 |
227
- +-----+-----+-------+
228
- ).gsub(/^\s+/, '')
229
- )
230
- end
231
-
232
- it 'is empty' do
233
- @tst.tabularize({})
234
- expect($stdout.string).to eq("++\n++\n")
235
- end
236
-
237
- it 'no headers' do
238
- @hsh.delete :headers
239
- @tst.tabularize(@hsh)
240
- expect($stdout.string).to eq(
241
- %(+----+----+----+
242
- | Test output |
243
- +----+----+----+
244
- | 1 | 2 | 3 |
245
- | 10 | 20 | 30 |
246
- +----+----+----+
247
- ).gsub(/^\s+/, '')
248
- )
249
- end
250
-
251
- it 'no title' do
252
- @hsh.delete :title
253
- @tst.tabularize(@hsh)
254
- expect($stdout.string).to eq(
255
- %(+-----+-----+-------+
256
- | one | two | three |
257
- +-----+-----+-------+
258
- | 1 | 2 | 3 |
259
- | 10 | 20 | 30 |
260
- +-----+-----+-------+
261
- ).gsub(/^\s+/, '')
262
- )
263
- end
264
-
265
- it 'no rows' do
266
- @hsh.delete :rows
267
- @tst.tabularize(@hsh)
268
- expect($stdout.string).to eq(
269
- %(+-----+-----+-------+
270
- | Test output |
271
- +-----+-----+-------+
272
- | one | two | three |
273
- +-----+-----+-------+
274
- +-----+-----+-------+
275
- ).gsub(/^\s+/, '')
276
- )
277
- end
278
- end
279
- end
280
- end
281
-
282
- context 'outf' do
283
- before(:example) do
284
- @data = {
285
- one: 'three',
286
- two: [{ one: 3 }, { one: 4 }],
287
- }
288
- @stdout_saved = $stdout
289
- $stdout = StringIO.new
290
- end
291
-
292
- after(:example) do
293
- $stdout = @stdout_saved
294
- end
295
-
296
- it 'outputs yaml' do
297
- $cfg['tool.outformat'] = 'yaml'
298
- @tst.outf(@data)
299
- expect($stdout.string).to eq("---\none: three\ntwo:\n- one: 3\n- one: 4\n")
300
- end
301
-
302
- it 'outputs json' do
303
- $cfg['tool.outformat'] = 'json'
304
- @tst.outf(@data)
305
- expect($stdout.string).to eq("{\"one\":\"three\",\"two\":[{\"one\":3},{\"one\":4}]}\n")
306
- end
307
-
308
- it 'outputs ruby' do
309
- $cfg['tool.outformat'] = 'pp'
310
- @tst.outf(@data)
311
- expect($stdout.string).to eq("{:one=>\"three\", :two=>[{:one=>3}, {:one=>4}]}\n")
312
- end
313
-
314
- it 'outputs as String' do
315
- @tst.outf(@data)
316
- expect($stdout.string).to eq("{:one=>\"three\", :two=>[{:one=>3}, {:one=>4}]}\n")
317
- end
318
-
319
- it 'outputs as Array' do
320
- @tst.outf([1, 2, 3, 4, 5])
321
- expect($stdout.string).to eq("1\n2\n3\n4\n5\n")
322
- end
323
-
324
- it 'returns to block' do
325
- @tst.outf(@data) do |_dd, ios|
326
- ios.puts 'pop'
327
- end
328
- expect($stdout.string).to eq("pop\n")
329
- end
330
- end
331
- end
332
-
@@ -1,225 +0,0 @@
1
- # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
- # License: PROPRIETARY. See LICENSE.txt.
3
- # frozen_string_literal: true
4
-
5
- # vim:tw=0:ts=2:sw=2:et:ai
6
- # Unauthorized copying of this file is strictly prohibited.
7
-
8
- require 'tempfile'
9
- require 'webmock'
10
- require 'yaml'
11
-
12
- require 'MrMurano/version'
13
- require 'MrMurano/HttpAuthed'
14
- require 'MrMurano/ProjectFile'
15
- require 'MrMurano/SyncRoot'
16
- require 'MrMurano/Webservice-Cors'
17
- require '_workspace'
18
- require 'HttpAuthed_spec'
19
-
20
- RSpec.describe MrMurano::Webservice::Cors do
21
- include_context 'WORKSPACE'
22
-
23
- before(:example) do
24
- $cfg = MrMurano::Config.new
25
- $cfg.load
26
- $cfg['net.host'] = 'bizapi.hosted.exosite.io'
27
- $cfg['application.id'] = 'XYZ'
28
- stub_request_email_password
29
-
30
- @srv = MrMurano::Webservice::Cors.new
31
- MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
32
-
33
- @base_uri = 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/cors'
34
- end
35
-
36
- after(:example) do
37
- WebMock.reset!
38
- end
39
-
40
- it 'initializes' do
41
- uri = @srv.endpoint('/')
42
- expect(uri.to_s).to eq("#{@base_uri}/")
43
- end
44
-
45
- context 'when server gives string' do
46
- context 'fetches' do
47
- it 'as a hash' do
48
- cors = {
49
- origin: true,
50
- methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
51
- headers: ['Content-Type', 'Cookie', 'Authorization'],
52
- credentials: true,
53
- }
54
- body = { cors: cors.to_json }
55
- stub_request(
56
- :get, @base_uri.to_s
57
- ).with(
58
- headers: {
59
- 'Authorization' => 'token TTTTTTTTTT',
60
- 'Content-Type' => 'application/json',
61
- }
62
- ).to_return(body: body.to_json)
63
-
64
- ret = @srv.fetch
65
- expect(ret).to eq(cors)
66
- end
67
-
68
- it 'as a block' do
69
- cors = {
70
- origin: true,
71
- methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
72
- headers: ['Content-Type', 'Cookie', 'Authorization'],
73
- credentials: true,
74
- }
75
- body = { cors: cors.to_json }
76
- stub_request(
77
- :get, @base_uri.to_s
78
- ).with(
79
- headers: {
80
- 'Authorization' => 'token TTTTTTTTTT',
81
- 'Content-Type' => 'application/json',
82
- }
83
- ).to_return(body: body.to_json)
84
-
85
- ret = ''
86
- loops = 0
87
- @srv.fetch do |chunk|
88
- loops += 1
89
- ret += chunk
90
- expect(loops).to be <= 1
91
- end
92
- expect(ret).to eq(Hash.transform_keys_to_strings(cors).to_yaml)
93
- end
94
- end
95
- end
96
-
97
- context 'when server gives object' do
98
- context 'fetches' do
99
- it 'as a hash' do
100
- cors = {
101
- origin: true,
102
- methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
103
- headers: ['Content-Type', 'Cookie', 'Authorization'],
104
- credentials: true,
105
- }
106
- body = cors
107
- stub_request(
108
- :get, @base_uri.to_s
109
- ).with(
110
- headers: {
111
- 'Authorization' => 'token TTTTTTTTTT',
112
- 'Content-Type' => 'application/json',
113
- }
114
- ).to_return(body: body.to_json)
115
-
116
- ret = @srv.fetch
117
- expect(ret).to eq(cors)
118
- end
119
-
120
- it 'as a block' do
121
- cors = {
122
- origin: true,
123
- methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
124
- headers: ['Content-Type', 'Cookie', 'Authorization'],
125
- credentials: true,
126
- }
127
- body = cors
128
- stub_request(
129
- :get, @base_uri.to_s
130
- ).with(
131
- headers: {
132
- 'Authorization' => 'token TTTTTTTTTT',
133
- 'Content-Type' => 'application/json',
134
- }
135
- ).to_return(body: body.to_json)
136
-
137
- ret = ''
138
- loops = 0
139
- @srv.fetch do |chunk|
140
- loops += 1
141
- ret += chunk
142
- expect(loops).to be <= 1
143
- end
144
- expect(ret).to eq(Hash.transform_keys_to_strings(cors).to_yaml)
145
- end
146
- end
147
- end
148
-
149
- context 'uploads' do
150
- before(:example) do
151
- $project = MrMurano::ProjectFile.new
152
- $project.load
153
- @cors = {
154
- origin: true,
155
- methods: %w[HEAD GET POST PUT DELETE OPTIONS PATCH],
156
- headers: ['Content-Type', 'Cookie', 'Authorization'],
157
- credentials: true,
158
- }
159
- end
160
-
161
- it 'specified file' do
162
- File.open(File.join(@project_dir, 'bob.yaml'), 'w') { |io| io << @cors.to_yaml }
163
- stub_request(
164
- :put, @base_uri.to_s
165
- ).with(
166
- body: @cors.to_json,
167
- headers: {
168
- 'Authorization' => 'token TTTTTTTTTT',
169
- 'Content-Type' => 'application/json',
170
- }
171
- ).to_return(body: '')
172
-
173
- ret = @srv.upload('bob.yaml')
174
- expect(ret).to eq({})
175
- end
176
-
177
- it 'file in $project' do
178
- File.open(File.join(@project_dir, 'bob.yaml'), 'w') { |io| io << @cors.to_yaml }
179
- $project['routes.cors'] = 'bob.yaml'
180
- stub_request(
181
- :put, @base_uri.to_s
182
- ).with(body: @cors.to_json,
183
- headers: {
184
- 'Authorization' => 'token TTTTTTTTTT',
185
- 'Content-Type' => 'application/json',
186
- }).to_return(body: '')
187
-
188
- ret = @srv.upload
189
- expect(ret).to eq({})
190
- end
191
-
192
- it 'file defaults thru $project' do
193
- File.open(File.join(@project_dir, 'cors.yaml'), 'w') { |io| io << @cors.to_yaml }
194
- stub_request(
195
- :put, @base_uri.to_s
196
- ).with(
197
- body: @cors.to_json,
198
- headers: {
199
- 'Authorization' => 'token TTTTTTTTTT',
200
- 'Content-Type' => 'application/json',
201
- }
202
- ).to_return(body: '')
203
-
204
- ret = @srv.upload
205
- expect(ret).to eq({})
206
- end
207
-
208
- it 'cors in $project' do
209
- $project['routes.cors'] = @cors
210
- stub_request(
211
- :put, @base_uri.to_s
212
- ).with(
213
- body: @cors.to_json,
214
- headers: {
215
- 'Authorization' => 'token TTTTTTTTTT',
216
- 'Content-Type' => 'application/json',
217
- }
218
- ).to_return(body: '')
219
-
220
- ret = @srv.upload
221
- expect(ret).to eq({})
222
- end
223
- end
224
- end
225
-