webspicy 0.18.0 → 0.20.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/webspicy +6 -1
- data/doc/1-black-box-scene.md +109 -0
- data/doc/2-black-box-testing.md +27 -0
- data/doc/3-specification-importance.md +41 -0
- data/doc/4-sequence-diagram.md +82 -0
- data/lib/webspicy.rb +17 -9
- data/lib/webspicy/configuration.rb +48 -8
- data/lib/webspicy/configuration/scope.rb +22 -8
- data/lib/webspicy/formaldoc.fio +5 -5
- data/lib/webspicy/specification.rb +5 -2
- data/lib/webspicy/specification/condition.rb +48 -0
- data/lib/webspicy/specification/err.rb +18 -0
- data/lib/webspicy/specification/oldies.rb +4 -0
- data/lib/webspicy/specification/oldies/bridge.rb +32 -0
- data/lib/webspicy/specification/{errcondition.rb → oldies/errcondition.rb} +6 -0
- data/lib/webspicy/specification/{postcondition.rb → oldies/postcondition.rb} +6 -0
- data/lib/webspicy/specification/{precondition.rb → oldies/precondition.rb} +6 -2
- data/lib/webspicy/specification/post.rb +20 -0
- data/lib/webspicy/specification/post/missing_condition_impl.rb +15 -0
- data/lib/webspicy/specification/post/unexpected_condition_impl.rb +15 -0
- data/lib/webspicy/specification/pre.rb +19 -0
- data/lib/webspicy/specification/{precondition → pre}/global_request_headers.rb +4 -4
- data/lib/webspicy/specification/{precondition → pre}/robust_to_invalid_input.rb +4 -4
- data/lib/webspicy/specification/service.rb +34 -5
- data/lib/webspicy/specification/test_case.rb +11 -9
- data/lib/webspicy/support.rb +31 -0
- data/lib/webspicy/support/hooks.rb +65 -0
- data/lib/webspicy/support/world.rb +47 -0
- data/lib/webspicy/tester.rb +202 -3
- data/lib/webspicy/tester/assertions.rb +2 -2
- data/lib/webspicy/tester/client.rb +4 -50
- data/lib/webspicy/tester/fakeses.rb +41 -0
- data/lib/webspicy/tester/fakeses/email.rb +38 -0
- data/lib/webspicy/tester/fakesmtp.rb +39 -0
- data/lib/webspicy/tester/fakesmtp/email.rb +27 -0
- data/lib/webspicy/tester/file_checker.rb +22 -0
- data/lib/webspicy/tester/invocation.rb +15 -48
- data/lib/webspicy/tester/reporter.rb +85 -0
- data/lib/webspicy/tester/reporter/composite.rb +38 -0
- data/lib/webspicy/tester/reporter/documentation.rb +74 -0
- data/lib/webspicy/tester/reporter/error_count.rb +25 -0
- data/lib/webspicy/tester/reporter/exceptions.rb +62 -0
- data/lib/webspicy/tester/reporter/file_progress.rb +25 -0
- data/lib/webspicy/tester/reporter/file_summary.rb +43 -0
- data/lib/webspicy/tester/reporter/progress.rb +30 -0
- data/lib/webspicy/tester/reporter/summary.rb +63 -0
- data/lib/webspicy/tester/result.rb +142 -0
- data/lib/webspicy/tester/result/assert_met.rb +29 -0
- data/lib/webspicy/tester/result/check.rb +33 -0
- data/lib/webspicy/tester/result/errcondition_met.rb +29 -0
- data/lib/webspicy/tester/result/error_schema_met.rb +25 -0
- data/lib/webspicy/tester/result/invocation_succeeded.rb +13 -0
- data/lib/webspicy/tester/result/output_schema_met.rb +25 -0
- data/lib/webspicy/tester/result/postcondition_met.rb +29 -0
- data/lib/webspicy/tester/result/response_header_met.rb +43 -0
- data/lib/webspicy/tester/result/response_status_met.rb +25 -0
- data/lib/webspicy/version.rb +2 -2
- data/lib/webspicy/web.rb +4 -0
- data/lib/webspicy/web/client.rb +15 -0
- data/lib/webspicy/{tester → web}/client/http_client.rb +34 -14
- data/lib/webspicy/{tester → web}/client/rack_test_client.rb +3 -3
- data/lib/webspicy/{tester → web}/client/support.rb +2 -2
- data/lib/webspicy/web/invocation.rb +69 -0
- data/lib/webspicy/web/mocker.rb +90 -0
- data/lib/webspicy/{mocker → web/mocker}/config.ru +3 -2
- data/lib/webspicy/{openapi.rb → web/openapi.rb} +0 -0
- data/lib/webspicy/web/openapi/generator.rb +129 -0
- data/spec/unit/specification/{precondition → pre}/test_global_request_headers.rb +9 -4
- data/spec/unit/specification/test_condition.rb +44 -0
- data/spec/unit/support/hooks/test_fire_after_each.rb +53 -0
- data/spec/unit/{tester/client/test_around.rb → support/hooks/test_fire_around.rb} +15 -10
- data/spec/unit/support/hooks/test_fire_before_each.rb +53 -0
- data/spec/unit/support/world/fixtures/array.json +8 -0
- data/spec/unit/support/world/fixtures/queue.rb +1 -0
- data/spec/unit/support/world/fixtures/single.json +11 -0
- data/spec/unit/support/world/fixtures/yaml.yml +3 -0
- data/spec/unit/support/world/test_world.rb +56 -0
- data/spec/unit/test_configuration.rb +49 -0
- data/spec/unit/tester/fakeses/test_email.rb +40 -0
- data/spec/unit/web/mocker/test_mocker.rb +35 -0
- data/spec/unit/web/openapi/test_generator.rb +31 -0
- metadata +80 -65
- data/examples/restful/Gemfile +0 -5
- data/examples/restful/Rakefile +0 -25
- data/examples/restful/app.rb +0 -180
- data/examples/restful/webspicy/config.rb +0 -24
- data/examples/restful/webspicy/formaldef/todo/_one/delete.yml +0 -55
- data/examples/restful/webspicy/formaldef/todo/_one/get.simpler.yml +0 -46
- data/examples/restful/webspicy/formaldef/todo/_one/get.yml +0 -50
- data/examples/restful/webspicy/formaldef/todo/_one/patch.yml +0 -66
- data/examples/restful/webspicy/formaldef/todo/_one/put.yml +0 -65
- data/examples/restful/webspicy/formaldef/todo/get.yml +0 -36
- data/examples/restful/webspicy/formaldef/todo/options.yml +0 -32
- data/examples/restful/webspicy/formaldef/todo/post.csv.yml +0 -43
- data/examples/restful/webspicy/formaldef/todo/post.file.yml +0 -40
- data/examples/restful/webspicy/formaldef/todo/post.yml +0 -51
- data/examples/restful/webspicy/formaldef/todo/todos.csv +0 -4
- data/examples/restful/webspicy/rack.rb +0 -7
- data/examples/restful/webspicy/real.rb +0 -8
- data/examples/restful/webspicy/schema.fio +0 -20
- data/examples/restful/webspicy/support/must_be_an_admin.rb +0 -20
- data/examples/restful/webspicy/support/must_be_authenticated.rb +0 -48
- data/examples/restful/webspicy/support/todo_not_removed.rb +0 -21
- data/examples/restful/webspicy/support/todo_removed.rb +0 -20
- data/examples/single_spec/spec.yml +0 -59
- data/examples/website/config.rb +0 -2
- data/examples/website/schema.fio +0 -1
- data/examples/website/specification/get-http.yml +0 -30
- data/examples/website/specification/get-https.yml +0 -30
- data/lib/webspicy/checker.rb +0 -10
- data/lib/webspicy/mocker.rb +0 -88
- data/lib/webspicy/openapi/generator.rb +0 -127
- data/lib/webspicy/rspec/checker.rb +0 -2
- data/lib/webspicy/rspec/checker/rspec_checker.rb +0 -24
- data/lib/webspicy/rspec/support/rspec_runnable.rb +0 -27
- data/lib/webspicy/rspec/tester.rb +0 -4
- data/lib/webspicy/rspec/tester/rspec_asserter.rb +0 -121
- data/lib/webspicy/rspec/tester/rspec_matchers.rb +0 -114
- data/lib/webspicy/rspec/tester/rspec_tester.rb +0 -63
- data/spec/unit/mocker/test_mocker.rb +0 -32
- data/spec/unit/openapi/test_generator.rb +0 -28
@@ -1,114 +0,0 @@
|
|
1
|
-
require 'rspec/expectations'
|
2
|
-
|
3
|
-
RSpec::Matchers.define :match_response_status do |expected|
|
4
|
-
match do |actual|
|
5
|
-
expected === actual
|
6
|
-
end
|
7
|
-
failure_message_for_should do |actual|
|
8
|
-
"expected response status #{actual} to be #{expected}"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
RSpec::Matchers.define :have_no_response_type do
|
13
|
-
match do |actual|
|
14
|
-
actual.nil?
|
15
|
-
end
|
16
|
-
failure_message_for_should do |actual|
|
17
|
-
"expected Content-Type not to be present"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
RSpec::Matchers.define :match_content_type do |expected|
|
22
|
-
match do |actual|
|
23
|
-
actual.to_s.start_with?(expected.to_s)
|
24
|
-
end
|
25
|
-
failure_message_for_should do |actual|
|
26
|
-
"expected Content-Type to be `#{expected}`, got `#{actual}`"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
RSpec::Matchers.define :be_in_response_headers do |header_name|
|
31
|
-
match do |actual|
|
32
|
-
!actual.nil?
|
33
|
-
end
|
34
|
-
failure_message_for_should do |actual|
|
35
|
-
"expected response header `#{header_name}` to be set"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
RSpec::Matchers.define :match_response_header do |header_name, expected|
|
40
|
-
match do |actual|
|
41
|
-
expected == actual
|
42
|
-
end
|
43
|
-
failure_message_for_should do |actual|
|
44
|
-
"expected response header `#{header_name}` to be `#{expected}`, got `#{actual}`"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
RSpec::Matchers.define :be_an_empty_response_body do
|
49
|
-
match do |actual|
|
50
|
-
actual.empty?
|
51
|
-
end
|
52
|
-
failure_message_for_should do |actual|
|
53
|
-
"expected response body to be empty, started with `#{actual[0..20]}`"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
RSpec::Matchers.define :meet_output_schema do
|
58
|
-
match do |actual|
|
59
|
-
!actual.is_a?(Exception)
|
60
|
-
end
|
61
|
-
failure_message_for_should do |actual|
|
62
|
-
"expected response body to meet output schema, got following error:\n" + \
|
63
|
-
" #{actual.message}"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
RSpec::Matchers.define :meet_error_schema do
|
68
|
-
match do |actual|
|
69
|
-
!actual.is_a?(Exception)
|
70
|
-
end
|
71
|
-
failure_message_for_should do |actual|
|
72
|
-
"expected response body to meet error schema, got following error:\n" + \
|
73
|
-
" #{actual.message}"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
RSpec::Matchers.define :meet_assertion do |assert|
|
78
|
-
match do |actual|
|
79
|
-
actual.nil?
|
80
|
-
end
|
81
|
-
failure_message_for_should do |actual|
|
82
|
-
"expected assertion `#{assert}` to be met, got following error:\n" + \
|
83
|
-
" #{actual.message}"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
RSpec::Matchers.define :meet_postcondition do |post|
|
88
|
-
match do |actual|
|
89
|
-
actual.nil?
|
90
|
-
end
|
91
|
-
failure_message_for_should do |actual|
|
92
|
-
"expected postcondition `#{post.class.name}` to be met, got following error:\n" + \
|
93
|
-
" #{actual}"
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
RSpec::Matchers.define :meet_errcondition do |post|
|
98
|
-
match do |actual|
|
99
|
-
actual.nil?
|
100
|
-
end
|
101
|
-
failure_message_for_should do |actual|
|
102
|
-
"expected errcondition `#{post.class.name}` to be met, got following error:\n" + \
|
103
|
-
" #{actual}"
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
RSpec::Matchers.define :be_an_empty_errors_array do
|
108
|
-
match do |actual|
|
109
|
-
actual.empty?
|
110
|
-
end
|
111
|
-
failure_message_for_should do |actual|
|
112
|
-
"expected no webspicy error, got the following ones:\n" + actual.map{|a| " #{a}" }.join("\n")
|
113
|
-
end
|
114
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
module Webspicy
|
2
|
-
class Tester
|
3
|
-
class RSpecTester
|
4
|
-
include Webspicy::Support::RSpecRunnable
|
5
|
-
|
6
|
-
protected
|
7
|
-
|
8
|
-
def load_rspec_examples
|
9
|
-
tester = self
|
10
|
-
RSpec.describe "Webspicy test suite" do
|
11
|
-
before(:all) do
|
12
|
-
tester.config.listeners(:before_all).each do |l|
|
13
|
-
l.call(tester.config)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
after(:all) do
|
17
|
-
tester.config.listeners(:after_all).each do |l|
|
18
|
-
l.call(tester.config)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
tester.config.each_scope do |scope|
|
22
|
-
client = scope.get_client
|
23
|
-
scope.each_specification do |specification|
|
24
|
-
scope.each_service(specification) do |service|
|
25
|
-
scope.each_testcase(service) do |test_case|
|
26
|
-
str = "#{service} #{test_case}"
|
27
|
-
str = Webspicy::Support::Colorize.colorize_highlight(str, tester.config)
|
28
|
-
describe(str) do
|
29
|
-
|
30
|
-
around(:each) do |example|
|
31
|
-
client.around(test_case) do
|
32
|
-
client.before(test_case)
|
33
|
-
test_case.instrument(client)
|
34
|
-
client.instrument(test_case)
|
35
|
-
@response = client.call(test_case)
|
36
|
-
@invocation = Tester::Invocation.new(test_case, @response, client)
|
37
|
-
example.run
|
38
|
-
client.after(test_case, @invocation)
|
39
|
-
@invocation
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
let(:invocation) do
|
44
|
-
@invocation
|
45
|
-
end
|
46
|
-
|
47
|
-
it "meets its specification" do
|
48
|
-
raise "Test not ran" unless invocation.done?
|
49
|
-
RSpecAsserter.call(self, invocation)
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
self
|
59
|
-
end
|
60
|
-
|
61
|
-
end # class RSpecTester
|
62
|
-
end # class Tester
|
63
|
-
end # module Webspicy
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rack/test'
|
3
|
-
require 'webspicy/mocker'
|
4
|
-
module Webspicy
|
5
|
-
describe Mocker do
|
6
|
-
include Rack::Test::Methods
|
7
|
-
|
8
|
-
let(:app) {
|
9
|
-
Mocker.new(Configuration.dress(restful_folder))
|
10
|
-
}
|
11
|
-
|
12
|
-
it 'works as expected' do
|
13
|
-
get '/todo/'
|
14
|
-
expect(last_response.status).to eql(200)
|
15
|
-
expect(last_response.body).not_to be_empty
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'supports CORS on OPTIONS' do
|
19
|
-
options '/todo/'
|
20
|
-
expect(last_response.status).to eql(204)
|
21
|
-
expect(last_response.body).to be_empty
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'returns the correct status code, taken from first example' do
|
25
|
-
delete '/todo/1'
|
26
|
-
expect(last_response.status).to eql(204)
|
27
|
-
expect(last_response.body).to be_empty
|
28
|
-
expect(last_response["Content-Type"]).to be_nil
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'webspicy/openapi'
|
3
|
-
require 'openapi3_parser'
|
4
|
-
module Webspicy
|
5
|
-
module Openapi
|
6
|
-
describe Generator do
|
7
|
-
|
8
|
-
let(:config) {
|
9
|
-
Configuration.new(restful_folder)
|
10
|
-
}
|
11
|
-
|
12
|
-
subject {
|
13
|
-
ruby_objs = Generator.new(config).call
|
14
|
-
JSON.parse(ruby_objs.to_json)
|
15
|
-
}
|
16
|
-
|
17
|
-
it 'works fine' do
|
18
|
-
document = Openapi3Parser.load(subject)
|
19
|
-
#puts JSON.pretty_generate(subject)
|
20
|
-
document.errors.each do |err|
|
21
|
-
puts err.inspect
|
22
|
-
end unless document.errors.empty?
|
23
|
-
expect(document.errors).to be_empty
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|