webspicy 0.17.0 → 0.20.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/bin/webspicy +6 -1
  4. data/doc/1-black-box-scene.md +109 -0
  5. data/doc/2-black-box-testing.md +27 -0
  6. data/doc/3-specification-importance.md +41 -0
  7. data/doc/4-sequence-diagram.md +82 -0
  8. data/lib/webspicy.rb +17 -9
  9. data/lib/webspicy/configuration.rb +48 -8
  10. data/lib/webspicy/configuration/scope.rb +22 -8
  11. data/lib/webspicy/formaldoc.fio +5 -5
  12. data/lib/webspicy/specification.rb +5 -2
  13. data/lib/webspicy/specification/condition.rb +48 -0
  14. data/lib/webspicy/specification/err.rb +18 -0
  15. data/lib/webspicy/specification/oldies.rb +4 -0
  16. data/lib/webspicy/specification/oldies/bridge.rb +32 -0
  17. data/lib/webspicy/specification/{errcondition.rb → oldies/errcondition.rb} +6 -0
  18. data/lib/webspicy/specification/{postcondition.rb → oldies/postcondition.rb} +6 -0
  19. data/lib/webspicy/specification/{precondition.rb → oldies/precondition.rb} +6 -2
  20. data/lib/webspicy/specification/post.rb +20 -0
  21. data/lib/webspicy/specification/post/missing_condition_impl.rb +15 -0
  22. data/lib/webspicy/specification/post/unexpected_condition_impl.rb +15 -0
  23. data/lib/webspicy/specification/pre.rb +19 -0
  24. data/lib/webspicy/specification/{precondition → pre}/global_request_headers.rb +4 -4
  25. data/lib/webspicy/specification/{precondition → pre}/robust_to_invalid_input.rb +4 -4
  26. data/lib/webspicy/specification/service.rb +34 -5
  27. data/lib/webspicy/specification/test_case.rb +11 -9
  28. data/lib/webspicy/support.rb +31 -0
  29. data/lib/webspicy/support/hooks.rb +65 -0
  30. data/lib/webspicy/support/world.rb +47 -0
  31. data/lib/webspicy/tester.rb +202 -3
  32. data/lib/webspicy/tester/assertions.rb +2 -2
  33. data/lib/webspicy/tester/client.rb +4 -50
  34. data/lib/webspicy/tester/fakeses.rb +41 -0
  35. data/lib/webspicy/tester/fakeses/email.rb +38 -0
  36. data/lib/webspicy/tester/fakesmtp.rb +39 -0
  37. data/lib/webspicy/tester/fakesmtp/email.rb +27 -0
  38. data/lib/webspicy/tester/file_checker.rb +22 -0
  39. data/lib/webspicy/tester/invocation.rb +15 -48
  40. data/lib/webspicy/tester/reporter.rb +85 -0
  41. data/lib/webspicy/tester/reporter/composite.rb +38 -0
  42. data/lib/webspicy/tester/reporter/documentation.rb +74 -0
  43. data/lib/webspicy/tester/reporter/error_count.rb +25 -0
  44. data/lib/webspicy/tester/reporter/exceptions.rb +62 -0
  45. data/lib/webspicy/tester/reporter/file_progress.rb +25 -0
  46. data/lib/webspicy/tester/reporter/file_summary.rb +43 -0
  47. data/lib/webspicy/tester/reporter/progress.rb +30 -0
  48. data/lib/webspicy/tester/reporter/summary.rb +63 -0
  49. data/lib/webspicy/tester/result.rb +142 -0
  50. data/lib/webspicy/tester/result/assert_met.rb +29 -0
  51. data/lib/webspicy/tester/result/check.rb +33 -0
  52. data/lib/webspicy/tester/result/errcondition_met.rb +29 -0
  53. data/lib/webspicy/tester/result/error_schema_met.rb +25 -0
  54. data/lib/webspicy/tester/result/invocation_succeeded.rb +13 -0
  55. data/lib/webspicy/tester/result/output_schema_met.rb +25 -0
  56. data/lib/webspicy/tester/result/postcondition_met.rb +29 -0
  57. data/lib/webspicy/tester/result/response_header_met.rb +43 -0
  58. data/lib/webspicy/tester/result/response_status_met.rb +25 -0
  59. data/lib/webspicy/version.rb +2 -2
  60. data/lib/webspicy/web.rb +4 -0
  61. data/lib/webspicy/web/client.rb +15 -0
  62. data/lib/webspicy/{tester → web}/client/http_client.rb +34 -14
  63. data/lib/webspicy/{tester → web}/client/rack_test_client.rb +3 -3
  64. data/lib/webspicy/{tester → web}/client/support.rb +2 -2
  65. data/lib/webspicy/web/invocation.rb +69 -0
  66. data/lib/webspicy/web/mocker.rb +90 -0
  67. data/lib/webspicy/{mocker → web/mocker}/config.ru +3 -2
  68. data/lib/webspicy/{openapi.rb → web/openapi.rb} +0 -0
  69. data/lib/webspicy/web/openapi/generator.rb +129 -0
  70. data/spec/unit/specification/{precondition → pre}/test_global_request_headers.rb +9 -4
  71. data/spec/unit/specification/test_condition.rb +44 -0
  72. data/spec/unit/support/hooks/test_fire_after_each.rb +53 -0
  73. data/spec/unit/{tester/client/test_around.rb → support/hooks/test_fire_around.rb} +15 -10
  74. data/spec/unit/support/hooks/test_fire_before_each.rb +53 -0
  75. data/spec/unit/support/world/fixtures/array.json +8 -0
  76. data/spec/unit/support/world/fixtures/queue.rb +1 -0
  77. data/spec/unit/support/world/fixtures/single.json +11 -0
  78. data/spec/unit/support/world/fixtures/yaml.yml +3 -0
  79. data/spec/unit/support/world/test_world.rb +56 -0
  80. data/spec/unit/test_configuration.rb +49 -0
  81. data/spec/unit/tester/fakeses/test_email.rb +40 -0
  82. data/spec/unit/web/mocker/test_mocker.rb +35 -0
  83. data/spec/unit/web/openapi/test_generator.rb +31 -0
  84. metadata +86 -72
  85. data/examples/restful/Gemfile +0 -5
  86. data/examples/restful/Gemfile.lock +0 -106
  87. data/examples/restful/Rakefile +0 -25
  88. data/examples/restful/app.rb +0 -180
  89. data/examples/restful/webspicy/config.rb +0 -24
  90. data/examples/restful/webspicy/formaldef/todo/_one/delete.yml +0 -55
  91. data/examples/restful/webspicy/formaldef/todo/_one/get.simpler.yml +0 -46
  92. data/examples/restful/webspicy/formaldef/todo/_one/get.yml +0 -50
  93. data/examples/restful/webspicy/formaldef/todo/_one/patch.yml +0 -66
  94. data/examples/restful/webspicy/formaldef/todo/_one/put.yml +0 -65
  95. data/examples/restful/webspicy/formaldef/todo/get.yml +0 -36
  96. data/examples/restful/webspicy/formaldef/todo/options.yml +0 -32
  97. data/examples/restful/webspicy/formaldef/todo/post.csv.yml +0 -43
  98. data/examples/restful/webspicy/formaldef/todo/post.file.yml +0 -40
  99. data/examples/restful/webspicy/formaldef/todo/post.yml +0 -51
  100. data/examples/restful/webspicy/formaldef/todo/todos.csv +0 -4
  101. data/examples/restful/webspicy/rack.rb +0 -7
  102. data/examples/restful/webspicy/real.rb +0 -8
  103. data/examples/restful/webspicy/schema.fio +0 -20
  104. data/examples/restful/webspicy/support/must_be_an_admin.rb +0 -20
  105. data/examples/restful/webspicy/support/must_be_authenticated.rb +0 -48
  106. data/examples/restful/webspicy/support/todo_not_removed.rb +0 -21
  107. data/examples/restful/webspicy/support/todo_removed.rb +0 -20
  108. data/examples/single_spec/spec.yml +0 -59
  109. data/examples/website/config.rb +0 -2
  110. data/examples/website/schema.fio +0 -1
  111. data/examples/website/specification/get-http.yml +0 -30
  112. data/examples/website/specification/get-https.yml +0 -30
  113. data/lib/webspicy/checker.rb +0 -10
  114. data/lib/webspicy/mocker.rb +0 -88
  115. data/lib/webspicy/openapi/generator.rb +0 -127
  116. data/lib/webspicy/rspec/checker.rb +0 -2
  117. data/lib/webspicy/rspec/checker/rspec_checker.rb +0 -24
  118. data/lib/webspicy/rspec/support/rspec_runnable.rb +0 -27
  119. data/lib/webspicy/rspec/tester.rb +0 -4
  120. data/lib/webspicy/rspec/tester/rspec_asserter.rb +0 -121
  121. data/lib/webspicy/rspec/tester/rspec_matchers.rb +0 -114
  122. data/lib/webspicy/rspec/tester/rspec_tester.rb +0 -63
  123. data/spec/unit/mocker/test_mocker.rb +0 -32
  124. data/spec/unit/openapi/test_generator.rb +0 -28
@@ -1,50 +0,0 @@
1
- ---
2
- name: |-
3
- Todo
4
-
5
- url: |-
6
- /todo/{id}
7
-
8
- services:
9
- - method: |-
10
- GET
11
-
12
- description: |-
13
- Returns a single todo item
14
-
15
- input_schema: |-
16
- {
17
- id: Integer
18
- }
19
-
20
- output_schema: |-
21
- Todo
22
-
23
- error_schema: |-
24
- ErrorSchema
25
-
26
- examples:
27
-
28
- - description: |-
29
- when requested on an existing TODO
30
- params:
31
- id: 1
32
- expected:
33
- content_type: application/json
34
- status: 200
35
- assert:
36
- - "pathFD('', id: 1)"
37
- - "match('description', /Refactor/)"
38
- - "notMatch('description', /Foo/)"
39
-
40
- counterexamples:
41
-
42
- - description: |-
43
- when requested on an unexisting TODO
44
- params:
45
- id: 999254654
46
- expected:
47
- content_type: application/json
48
- status: 404
49
- assert:
50
- - "pathFD('', error: 'No such todo')"
@@ -1,66 +0,0 @@
1
- ---
2
- name: |-
3
- Todo
4
-
5
- url: |-
6
- /todo/{id}
7
-
8
- services:
9
- - method: |-
10
- PATCH
11
-
12
- description: |-
13
- Patches a single Todo item
14
-
15
- preconditions:
16
- - Must be authenticated
17
-
18
- input_schema: |-
19
- TodoPatch
20
-
21
- output_schema: |-
22
- Todo
23
-
24
- error_schema: |-
25
- ErrorSchema
26
-
27
- default_example:
28
- expected:
29
- content_type: application/json
30
- status: 200
31
-
32
- examples:
33
-
34
- - description: |-
35
- when requested on an existing TODO
36
- params:
37
- id: 1
38
- description: 'hello world'
39
- expected:
40
- content_type: application/json
41
- status: 200
42
- assert:
43
- - "pathFD('', description: 'hello world')"
44
-
45
- counterexamples:
46
-
47
- - description: |-
48
- when requested on an unexisting TODO
49
- params:
50
- id: 999254654
51
- expected:
52
- content_type: application/json
53
- status: 404
54
- assert:
55
- - "pathFD('', error: 'No such todo')"
56
-
57
- - description: |-
58
- when violating the Patch data type
59
- params:
60
- id: 1
61
- nosuchone: 'foobar'
62
- dress_params:
63
- false
64
- expected:
65
- content_type: application/json
66
- status: 400
@@ -1,65 +0,0 @@
1
- ---
2
- name: |-
3
- Todo
4
-
5
- url: |-
6
- /todo/{id}
7
-
8
- services:
9
- - method: |-
10
- PUT
11
-
12
- description: |-
13
- Update a single Todo item
14
-
15
- preconditions:
16
- - Must be authenticated
17
-
18
- input_schema: |-
19
- TodoPut
20
-
21
- output_schema: |-
22
- Todo
23
-
24
- error_schema: |-
25
- ErrorSchema
26
-
27
- default_example:
28
- expected:
29
- content_type: application/json
30
- status: 200
31
-
32
- examples:
33
-
34
- - description: |-
35
- when requested on an existing TODO
36
- params:
37
- id: 1
38
- description: 'hello world'
39
- assert:
40
- - "pathFD('', description: 'hello world')"
41
-
42
- counterexamples:
43
-
44
- - description: |-
45
- when requested on an unexisting TODO
46
- params:
47
- id: 999254654
48
- description: 'hello world'
49
- expected:
50
- content_type: application/json
51
- status: 404
52
- assert:
53
- - "pathFD('', error: 'No such todo')"
54
-
55
- - description: |-
56
- when violating the Put data type
57
- params:
58
- id: 1
59
- description: 'hello world'
60
- nosuchone: 'foobar'
61
- dress_params:
62
- false
63
- expected:
64
- content_type: application/json
65
- status: 400
@@ -1,36 +0,0 @@
1
- ---
2
- name: |-
3
- Todo
4
-
5
- url: |-
6
- /todo/
7
-
8
- services:
9
- - method: |-
10
- GET
11
-
12
- description: |-
13
- Returns the list of todo items
14
-
15
- input_schema: |-
16
- {
17
- }
18
-
19
- output_schema: |-
20
- [Todo]
21
-
22
- error_schema: |-
23
- ErrorSchema
24
-
25
- examples:
26
-
27
- - description: |-
28
- when requested
29
- params: {}
30
- expected:
31
- content_type: application/json
32
- status: 200
33
- assert:
34
- - notEmpty
35
-
36
- counterexamples: []
@@ -1,32 +0,0 @@
1
- ---
2
- name: |-
3
- Todo
4
-
5
- url: |-
6
- /todo/
7
-
8
- services:
9
- - method: |-
10
- OPTIONS
11
-
12
- description: |-
13
- Returns options about the web service
14
-
15
- input_schema: |-
16
- {
17
- }
18
-
19
- output_schema: |-
20
- Any
21
-
22
- error_schema: |-
23
- ErrorSchema
24
-
25
- examples:
26
-
27
- - description: |-
28
- when requested on an existing TODO
29
- params: {}
30
- expected:
31
- content_type: ~
32
- status: 204
@@ -1,43 +0,0 @@
1
- ---
2
- name: |-
3
- Todo
4
-
5
- url: |-
6
- /todo/
7
-
8
- services:
9
- - method: |-
10
- POST
11
-
12
- description: |-
13
- Creates new todo items through a CSV import
14
-
15
- preconditions:
16
- - Must be authenticated
17
-
18
- input_schema: |-
19
- {}
20
-
21
- output_schema: |-
22
- { count: Integer }
23
-
24
- error_schema: |-
25
- ErrorSchema
26
-
27
- examples:
28
-
29
- - description: |-
30
- when requested with a valid CSV
31
- params: {}
32
- headers:
33
- Content-Type: text/csv
34
- body: |-
35
- id,description
36
- 10,Write documentation
37
- 11,Create website
38
- 12,Add smart tools
39
- expected:
40
- content_type: application/json
41
- status: 201
42
- assert:
43
- - "pathFD('', count: 3)"
@@ -1,40 +0,0 @@
1
- ---
2
- name: |-
3
- Todo
4
-
5
- url: |-
6
- /todo/
7
-
8
- services:
9
- - method: |-
10
- POST
11
-
12
- description: |-
13
- Creates new todo items through a CSV file upload
14
-
15
- preconditions:
16
- - Must be authenticated
17
-
18
- input_schema: |-
19
- Any
20
-
21
- output_schema: |-
22
- { count: Integer }
23
-
24
- error_schema: |-
25
- ErrorSchema
26
-
27
- examples:
28
-
29
- - description: |-
30
- when requested with a valid CSV file
31
- tags:
32
- - upload
33
- file_upload:
34
- path: ./todos.csv
35
- content_type: "text/csv"
36
- expected:
37
- content_type: application/json
38
- status: 201
39
- assert:
40
- - "pathFD('', count: 3)"
@@ -1,51 +0,0 @@
1
- ---
2
- name: |-
3
- Todo
4
-
5
- url: |-
6
- /todo/
7
-
8
- services:
9
- - method: |-
10
- POST
11
-
12
- description: |-
13
- Creates a new todo item
14
-
15
- preconditions:
16
- - Must be authenticated
17
-
18
- input_schema: |-
19
- Todo
20
-
21
- output_schema: |-
22
- Todo
23
-
24
- error_schema: |-
25
- ErrorSchema
26
-
27
- examples:
28
-
29
- - description: |-
30
- when requested with a non existing ID
31
- params:
32
- id: 3
33
- description: "Hello World"
34
- expected:
35
- content_type: application/json
36
- status: 201
37
- assert:
38
- - "pathFD('', id: 3)"
39
-
40
- counterexamples:
41
-
42
- - description: |-
43
- when requested while the id already exists
44
- params:
45
- id: 1
46
- description: "Hello World"
47
- expected:
48
- content_type: application/json
49
- status: 409
50
- assert:
51
- - "pathFD('', error: 'Identifier already in use')"
@@ -1,4 +0,0 @@
1
- id,description
2
- 10,Write documentation
3
- 11,Create website
4
- 12,Add smart tools
@@ -1,7 +0,0 @@
1
- require_relative 'config'
2
- webspicy_config do |c|
3
- c.client = Webspicy::Tester::RackTestClient.for(::Sinatra::Application)
4
- c.before_each do |_,client|
5
- client.api.post "/reset"
6
- end
7
- end
@@ -1,8 +0,0 @@
1
- require_relative 'config'
2
- webspicy_config do |c|
3
- c.host = "http://127.0.0.1:4567"
4
- c.client = Webspicy::Tester::HttpClient
5
- c.before_each do |_,client|
6
- client.api.post "http://127.0.0.1:4567/reset"
7
- end
8
- end
@@ -1,20 +0,0 @@
1
- @import webspicy/scalars
2
-
3
- Todo = {
4
- id : Integer
5
- description : String
6
- }
7
-
8
- TodoPatch = {
9
- id : Integer
10
- description :? String
11
- }
12
-
13
- TodoPut = {
14
- id : Integer
15
- description : String
16
- }
17
-
18
- ErrorSchema = {
19
- error: String
20
- }
@@ -1,20 +0,0 @@
1
- require_relative 'must_be_authenticated'
2
- class MustBeAnAdmin < MustBeAuthenticated
3
- include Webspicy::Precondition
4
-
5
- def self.match(service, pre)
6
- MustBeAnAdmin.new(:admin) if pre =~ /Must be an admin/
7
- end
8
-
9
- def counterexamples(service)
10
- examples = super
11
- examples << counterexample(
12
- "When authenticated as a normal user",
13
- "user",
14
- "Admin required",
15
- 401
16
- )
17
- examples
18
- end
19
-
20
- end