webspicy 0.20.1 → 0.20.6

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/bin/sandr +14 -0
  3. data/bin/search +2 -0
  4. data/bin/webspicy +3 -4
  5. data/lib/finitio/webspicy/shared.fio +10 -0
  6. data/lib/webspicy.rb +22 -53
  7. data/lib/webspicy/configuration.rb +17 -0
  8. data/lib/webspicy/configuration/scope.rb +3 -2
  9. data/lib/webspicy/configuration/single_url.rb +35 -25
  10. data/lib/webspicy/configuration/single_yml_file.rb +7 -2
  11. data/lib/webspicy/specification.rb +0 -55
  12. data/lib/webspicy/specification/oldies/bridge.rb +4 -1
  13. data/lib/webspicy/specification/post/missing_condition_impl.rb +2 -2
  14. data/lib/webspicy/specification/post/unexpected_condition_impl.rb +2 -2
  15. data/lib/webspicy/specification/service.rb +4 -5
  16. data/lib/webspicy/specification/test_case.rb +3 -49
  17. data/lib/webspicy/support/colorize.rb +7 -1
  18. data/lib/webspicy/tester.rb +21 -20
  19. data/lib/webspicy/tester/assertions.rb +2 -2
  20. data/lib/webspicy/tester/fakesmtp/email.rb +13 -0
  21. data/lib/webspicy/tester/reporter.rb +5 -0
  22. data/lib/webspicy/tester/reporter/documentation.rb +30 -8
  23. data/lib/webspicy/tester/reporter/error_count.rb +11 -7
  24. data/lib/webspicy/tester/reporter/file_progress.rb +2 -2
  25. data/lib/webspicy/tester/reporter/file_summary.rb +2 -2
  26. data/lib/webspicy/tester/reporter/progress.rb +4 -4
  27. data/lib/webspicy/tester/reporter/summary.rb +8 -7
  28. data/lib/webspicy/tester/result.rb +2 -2
  29. data/lib/webspicy/tester/result/errcondition_met.rb +1 -3
  30. data/lib/webspicy/tester/result/postcondition_met.rb +1 -3
  31. data/lib/webspicy/version.rb +1 -1
  32. data/lib/webspicy/web.rb +46 -0
  33. data/lib/webspicy/{formaldoc.fio → web/formaldoc.fio} +5 -13
  34. data/lib/webspicy/web/invocation.rb +1 -0
  35. data/lib/webspicy/web/specification.rb +68 -0
  36. data/lib/webspicy/web/specification/file_upload.rb +39 -0
  37. data/lib/webspicy/web/specification/service.rb +13 -0
  38. data/lib/webspicy/web/specification/test_case.rb +58 -0
  39. data/spec/unit/configuration/scope/test_expand_example.rb +11 -5
  40. data/spec/unit/specification/pre/test_global_request_headers.rb +3 -3
  41. data/spec/unit/specification/service/test_dress_params.rb +2 -2
  42. data/spec/unit/test_configuration.rb +1 -0
  43. data/spec/unit/tester/fakesmtp/test_email.rb +93 -0
  44. data/spec/unit/web/specification/test_instantiate_url.rb +36 -0
  45. data/spec/unit/web/specification/test_url_placeholders.rb +23 -0
  46. data/tasks/test.rake +2 -1
  47. metadata +28 -19
  48. data/lib/webspicy/specification/file_upload.rb +0 -37
  49. data/spec/unit/specification/test_instantiate_url.rb +0 -34
  50. data/spec/unit/specification/test_url_placeholders.rb +0 -21
@@ -4,7 +4,7 @@ module Webspicy
4
4
  describe Service, "dress_params" do
5
5
 
6
6
  it 'symbolizes keys' do
7
- service = Webspicy.service({
7
+ service = Webspicy::Web.service({
8
8
  method: "GET",
9
9
  description: "Test service",
10
10
  preconditions: "Foo",
@@ -17,7 +17,7 @@ module Webspicy
17
17
  end
18
18
 
19
19
  it 'supports an array' do
20
- service = Webspicy.service({
20
+ service = Webspicy::Web.service({
21
21
  method: "GET",
22
22
  description: "Test service",
23
23
  preconditions: "Foo",
@@ -36,6 +36,7 @@ module Webspicy
36
36
  expect(c).to be_a(Configuration)
37
37
  expect(c.folder).to eq(Path.pwd)
38
38
  expect(c.each_scope.to_a.size).to eql(1)
39
+ expect(c.each_scope.to_a.first.each_specification_file.to_a.size).to eql(1)
39
40
  expect(c.each_scope.to_a.first.each_specification.to_a.size).to eql(1)
40
41
  end
41
42
 
@@ -0,0 +1,93 @@
1
+ require 'spec_helper'
2
+ require 'webspicy/tester/fakesmtp'
3
+ module Webspicy
4
+ class Tester
5
+ class Fakesmtp
6
+ describe Email do
7
+
8
+ DATA = JSON.parse <<~J
9
+ {
10
+ "attachments": [],
11
+ "headerLines": [
12
+ {
13
+ "key": "date",
14
+ "line": "Date: Tue, 20 Apr 2021 14:06:13 +0000"
15
+ },
16
+ {
17
+ "key": "from",
18
+ "line": "From: info@mydomain.be"
19
+ },
20
+ {
21
+ "key": "reply-to",
22
+ "line": "Reply-To: test@email.be"
23
+ },
24
+ {
25
+ "key": "to",
26
+ "line": "To: support@mydomain.fr"
27
+ },
28
+ {
29
+ "key": "message-id",
30
+ "line": "Message-ID: <607edfd56836e_1b0492af@1d3356d02030.mail>"
31
+ },
32
+ {
33
+ "key": "subject",
34
+ "line": "Subject: Hello World"
35
+ },
36
+ {
37
+ "key": "mime-version",
38
+ "line": "Mime-Version: 1.0"
39
+ }
40
+ ],
41
+ "html": "<p>Hello World!!</p>",
42
+ "text": "Hello World!!",
43
+ "textAsHtml": "Hello World!!",
44
+ "subject": "Hello World",
45
+ "date": "2021-04-20T14:06:13.000Z",
46
+ "to": {
47
+ "value": [
48
+ {
49
+ "address": "support@mydomain.fr",
50
+ "name": ""
51
+ }
52
+ ],
53
+ "html": "<span class=\\"mp_address_group\\"><a href=\\"mailto:support@mydomain.fr\\" class=\\"mp_address_email\\">support@mydomain.fr</a></span>",
54
+ "text": "support@mydomain.fr"
55
+ },
56
+ "from": {
57
+ "value": [
58
+ {
59
+ "address": "info@mydomain.be",
60
+ "name": ""
61
+ }
62
+ ],
63
+ "html": "<span class=\\"mp_address_group\\"><a href=\\"mailto:info@mydomain.be\\" class=\\"mp_address_email\\">info@mydomain.be</a></span>",
64
+ "text": "info@mydomain.be"
65
+ },
66
+ "messageId": "<607edfd56836e_1b0492af@1d3356d02030.mail>",
67
+ "replyTo": {
68
+ "value": [
69
+ {
70
+ "address": "test@email.be",
71
+ "name": ""
72
+ }
73
+ ],
74
+ "html": "<span class=\\"mp_address_group\\"><a href=\\"mailto:test@email.be\\" class=\\"mp_address_email\\">test@email.be</a></span>",
75
+ "text": "test@email.be"
76
+ }
77
+ }
78
+ J
79
+
80
+ subject{
81
+ Email.new(DATA)
82
+ }
83
+
84
+ it 'works as expected' do
85
+ expect(subject.from).to eql("info@mydomain.be")
86
+ expect(subject.to).to eql(["support@mydomain.fr"])
87
+ expect(subject.subject).to eql("Hello World")
88
+ end
89
+
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,36 @@
1
+ require "spec_helper"
2
+ module Webspicy
3
+ module Web
4
+ describe Specification, "instantiate_url" do
5
+
6
+ it 'does nothing when the url has no placeholder' do
7
+ r = Specification.new(url: "/test/a/url")
8
+ url, params = r.instantiate_url(foo: "bar")
9
+ expect(url).to eq("/test/a/url")
10
+ expect(params).to eq(foo: "bar")
11
+ end
12
+
13
+ it 'instantiates placeholders and strips corresponding params' do
14
+ r = Specification.new(url: "/test/{foo}/url")
15
+ url, params = r.instantiate_url(foo: "bar", baz: "coz")
16
+ expect(url).to eq("/test/bar/url")
17
+ expect(params).to eq(baz: "coz")
18
+ end
19
+
20
+ it 'instantiates placeholders and strips corresponding params even when multiple' do
21
+ r = Specification.new(url: "/test/{foo}/url/{bar}")
22
+ url, params = r.instantiate_url(foo: "bar", bar: "baz", baz: "coz")
23
+ expect(url).to eq("/test/bar/url/baz")
24
+ expect(params).to eq(baz: "coz")
25
+ end
26
+
27
+ it 'supports placeholders corresponding to subentities' do
28
+ r = Specification.new(url: "/test/{foo.id}/url")
29
+ url, params = r.instantiate_url(foo: {id: "bar"}, baz: "coz")
30
+ expect(url).to eq("/test/bar/url")
31
+ expect(params).to eq(foo: {}, baz: "coz")
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,23 @@
1
+ require "spec_helper"
2
+ module Webspicy
3
+ module Web
4
+ describe Specification, "url_placeholders" do
5
+
6
+ it 'returns an empty array on none' do
7
+ r = Specification.new(url: "/test/a/url")
8
+ expect(r.url_placeholders).to eq([])
9
+ end
10
+
11
+ it 'returns all placeholders' do
12
+ r = Specification.new(url: "/test/{foo}/url/{bar}")
13
+ expect(r.url_placeholders).to eq(["foo", "bar"])
14
+ end
15
+
16
+ it 'returns all placeholders expr' do
17
+ r = Specification.new(url: "/test/{foo.id}/url/{bar}")
18
+ expect(r.url_placeholders).to eq(["foo.id", "bar"])
19
+ end
20
+
21
+ end
22
+ end
23
+ end
data/tasks/test.rake CHANGED
@@ -18,7 +18,8 @@ namespace :test do
18
18
  desc "Runs the integration tests on the #{file.basename} example"
19
19
  task(test_name) do
20
20
  Bundler.with_original_env do
21
- system("cd #{file} && bundle exec rake")
21
+ x = system("cd #{file} && bundle exec rake")
22
+ abort("Example test suite failed: #{file}") unless x
22
23
  end
23
24
  end
24
25
  tests << test_name
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webspicy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.1
4
+ version: 0.20.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-12 00:00:00.000000000 Z
11
+ date: 2021-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -126,22 +126,22 @@ dependencies:
126
126
  name: rack-robustness
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: 1.1.0
132
129
  - - "~>"
133
130
  - !ruby/object:Gem::Version
134
131
  version: '1.1'
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 1.1.0
135
135
  type: :runtime
136
136
  prerelease: false
137
137
  version_requirements: !ruby/object:Gem::Requirement
138
138
  requirements:
139
- - - ">="
140
- - !ruby/object:Gem::Version
141
- version: 1.1.0
142
139
  - - "~>"
143
140
  - !ruby/object:Gem::Version
144
141
  version: '1.1'
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: 1.1.0
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: mustermann
147
147
  requirement: !ruby/object:Gem::Requirement
@@ -171,19 +171,19 @@ dependencies:
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  - !ruby/object:Gem::Dependency
174
- name: colorize
174
+ name: paint
175
175
  requirement: !ruby/object:Gem::Requirement
176
176
  requirements:
177
177
  - - "~>"
178
178
  - !ruby/object:Gem::Version
179
- version: 0.8.1
179
+ version: '2.2'
180
180
  type: :runtime
181
181
  prerelease: false
182
182
  version_requirements: !ruby/object:Gem::Requirement
183
183
  requirements:
184
184
  - - "~>"
185
185
  - !ruby/object:Gem::Version
186
- version: 0.8.1
186
+ version: '2.2'
187
187
  - !ruby/object:Gem::Dependency
188
188
  name: openapi3_parser
189
189
  requirement: !ruby/object:Gem::Requirement
@@ -201,6 +201,8 @@ dependencies:
201
201
  description: Webspicy helps testing web services as software operation black boxes
202
202
  email: blambeau@gmail.com
203
203
  executables:
204
+ - sandr
205
+ - search
204
206
  - webspicy
205
207
  extensions: []
206
208
  extra_rdoc_files: []
@@ -208,22 +210,23 @@ files:
208
210
  - Gemfile
209
211
  - README.md
210
212
  - Rakefile
213
+ - bin/sandr
214
+ - bin/search
211
215
  - bin/webspicy
212
216
  - doc/1-black-box-scene.md
213
217
  - doc/2-black-box-testing.md
214
218
  - doc/3-specification-importance.md
215
219
  - doc/4-sequence-diagram.md
216
220
  - lib/finitio/webspicy/scalars.fio
221
+ - lib/finitio/webspicy/shared.fio
217
222
  - lib/webspicy.rb
218
223
  - lib/webspicy/configuration.rb
219
224
  - lib/webspicy/configuration/scope.rb
220
225
  - lib/webspicy/configuration/single_url.rb
221
226
  - lib/webspicy/configuration/single_yml_file.rb
222
- - lib/webspicy/formaldoc.fio
223
227
  - lib/webspicy/specification.rb
224
228
  - lib/webspicy/specification/condition.rb
225
229
  - lib/webspicy/specification/err.rb
226
- - lib/webspicy/specification/file_upload.rb
227
230
  - lib/webspicy/specification/oldies.rb
228
231
  - lib/webspicy/specification/oldies/bridge.rb
229
232
  - lib/webspicy/specification/oldies/errcondition.rb
@@ -279,11 +282,16 @@ files:
279
282
  - lib/webspicy/web/client/http_client.rb
280
283
  - lib/webspicy/web/client/rack_test_client.rb
281
284
  - lib/webspicy/web/client/support.rb
285
+ - lib/webspicy/web/formaldoc.fio
282
286
  - lib/webspicy/web/invocation.rb
283
287
  - lib/webspicy/web/mocker.rb
284
288
  - lib/webspicy/web/mocker/config.ru
285
289
  - lib/webspicy/web/openapi.rb
286
290
  - lib/webspicy/web/openapi/generator.rb
291
+ - lib/webspicy/web/specification.rb
292
+ - lib/webspicy/web/specification/file_upload.rb
293
+ - lib/webspicy/web/specification/service.rb
294
+ - lib/webspicy/web/specification/test_case.rb
287
295
  - spec/spec_helper.rb
288
296
  - spec/unit/configuration/config.rb
289
297
  - spec/unit/configuration/scope/test_each_service.rb
@@ -294,8 +302,6 @@ files:
294
302
  - spec/unit/specification/service/test_dress_params.rb
295
303
  - spec/unit/specification/test_case/test_mutate.rb
296
304
  - spec/unit/specification/test_condition.rb
297
- - spec/unit/specification/test_instantiate_url.rb
298
- - spec/unit/specification/test_url_placeholders.rb
299
305
  - spec/unit/support/hooks/test_fire_after_each.rb
300
306
  - spec/unit/support/hooks/test_fire_around.rb
301
307
  - spec/unit/support/hooks/test_fire_before_each.rb
@@ -307,17 +313,20 @@ files:
307
313
  - spec/unit/support/world/test_world.rb
308
314
  - spec/unit/test_configuration.rb
309
315
  - spec/unit/tester/fakeses/test_email.rb
316
+ - spec/unit/tester/fakesmtp/test_email.rb
310
317
  - spec/unit/tester/test_asserter.rb
311
318
  - spec/unit/tester/test_assertions.rb
312
319
  - spec/unit/web/mocker/test_mocker.rb
313
320
  - spec/unit/web/openapi/test_generator.rb
321
+ - spec/unit/web/specification/test_instantiate_url.rb
322
+ - spec/unit/web/specification/test_url_placeholders.rb
314
323
  - tasks/gem.rake
315
324
  - tasks/test.rake
316
325
  homepage: http://github.com/enspirit/webspicy
317
326
  licenses:
318
327
  - MIT
319
328
  metadata: {}
320
- post_install_message:
329
+ post_install_message:
321
330
  rdoc_options: []
322
331
  require_paths:
323
332
  - lib
@@ -332,8 +341,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
332
341
  - !ruby/object:Gem::Version
333
342
  version: '0'
334
343
  requirements: []
335
- rubygems_version: 3.0.8
336
- signing_key:
344
+ rubygems_version: 3.2.1
345
+ signing_key:
337
346
  specification_version: 4
338
347
  summary: Webspicy helps testing web services as software operation black boxes!
339
348
  test_files: []
@@ -1,37 +0,0 @@
1
- module Webspicy
2
- class Specification
3
- class FileUpload
4
-
5
- def initialize(raw)
6
- @path = raw[:path]
7
- @content_type = raw[:content_type]
8
- @param_name = raw[:param_name] || "file"
9
- end
10
-
11
- attr_reader :path, :content_type, :param_name
12
-
13
- def self.info(raw)
14
- new(raw)
15
- end
16
-
17
- def locate(specification)
18
- FileUpload.new({
19
- path: specification.locate(path),
20
- content_type: content_type
21
- })
22
- end
23
-
24
- def to_info
25
- { path: path.to_s,
26
- content_type: content_type,
27
- param_name: param_name }
28
- end
29
-
30
- def to_s
31
- "FileUpload(#{to_info})"
32
- end
33
- alias :inspect :to_s
34
-
35
- end # class FileUpload
36
- end # class Specification
37
- end # module Webspicy
@@ -1,34 +0,0 @@
1
- require "spec_helper"
2
- module Webspicy
3
- describe Specification, "instantiate_url" do
4
-
5
- it 'does nothing when the url has no placeholder' do
6
- r = Specification.new(url: "/test/a/url")
7
- url, params = r.instantiate_url(foo: "bar")
8
- expect(url).to eq("/test/a/url")
9
- expect(params).to eq(foo: "bar")
10
- end
11
-
12
- it 'instantiates placeholders and strips corresponding params' do
13
- r = Specification.new(url: "/test/{foo}/url")
14
- url, params = r.instantiate_url(foo: "bar", baz: "coz")
15
- expect(url).to eq("/test/bar/url")
16
- expect(params).to eq(baz: "coz")
17
- end
18
-
19
- it 'instantiates placeholders and strips corresponding params even when multiple' do
20
- r = Specification.new(url: "/test/{foo}/url/{bar}")
21
- url, params = r.instantiate_url(foo: "bar", bar: "baz", baz: "coz")
22
- expect(url).to eq("/test/bar/url/baz")
23
- expect(params).to eq(baz: "coz")
24
- end
25
-
26
- it 'supports placeholders corresponding to subentities' do
27
- r = Specification.new(url: "/test/{foo.id}/url")
28
- url, params = r.instantiate_url(foo: {id: "bar"}, baz: "coz")
29
- expect(url).to eq("/test/bar/url")
30
- expect(params).to eq(foo: {}, baz: "coz")
31
- end
32
-
33
- end
34
- end
@@ -1,21 +0,0 @@
1
- require "spec_helper"
2
- module Webspicy
3
- describe Specification, "url_placeholders" do
4
-
5
- it 'returns an empty array on none' do
6
- r = Specification.new(url: "/test/a/url")
7
- expect(r.url_placeholders).to eq([])
8
- end
9
-
10
- it 'returns all placeholders' do
11
- r = Specification.new(url: "/test/{foo}/url/{bar}")
12
- expect(r.url_placeholders).to eq(["foo", "bar"])
13
- end
14
-
15
- it 'returns all placeholders expr' do
16
- r = Specification.new(url: "/test/{foo.id}/url/{bar}")
17
- expect(r.url_placeholders).to eq(["foo.id", "bar"])
18
- end
19
-
20
- end
21
- end