webspicy 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/restful/Rakefile +3 -17
- data/examples/restful/webspicy/config.rb +1 -0
- data/examples/restful/webspicy/rack.rb +6 -0
- data/examples/restful/webspicy/real.rb +7 -0
- data/lib/webspicy/checker.rb +1 -1
- data/lib/webspicy/client/http_client.rb +3 -1
- data/lib/webspicy/client/rack_test_client.rb +15 -4
- data/lib/webspicy/configuration.rb +37 -0
- data/lib/webspicy/formaldoc.fio +7 -7
- data/lib/webspicy/resource/service/invocation.rb +9 -0
- data/lib/webspicy/resource/service/test_case.rb +16 -1
- data/lib/webspicy/resource/service.rb +71 -0
- data/lib/webspicy/resource.rb +9 -0
- data/lib/webspicy/scope.rb +22 -3
- data/lib/webspicy/tester.rb +47 -73
- data/lib/webspicy/version.rb +1 -1
- data/lib/webspicy.rb +9 -0
- data/spec/unit/configuration/config.rb +3 -0
- data/spec/unit/test_configuration.rb +43 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 316f44001f615a30f037e1bced5a2988df1e85c2
|
4
|
+
data.tar.gz: af13f64c5f2096dfaf1fea51dbc119a30a9ac4f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0c0c064b0c096fea8a4520356f08104dd796778b88c3564abdc5eb61adcb41d0ccf8e08fd513adc57f6f1cf6a88437a52ba15f72494cf09f45d2254899ed196
|
7
|
+
data.tar.gz: aba64e2492ba14d5f89f867508f3f737893b6d42cd2776dafc4932b8a1e8d93ca22461694161cc8da7e5a38238be940b7c08d1f11857fe2e4f854669ce2b8156
|
data/examples/restful/Rakefile
CHANGED
@@ -4,32 +4,18 @@ require 'webspicy'
|
|
4
4
|
|
5
5
|
desc "Checks all .yml definition files"
|
6
6
|
task :check do
|
7
|
-
|
8
|
-
Webspicy::Checker.new(config).call
|
7
|
+
Webspicy::Checker.new(Path.dir/'webspicy').call
|
9
8
|
end
|
10
9
|
|
11
10
|
namespace :test do
|
12
11
|
desc "Run all tests directly on Sinatra application using rack/test"
|
13
12
|
task :rack do
|
14
|
-
|
15
|
-
c.client = Webspicy::RackTestClient.for(::Sinatra::Application)
|
16
|
-
c.before_each do |_,_,_,client|
|
17
|
-
client.api.post "/reset"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
Webspicy::Tester.new(config).call
|
13
|
+
Webspicy::Tester.new(Path.dir/'webspicy/rack.rb').call
|
21
14
|
end
|
22
15
|
|
23
16
|
desc "Runs all tests on the real web server (must be launched previously)"
|
24
17
|
task :real do
|
25
|
-
|
26
|
-
c.host = "http://127.0.0.1:4567"
|
27
|
-
c.client = Webspicy::HttpClient
|
28
|
-
c.before_each do |_,_,_,client|
|
29
|
-
client.api.post "http://127.0.0.1:4567/reset"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
Webspicy::Tester.new(config).call
|
18
|
+
Webspicy::Tester.new(Path.dir/'webspicy/real.rb').call
|
33
19
|
end
|
34
20
|
end
|
35
21
|
|
@@ -0,0 +1 @@
|
|
1
|
+
Webspicy::Configuration.new(Path.dir)
|
data/lib/webspicy/checker.rb
CHANGED
@@ -7,7 +7,9 @@ module Webspicy
|
|
7
7
|
end
|
8
8
|
attr_reader :api
|
9
9
|
|
10
|
-
def call(test_case
|
10
|
+
def call(test_case)
|
11
|
+
service, resource = test_case.service, test_case.resource
|
12
|
+
|
11
13
|
# Instantiate the parameters
|
12
14
|
headers = test_case.headers
|
13
15
|
params = test_case.dress_params? ? service.dress_params(test_case.params) : test_case.params
|
@@ -5,19 +5,24 @@ module Webspicy
|
|
5
5
|
Factory.new(app)
|
6
6
|
end
|
7
7
|
|
8
|
-
def initialize(scope, app)
|
8
|
+
def initialize(scope, app, domain)
|
9
9
|
super(scope)
|
10
10
|
@api = Api.new(app)
|
11
|
+
@domain = domain
|
11
12
|
end
|
12
13
|
attr_reader :api
|
14
|
+
attr_reader :domain
|
15
|
+
|
16
|
+
def call(test_case)
|
17
|
+
service, resource = test_case.service, test_case.resource
|
13
18
|
|
14
|
-
def call(test_case, service, resource)
|
15
19
|
# Instantiate the parameters
|
16
|
-
headers = test_case.headers
|
20
|
+
headers = test_case.headers.dup
|
17
21
|
params = test_case.dress_params? ? service.dress_params(test_case.params) : test_case.params
|
18
22
|
|
19
23
|
# Instantiate the url and strip parameters
|
20
24
|
url, params = resource.instantiate_url(params)
|
25
|
+
url = "http://#{domain}#{url}" if domain
|
21
26
|
|
22
27
|
# Invoke the service now
|
23
28
|
api.public_send(service.method.to_s.downcase.to_sym, url, params, headers)
|
@@ -32,9 +37,15 @@ module Webspicy
|
|
32
37
|
@app = app
|
33
38
|
end
|
34
39
|
attr_reader :app
|
40
|
+
attr_reader :domain
|
41
|
+
|
42
|
+
def on(domain)
|
43
|
+
@domain = domain
|
44
|
+
self
|
45
|
+
end
|
35
46
|
|
36
47
|
def new(scope)
|
37
|
-
RackTestClient.new(scope, app)
|
48
|
+
RackTestClient.new(scope, app, domain)
|
38
49
|
end
|
39
50
|
|
40
51
|
end # class Factory
|
@@ -5,17 +5,38 @@ module Webspicy
|
|
5
5
|
@folder = folder
|
6
6
|
@parent = parent
|
7
7
|
@children = []
|
8
|
+
@preconditions = []
|
9
|
+
@postconditions = []
|
8
10
|
@before_listeners = []
|
9
11
|
@rspec_options = default_rspec_options
|
10
12
|
@run_counterexamples = default_run_counterexamples
|
11
13
|
@file_filter = default_file_filter
|
12
14
|
@service_filter = default_service_filter
|
13
15
|
@client = HttpClient
|
16
|
+
Path.require_tree(folder/'support') if (folder/'support').exists?
|
14
17
|
yield(self) if block_given?
|
15
18
|
end
|
16
19
|
attr_accessor :folder
|
17
20
|
protected :folder=
|
18
21
|
|
22
|
+
def self.dress(arg, &bl)
|
23
|
+
return arg if arg.is_a?(Configuration)
|
24
|
+
arg = Path(arg)
|
25
|
+
if arg.file?
|
26
|
+
c = Kernel.instance_eval arg.read, arg.to_s
|
27
|
+
yield(c) if block_given?
|
28
|
+
c
|
29
|
+
elsif (arg/'config.rb').file?
|
30
|
+
dress(arg/'config.rb', &bl)
|
31
|
+
else
|
32
|
+
raise ArgumentError, "Missing config.rb file"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.inherits(*args, &bl)
|
37
|
+
dress(*args, &bl)
|
38
|
+
end
|
39
|
+
|
19
40
|
attr_accessor :parent
|
20
41
|
protected :parent=
|
21
42
|
|
@@ -51,6 +72,20 @@ module Webspicy
|
|
51
72
|
attr_accessor :children
|
52
73
|
protected :children=
|
53
74
|
|
75
|
+
# Registers a precondition matcher
|
76
|
+
def precondition(clazz)
|
77
|
+
preconditions << clazz
|
78
|
+
end
|
79
|
+
attr_accessor :preconditions
|
80
|
+
protected :preconditions=
|
81
|
+
|
82
|
+
# Registers a postcondition matcher
|
83
|
+
def postcondition(clazz)
|
84
|
+
postconditions << clazz
|
85
|
+
end
|
86
|
+
attr_accessor :postconditions
|
87
|
+
protected :postconditions=
|
88
|
+
|
54
89
|
# Returns whether this configuration has children configurations or not
|
55
90
|
def has_children?
|
56
91
|
!children.empty?
|
@@ -229,6 +264,8 @@ module Webspicy
|
|
229
264
|
def dup(&bl)
|
230
265
|
super.tap do |d|
|
231
266
|
d.children = []
|
267
|
+
d.preconditions = self.preconditions.dup
|
268
|
+
d.postconditions = self.postconditions.dup
|
232
269
|
d.rspec_options = self.rspec_options.dup
|
233
270
|
d.before_listeners = self.before_listeners.dup
|
234
271
|
yield d if block_given?
|
data/lib/webspicy/formaldoc.fio
CHANGED
@@ -15,13 +15,13 @@ Resource =
|
|
15
15
|
|
16
16
|
Service =
|
17
17
|
.Webspicy::Resource::Service <info> {
|
18
|
-
method :
|
19
|
-
description :
|
20
|
-
preconditions
|
21
|
-
postconditions :? String
|
22
|
-
input_schema :
|
23
|
-
output_schema :
|
24
|
-
error_schema :
|
18
|
+
method : Method
|
19
|
+
description : String
|
20
|
+
preconditions :? [String]|String
|
21
|
+
postconditions :? [String]|String
|
22
|
+
input_schema : Schema
|
23
|
+
output_schema : Schema
|
24
|
+
error_schema : Schema
|
25
25
|
blackbox :? String
|
26
26
|
examples :? [TestCase]
|
27
27
|
counterexamples :? [TestCase]
|
@@ -141,6 +141,15 @@ module Webspicy
|
|
141
141
|
unmet.empty? ? nil : unmet.join("\n")
|
142
142
|
end
|
143
143
|
|
144
|
+
### Check of postconditions
|
145
|
+
|
146
|
+
def postconditions_unmet
|
147
|
+
failures = service.postconditions.map{|post|
|
148
|
+
post.check(self)
|
149
|
+
}.compact
|
150
|
+
failures.empty? ? nil : failures.join("\n")
|
151
|
+
end
|
152
|
+
|
144
153
|
private
|
145
154
|
|
146
155
|
def loaded_body
|
@@ -6,6 +6,11 @@ module Webspicy
|
|
6
6
|
def initialize(raw)
|
7
7
|
@raw = raw
|
8
8
|
end
|
9
|
+
attr_accessor :service
|
10
|
+
|
11
|
+
def resource
|
12
|
+
service.resource
|
13
|
+
end
|
9
14
|
|
10
15
|
def self.info(raw)
|
11
16
|
new(raw)
|
@@ -20,7 +25,7 @@ module Webspicy
|
|
20
25
|
end
|
21
26
|
|
22
27
|
def headers
|
23
|
-
@raw[:headers]
|
28
|
+
@raw[:headers] ||= {}
|
24
29
|
end
|
25
30
|
|
26
31
|
def dress_params
|
@@ -68,6 +73,16 @@ module Webspicy
|
|
68
73
|
@raw
|
69
74
|
end
|
70
75
|
|
76
|
+
def instrument
|
77
|
+
service.preconditions.each do |pre|
|
78
|
+
pre.ensure(self)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def to_s
|
83
|
+
description
|
84
|
+
end
|
85
|
+
|
71
86
|
end # class TestCase
|
72
87
|
end # class Service
|
73
88
|
end # class Resource
|
@@ -4,7 +4,12 @@ module Webspicy
|
|
4
4
|
|
5
5
|
def initialize(raw)
|
6
6
|
@raw = raw
|
7
|
+
bind_examples
|
8
|
+
bind_counterexamples
|
9
|
+
@preconditions = compile_preconditions
|
10
|
+
@postconditions = compile_postconditions
|
7
11
|
end
|
12
|
+
attr_accessor :resource
|
8
13
|
|
9
14
|
def self.info(raw)
|
10
15
|
new(raw)
|
@@ -14,6 +19,22 @@ module Webspicy
|
|
14
19
|
@raw[:method]
|
15
20
|
end
|
16
21
|
|
22
|
+
def preconditions
|
23
|
+
@preconditions
|
24
|
+
end
|
25
|
+
|
26
|
+
def has_preconditions?
|
27
|
+
!preconditions.empty?
|
28
|
+
end
|
29
|
+
|
30
|
+
def postconditions
|
31
|
+
@postconditions
|
32
|
+
end
|
33
|
+
|
34
|
+
def has_postconditions?
|
35
|
+
!postconditions.empty?
|
36
|
+
end
|
37
|
+
|
17
38
|
def examples
|
18
39
|
@raw[:examples]
|
19
40
|
end
|
@@ -22,6 +43,16 @@ module Webspicy
|
|
22
43
|
@raw[:counterexamples]
|
23
44
|
end
|
24
45
|
|
46
|
+
def generated_counterexamples
|
47
|
+
preconditions.map{|pre|
|
48
|
+
pre.counterexamples(self).map{|tc|
|
49
|
+
tc = Webspicy.test_case(tc, Webspicy.current_scope)
|
50
|
+
tc.service = self
|
51
|
+
tc
|
52
|
+
}
|
53
|
+
}.flatten
|
54
|
+
end
|
55
|
+
|
25
56
|
def input_schema
|
26
57
|
@raw[:input_schema]
|
27
58
|
end
|
@@ -42,6 +73,46 @@ module Webspicy
|
|
42
73
|
@raw
|
43
74
|
end
|
44
75
|
|
76
|
+
def to_s
|
77
|
+
"#{method} #{resource.url}"
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def scope
|
83
|
+
Webspicy.current_scope
|
84
|
+
end
|
85
|
+
|
86
|
+
def compile_preconditions
|
87
|
+
@raw[:preconditions] = [@raw[:preconditions]] if @raw[:preconditions].is_a?(String)
|
88
|
+
compile_conditions(@raw[:preconditions] ||= [], scope.preconditions)
|
89
|
+
end
|
90
|
+
|
91
|
+
def compile_postconditions
|
92
|
+
@raw[:postconditions] = [@raw[:postconditions]] if @raw[:postconditions].is_a?(String)
|
93
|
+
compile_conditions(@raw[:postconditions] ||= [], scope.postconditions)
|
94
|
+
end
|
95
|
+
|
96
|
+
def compile_conditions(descriptions, conditions)
|
97
|
+
descriptions
|
98
|
+
.map{|descr|
|
99
|
+
conditions.map{|c| c.match(self, descr) }.compact
|
100
|
+
}
|
101
|
+
.flatten
|
102
|
+
end
|
103
|
+
|
104
|
+
def bind_examples
|
105
|
+
(@raw[:examples] ||= []).each do |ex|
|
106
|
+
ex.service = self
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def bind_counterexamples
|
111
|
+
(@raw[:counterexamples] ||= []).each do |ex|
|
112
|
+
ex.service = self
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
45
116
|
end # class Service
|
46
117
|
end # class Resource
|
47
118
|
end # module Webspicy
|
data/lib/webspicy/resource.rb
CHANGED
@@ -3,6 +3,7 @@ module Webspicy
|
|
3
3
|
|
4
4
|
def initialize(raw)
|
5
5
|
@raw = raw
|
6
|
+
bind_services
|
6
7
|
end
|
7
8
|
|
8
9
|
def self.info(raw)
|
@@ -38,6 +39,14 @@ module Webspicy
|
|
38
39
|
@raw
|
39
40
|
end
|
40
41
|
|
42
|
+
private
|
43
|
+
|
44
|
+
def bind_services
|
45
|
+
(@raw[:services] ||= []).each do |s|
|
46
|
+
s.resource = self
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
41
50
|
end
|
42
51
|
end
|
43
52
|
require_relative 'resource/service'
|
data/lib/webspicy/scope.rb
CHANGED
@@ -6,6 +6,14 @@ module Webspicy
|
|
6
6
|
end
|
7
7
|
attr_reader :config
|
8
8
|
|
9
|
+
def preconditions
|
10
|
+
config.preconditions
|
11
|
+
end
|
12
|
+
|
13
|
+
def postconditions
|
14
|
+
config.postconditions
|
15
|
+
end
|
16
|
+
|
9
17
|
###
|
10
18
|
### Eachers -- Allow navigating the web service definitions
|
11
19
|
###
|
@@ -38,14 +46,25 @@ module Webspicy
|
|
38
46
|
resource.services.select(&to_filter_proc(config.service_filter)).each(&bl)
|
39
47
|
end
|
40
48
|
|
41
|
-
def each_example(service
|
42
|
-
service.examples.each(
|
49
|
+
def each_example(service)
|
50
|
+
service.examples.each{|s| yield(s, false) }
|
43
51
|
end
|
44
52
|
|
45
53
|
def each_counterexamples(service, &bl)
|
46
|
-
service.counterexamples.each(
|
54
|
+
service.counterexamples.each{|s| yield(s, true) } if config.run_counterexamples?
|
47
55
|
end
|
48
56
|
|
57
|
+
def each_generated_counterexamples(service, &bl)
|
58
|
+
Webspicy.with_scope(self) do
|
59
|
+
service.generated_counterexamples.each{|s| yield(s, true) }
|
60
|
+
end if config.run_counterexamples?
|
61
|
+
end
|
62
|
+
|
63
|
+
def each_testcase(service, &bl)
|
64
|
+
each_example(service, &bl)
|
65
|
+
each_counterexamples(service, &bl)
|
66
|
+
each_generated_counterexamples(service, &bl)
|
67
|
+
end
|
49
68
|
|
50
69
|
###
|
51
70
|
### Schemas -- For parsing input and output data schemas found in
|
data/lib/webspicy/tester.rb
CHANGED
@@ -2,96 +2,70 @@ module Webspicy
|
|
2
2
|
class Tester
|
3
3
|
|
4
4
|
def initialize(config)
|
5
|
-
@config = config
|
5
|
+
@config = Configuration.dress(config)
|
6
6
|
end
|
7
7
|
attr_reader :config
|
8
8
|
|
9
9
|
def call
|
10
|
+
rspec_config!
|
10
11
|
config.each_scope do |scope|
|
11
12
|
client = scope.get_client
|
12
13
|
scope.each_resource do |resource|
|
13
14
|
scope.each_service(resource) do |service|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@invocation ||= client.call(test_case, service, resource)
|
21
|
-
end
|
22
|
-
|
23
|
-
subject do
|
24
|
-
@invocation
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'can be invoked successfuly' do
|
28
|
-
expect(subject.done?).to eq(true)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'meets the status and content type specification' do
|
32
|
-
expect(subject.expected_status_unmet).to(be_nil)
|
33
|
-
expect(subject.expected_content_type_unmet).to(be_nil)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'has the expected response headers' do
|
37
|
-
expect(subject.expected_headers_unmet).to(be_nil)
|
38
|
-
end if test_case.has_expected_headers?
|
39
|
-
|
40
|
-
it 'meets the output data schema' do
|
41
|
-
expect(subject.expected_schema_unmet).to(be_nil)
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'meets all assertions' do
|
45
|
-
expect(subject.assertions_unmet).to(be_nil)
|
46
|
-
end if test_case.has_assertions?
|
47
|
-
|
48
|
-
end
|
49
|
-
end # service.examples
|
50
|
-
|
51
|
-
scope.each_counterexamples(service) do |test_case|
|
52
|
-
describe test_case.description do
|
53
|
-
|
54
|
-
before(:all) do
|
55
|
-
client.before(test_case, service, resource)
|
56
|
-
@invocation ||= client.call(test_case, service, resource)
|
57
|
-
end
|
15
|
+
rspec_service!(service, client, scope)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
RSpec::Core::Runner.run config.rspec_options
|
20
|
+
end
|
58
21
|
|
59
|
-
|
60
|
-
|
61
|
-
|
22
|
+
def rspec_service!(service, client, scope)
|
23
|
+
RSpec.describe service do
|
24
|
+
scope.each_testcase(service) do |test_case, counterexample|
|
25
|
+
describe test_case do
|
26
|
+
include_examples 'a successful test case invocation', client, test_case, counterexample
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
62
31
|
|
63
|
-
|
64
|
-
|
65
|
-
|
32
|
+
def rspec_config!
|
33
|
+
return if @rspec_config
|
34
|
+
RSpec.shared_examples "a successful test case invocation" do |client, test_case, counterexample|
|
66
35
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
36
|
+
before(:all) do
|
37
|
+
@invocation ||= begin
|
38
|
+
test_case.instrument
|
39
|
+
client.before(test_case)
|
40
|
+
client.call(test_case)
|
41
|
+
end
|
42
|
+
end
|
71
43
|
|
72
|
-
|
73
|
-
|
74
|
-
|
44
|
+
let(:invocation) do
|
45
|
+
@invocation
|
46
|
+
end
|
75
47
|
|
76
|
-
|
77
|
-
|
78
|
-
|
48
|
+
it 'meets the HTTP specification' do
|
49
|
+
expect(invocation.done?).to eq(true)
|
50
|
+
expect(invocation.expected_status_unmet).to(be_nil)
|
51
|
+
expect(invocation.expected_content_type_unmet).to(be_nil)
|
52
|
+
expect(invocation.expected_headers_unmet).to(be_nil) if test_case.has_expected_headers?
|
53
|
+
expect(invocation.expected_schema_unmet).to(be_nil)
|
54
|
+
end
|
79
55
|
|
80
|
-
|
81
|
-
|
82
|
-
|
56
|
+
it 'meets all specific assertions' do
|
57
|
+
expect(invocation.assertions_unmet).to(be_nil)
|
58
|
+
end if test_case.has_assertions?
|
83
59
|
|
84
|
-
|
85
|
-
|
86
|
-
|
60
|
+
it 'meets declarative postconditions' do
|
61
|
+
expect(invocation.postconditions_unmet).to(be_nil)
|
62
|
+
end if test_case.service.has_postconditions? and not(counterexample)
|
87
63
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
92
|
-
end
|
64
|
+
it 'meets the specific error messages, if any (backward compatibility)' do
|
65
|
+
expect(@invocation.expected_error_unmet).to(be_nil)
|
66
|
+
end if test_case.has_expected_error?
|
93
67
|
end
|
94
|
-
|
68
|
+
@rspec_config = true
|
95
69
|
end
|
96
70
|
|
97
71
|
end # class Tester
|
data/lib/webspicy/version.rb
CHANGED
data/lib/webspicy.rb
CHANGED
@@ -84,6 +84,15 @@ module Webspicy
|
|
84
84
|
end
|
85
85
|
module_function :with_scope
|
86
86
|
|
87
|
+
#
|
88
|
+
# Returns the current scope or a default one is none has been
|
89
|
+
# previously installed using `set_current_scope` or `with_scope`
|
90
|
+
#
|
91
|
+
def current_scope
|
92
|
+
Thread.current[:webspicy_scope] || default_scope
|
93
|
+
end
|
94
|
+
module_function :current_scope
|
95
|
+
|
87
96
|
#
|
88
97
|
# Sets the current scope.
|
89
98
|
#
|
@@ -10,6 +10,43 @@ module Webspicy
|
|
10
10
|
expect(seen).to be_a(Configuration)
|
11
11
|
end
|
12
12
|
|
13
|
+
describe '.dress' do
|
14
|
+
|
15
|
+
it 'is idempotent' do
|
16
|
+
c = Configuration.new
|
17
|
+
expect(Configuration.dress(c)).to be(c)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'supports a config.rb file' do
|
21
|
+
c = Configuration.dress(Path.dir/'configuration/config.rb')
|
22
|
+
expect(c).to be_a(Configuration)
|
23
|
+
expect(c.folder).to eq(Path.dir/'configuration')
|
24
|
+
expect(c.preconditions.size).to eq(1)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'supports a folder having a config.rb file' do
|
28
|
+
c = Configuration.dress(Path.dir/'configuration')
|
29
|
+
expect(c).to be_a(Configuration)
|
30
|
+
expect(c.folder).to eq(Path.dir/'configuration')
|
31
|
+
expect(c.preconditions.size).to eq(1)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'yields the block with the configuration, if given' do
|
35
|
+
seen = nil
|
36
|
+
Configuration.dress(Path.dir/'configuration'){|c|
|
37
|
+
seen = c
|
38
|
+
}
|
39
|
+
expect(seen).to be_a(Configuration)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'raises if the folder has no config.rb file' do
|
43
|
+
expect(->{
|
44
|
+
Configuration.dress(Path.dir)
|
45
|
+
}).to raise_error(/Missing config.rb file/)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
13
50
|
describe 'folder' do
|
14
51
|
|
15
52
|
it 'returns the main folder without arg' do
|
@@ -129,12 +166,18 @@ module Webspicy
|
|
129
166
|
duped = original.dup do |d|
|
130
167
|
d.rspec_options << "--hello"
|
131
168
|
d.before_each do end
|
169
|
+
d.precondition Class.new
|
170
|
+
d.postcondition Class.new
|
132
171
|
end
|
133
172
|
expect(duped.rspec_options.last).to eq("--hello")
|
134
173
|
expect(original.rspec_options.last).not_to eq("--hello")
|
174
|
+
expect(duped.preconditions.size).to eq(1)
|
175
|
+
expect(duped.postconditions.size).to eq(1)
|
135
176
|
|
136
177
|
expect(duped.before_listeners.size).to eq(1)
|
137
178
|
expect(original.before_listeners.size).to eq(0)
|
179
|
+
expect(original.preconditions.size).to eq(0)
|
180
|
+
expect(original.postconditions.size).to eq(0)
|
138
181
|
end
|
139
182
|
|
140
183
|
it 'empties the children' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webspicy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
@@ -122,6 +122,9 @@ files:
|
|
122
122
|
- examples/restful/Gemfile.lock
|
123
123
|
- examples/restful/Rakefile
|
124
124
|
- examples/restful/app.rb
|
125
|
+
- examples/restful/webspicy/config.rb
|
126
|
+
- examples/restful/webspicy/rack.rb
|
127
|
+
- examples/restful/webspicy/real.rb
|
125
128
|
- examples/restful/webspicy/schema.fio
|
126
129
|
- examples/restful/webspicy/todo/deleteTodo.yml
|
127
130
|
- examples/restful/webspicy/todo/getTodo.yml
|
@@ -143,6 +146,7 @@ files:
|
|
143
146
|
- lib/webspicy/tester/asserter.rb
|
144
147
|
- lib/webspicy/tester/assertions.rb
|
145
148
|
- lib/webspicy/version.rb
|
149
|
+
- spec/unit/configuration/config.rb
|
146
150
|
- spec/unit/resource/service/test_dress_params.rb
|
147
151
|
- spec/unit/resource/test_instantiate_url.rb
|
148
152
|
- spec/unit/resource/test_url_placeholders.rb
|
@@ -174,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
178
|
version: '0'
|
175
179
|
requirements: []
|
176
180
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.
|
181
|
+
rubygems_version: 2.6.11
|
178
182
|
signing_key:
|
179
183
|
specification_version: 4
|
180
184
|
summary: Webspicy helps testing web services as software operation black boxes!
|