webspicy 0.15.8 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +71 -24
  3. data/bin/webspicy +30 -14
  4. data/examples/restful/Gemfile.lock +38 -23
  5. data/examples/restful/Rakefile +0 -1
  6. data/examples/restful/app.rb +4 -1
  7. data/examples/restful/webspicy/config.rb +8 -0
  8. data/examples/restful/webspicy/rack.rb +1 -1
  9. data/examples/restful/webspicy/real.rb +1 -1
  10. data/examples/restful/webspicy/schema.fio +2 -2
  11. data/examples/restful/webspicy/support/must_be_authenticated.rb +2 -2
  12. data/examples/restful/webspicy/support/todo_removed.rb +18 -0
  13. data/examples/restful/webspicy/todo/deleteTodo.yml +4 -1
  14. data/examples/restful/webspicy/todo/getTodoSingleServiceFormat.yml +46 -0
  15. data/examples/restful/webspicy/todo/options.yml +1 -1
  16. data/examples/restful/webspicy/todo/patchTodo.yml +3 -0
  17. data/examples/restful/webspicy/todo/postFile.yml +1 -1
  18. data/examples/single_spec/spec.yml +59 -0
  19. data/examples/website/config.rb +2 -0
  20. data/examples/website/schema.fio +1 -0
  21. data/examples/website/specification/get-http.yml +34 -0
  22. data/examples/website/specification/get-https.yml +34 -0
  23. data/lib/finitio/webspicy/scalars.fio +25 -0
  24. data/lib/webspicy.rb +48 -17
  25. data/lib/webspicy/checker.rb +2 -2
  26. data/lib/webspicy/configuration.rb +70 -14
  27. data/lib/webspicy/configuration/scope.rb +162 -0
  28. data/lib/webspicy/configuration/single_url.rb +58 -0
  29. data/lib/webspicy/configuration/single_yml_file.rb +30 -0
  30. data/lib/webspicy/formaldoc.fio +23 -8
  31. data/lib/webspicy/mocker.rb +8 -8
  32. data/lib/webspicy/openapi.rb +1 -0
  33. data/lib/webspicy/openapi/generator.rb +127 -0
  34. data/lib/webspicy/{resource.rb → specification.rb} +26 -5
  35. data/lib/webspicy/specification/file_upload.rb +37 -0
  36. data/lib/webspicy/specification/postcondition.rb +16 -0
  37. data/lib/webspicy/specification/precondition.rb +19 -0
  38. data/lib/webspicy/specification/precondition/global_request_headers.rb +35 -0
  39. data/lib/webspicy/specification/precondition/robust_to_invalid_input.rb +68 -0
  40. data/lib/webspicy/{resource → specification}/service.rb +11 -6
  41. data/lib/webspicy/specification/test_case.rb +139 -0
  42. data/lib/webspicy/support.rb +1 -0
  43. data/lib/webspicy/support/colorize.rb +28 -0
  44. data/lib/webspicy/support/status_range.rb +6 -1
  45. data/lib/webspicy/tester.rb +16 -11
  46. data/lib/webspicy/tester/asserter.rb +3 -2
  47. data/lib/webspicy/tester/assertions.rb +5 -1
  48. data/lib/webspicy/tester/client.rb +63 -0
  49. data/lib/webspicy/tester/client/http_client.rb +154 -0
  50. data/lib/webspicy/tester/client/rack_test_client.rb +188 -0
  51. data/lib/webspicy/tester/client/support.rb +65 -0
  52. data/lib/webspicy/tester/invocation.rb +218 -0
  53. data/lib/webspicy/tester/rspec_asserter.rb +108 -0
  54. data/lib/webspicy/tester/rspec_matchers.rb +104 -0
  55. data/lib/webspicy/version.rb +2 -2
  56. data/spec/{unit/spec_helper.rb → spec_helper.rb} +0 -0
  57. data/spec/unit/configuration/scope/test_each_service.rb +49 -0
  58. data/spec/unit/configuration/scope/test_each_specification.rb +68 -0
  59. data/spec/unit/configuration/scope/test_expand_example.rb +65 -0
  60. data/spec/unit/configuration/scope/test_to_real_url.rb +82 -0
  61. data/spec/unit/openapi/test_generator.rb +28 -0
  62. data/spec/unit/specification/precondition/test_global_request_headers.rb +42 -0
  63. data/spec/unit/{resource → specification}/service/test_dress_params.rb +2 -2
  64. data/spec/unit/specification/test_case/test_mutate.rb +24 -0
  65. data/spec/unit/{resource → specification}/test_instantiate_url.rb +5 -5
  66. data/spec/unit/{resource → specification}/test_url_placeholders.rb +4 -4
  67. data/spec/unit/test_configuration.rb +24 -7
  68. data/spec/unit/tester/client/test_around.rb +61 -0
  69. data/spec/unit/tester/test_asserter.rb +51 -0
  70. data/spec/unit/tester/test_assertions.rb +4 -4
  71. data/tasks/test.rake +3 -1
  72. metadata +83 -34
  73. data/lib/webspicy/client.rb +0 -61
  74. data/lib/webspicy/client/http_client.rb +0 -145
  75. data/lib/webspicy/client/rack_test_client.rb +0 -181
  76. data/lib/webspicy/client/support.rb +0 -48
  77. data/lib/webspicy/file_upload.rb +0 -35
  78. data/lib/webspicy/postcondition.rb +0 -14
  79. data/lib/webspicy/precondition.rb +0 -15
  80. data/lib/webspicy/resource/service/invocation.rb +0 -212
  81. data/lib/webspicy/resource/service/test_case.rb +0 -132
  82. data/lib/webspicy/scope.rb +0 -160
  83. data/spec/unit/client/test_around.rb +0 -59
  84. data/spec/unit/scope/test_each_resource.rb +0 -66
  85. data/spec/unit/scope/test_each_service.rb +0 -47
  86. data/spec/unit/scope/test_expand_example.rb +0 -63
  87. data/spec/unit/scope/test_to_real_url.rb +0 -80
@@ -1,63 +0,0 @@
1
- require 'spec_helper'
2
- module Webspicy
3
- describe Scope, "expand_example" do
4
-
5
- subject{ Scope.new({}).send(:expand_example, service, example) }
6
-
7
- context 'when the service has no default example' do
8
- let(:service) {
9
- Webspicy.service({
10
- method: "GET",
11
- description: "Test service",
12
- preconditions: "Foo",
13
- input_schema: "{ id: Integer }",
14
- output_schema: "{}",
15
- error_schema: "{}"
16
- })
17
- }
18
-
19
- let(:example) {
20
- Webspicy.test_case({
21
- description: "Hello world"
22
- })
23
- }
24
-
25
- it 'returns the example itself' do
26
- expect(subject).to be(example)
27
- end
28
- end
29
-
30
- context 'when the service has a default example' do
31
- let(:service) {
32
- Webspicy.service({
33
- method: "GET",
34
- description: "Test service",
35
- preconditions: "Foo",
36
- input_schema: "{ id: Integer }",
37
- output_schema: "{}",
38
- error_schema: "{}",
39
- default_example: {
40
- expected: { status: 200 }
41
- }
42
- })
43
- }
44
-
45
- let(:example) {
46
- Webspicy.test_case({
47
- description: "Hello world",
48
- expected: { content_type: "application/json" }
49
- })
50
- }
51
-
52
- it 'deep merges the default example and the example as expected' do
53
- expect(subject).to be_a(Resource::Service::TestCase)
54
- expect(subject.description).to eql("Hello world")
55
- expect(subject.expected).to eql({
56
- status: Support::StatusRange.int(200),
57
- content_type: "application/json"
58
- })
59
- end
60
- end
61
-
62
- end
63
- end # module Webspicy
@@ -1,80 +0,0 @@
1
- require 'spec_helper'
2
- module Webspicy
3
- describe Scope, 'to_real_url' do
4
-
5
- let(:scope) {
6
- Scope.new(configuration)
7
- }
8
-
9
- context 'when no host at all' do
10
-
11
- let(:configuration) {
12
- Configuration.new
13
- }
14
-
15
- it 'does nothing on absolute URLs already' do
16
- url = 'http://127.0.0.1:4567/todo'
17
- got = scope.to_real_url(url)
18
- expect(got).to eql(url)
19
- end
20
-
21
- it 'yields the block relative URLs' do
22
- got = scope.to_real_url("/todo"){ "hello" }
23
- expect(got).to eql("hello")
24
- end
25
-
26
- it 'fails on relative URLs and no block is given' do
27
- expect(->(){
28
- scope.to_real_url("/todo")
29
- }).to raise_error(/Unable to resolve `\/todo`/)
30
- end
31
- end
32
-
33
- context 'with a static host' do
34
-
35
- let(:configuration) {
36
- Configuration.new do |c|
37
- c.host = "http://127.0.0.1:4568"
38
- end
39
- }
40
-
41
- it 'does nothing on absolute URLs already' do
42
- url = 'http://127.0.0.1:4567/todo'
43
- got = scope.to_real_url(url)
44
- expect(got).to eql(url)
45
- end
46
-
47
- it 'resolves relative URLs as expected' do
48
- url = '/todo'
49
- got = scope.to_real_url(url)
50
- expect(got).to eql("http://127.0.0.1:4568/todo")
51
- end
52
-
53
- end
54
-
55
- context 'with a dynamic host resolver' do
56
-
57
- let(:configuration) {
58
- Configuration.new do |c|
59
- c.host = ->(url, tc) {
60
- "http://127.0.0.1:4568#{url}"
61
- }
62
- end
63
- }
64
-
65
- it 'resolves absolute URLs' do
66
- url = 'http://127.0.0.1:4567/todo'
67
- got = scope.to_real_url(url)
68
- expect(got).to eql("http://127.0.0.1:4568#{url}")
69
- end
70
-
71
- it 'resolves relative URLs as expected' do
72
- url = '/todo'
73
- got = scope.to_real_url(url)
74
- expect(got).to eql("http://127.0.0.1:4568/todo")
75
- end
76
-
77
- end
78
-
79
- end
80
- end