webspicy 0.15.3 → 0.15.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/restful/Gemfile.lock +1 -1
- data/lib/webspicy.rb +1 -0
- data/lib/webspicy/configuration.rb +18 -0
- data/lib/webspicy/formaldoc.fio +5 -1
- data/lib/webspicy/mocker.rb +1 -1
- data/lib/webspicy/resource/service/invocation.rb +3 -3
- data/lib/webspicy/resource/service/test_case.rb +1 -1
- data/lib/webspicy/scope.rb +1 -1
- data/lib/webspicy/support.rb +1 -0
- data/lib/webspicy/support/status_range.rb +46 -0
- data/lib/webspicy/version.rb +1 -1
- data/spec/unit/scope/test_expand_example.rb +1 -1
- data/spec/unit/support/test_status_range.rb +29 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8b9e1294df7f1eebb306f79f9fc39230a29217a8578b686ab3c9664e542466a
|
4
|
+
data.tar.gz: c5c07c651e3790c4016c7ffa5647f8b1bc78311b86bcef2a16e3a127be588bbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21e6a2e43bf83a096cd0d77b94a1677d142599cc8f7842cf69202ef489bb4fe8b5c3266460c8ab758ee77d6a0cca6100aa9e5cc9bf34cc18ccf45d427de41cac
|
7
|
+
data.tar.gz: 62bb90f71538abd9132d7925ae861f2f80c1def589246e6838f5f39ea9cf8e15cb75c5cbd315d88a54b0a410decbc5743c1ec1a5686485c6d84a1753ca89382a
|
data/lib/webspicy.rb
CHANGED
@@ -11,6 +11,7 @@ module Webspicy
|
|
11
11
|
@postconditions = []
|
12
12
|
@listeners = Hash.new{|h,k| h[k] = [] }
|
13
13
|
@rspec_options = default_rspec_options
|
14
|
+
@run_examples = default_run_examples
|
14
15
|
@run_counterexamples = default_run_counterexamples
|
15
16
|
@file_filter = default_file_filter
|
16
17
|
@service_filter = default_service_filter
|
@@ -94,6 +95,23 @@ module Webspicy
|
|
94
95
|
!children.empty?
|
95
96
|
end
|
96
97
|
|
98
|
+
# Sets whether examples have to be ran or not.
|
99
|
+
def run_examples=(run_examples)
|
100
|
+
@run_examples = run_examples
|
101
|
+
end
|
102
|
+
attr_reader :run_examples
|
103
|
+
|
104
|
+
# Whether counter examples must be ran or not.
|
105
|
+
def run_examples?
|
106
|
+
@run_examples
|
107
|
+
end
|
108
|
+
|
109
|
+
# Returns the defaut value for run_examples
|
110
|
+
def default_run_examples
|
111
|
+
ENV['ROBUST'].nil? || (ENV['ROBUST'] != 'only')
|
112
|
+
end
|
113
|
+
private :default_run_examples
|
114
|
+
|
97
115
|
# Sets whether counter examples have to be ran or not.
|
98
116
|
def run_counterexamples=(run_counterexamples)
|
99
117
|
@run_counterexamples = run_counterexamples
|
data/lib/webspicy/formaldoc.fio
CHANGED
@@ -51,7 +51,7 @@ TestCase =
|
|
51
51
|
requester :? String
|
52
52
|
metadata :? { ...: .Object }
|
53
53
|
expected :? {
|
54
|
-
status :?
|
54
|
+
status :? StatusRange
|
55
55
|
content_type :? String|Nil
|
56
56
|
error :? String
|
57
57
|
headers :? .Hash
|
@@ -61,3 +61,7 @@ TestCase =
|
|
61
61
|
}
|
62
62
|
|
63
63
|
Params = .Array|.Hash
|
64
|
+
|
65
|
+
StatusRange = .Webspicy::Support::StatusRange
|
66
|
+
<int> Integer
|
67
|
+
<str> String(s | s =~ /^\dxx$/ )
|
data/lib/webspicy/mocker.rb
CHANGED
@@ -53,7 +53,7 @@ module Webspicy
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def is_expected_success?
|
56
|
-
test_case.expected_status >= 200 && test_case.expected_status < 300
|
56
|
+
test_case.expected_status.to_i >= 200 && test_case.expected_status.to_i < 300
|
57
57
|
end
|
58
58
|
|
59
59
|
def is_success?
|
@@ -73,7 +73,7 @@ module Webspicy
|
|
73
73
|
def expected_status_unmet
|
74
74
|
expected = test_case.expected_status
|
75
75
|
got = response.status
|
76
|
-
expected
|
76
|
+
expected === got ? nil : "#{expected} != #{got}"
|
77
77
|
end
|
78
78
|
|
79
79
|
def meets_expected_status?
|
@@ -89,7 +89,7 @@ module Webspicy
|
|
89
89
|
if ect.nil?
|
90
90
|
got.nil? ? nil : "#{ect} != #{got}"
|
91
91
|
else
|
92
|
-
|
92
|
+
got.to_s.start_with?(ect.to_s) ? nil : "#{ect} != #{got}"
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
data/lib/webspicy/scope.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'support/status_range'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Webspicy
|
2
|
+
module Support
|
3
|
+
class StatusRange
|
4
|
+
|
5
|
+
def initialize(range)
|
6
|
+
@range = range
|
7
|
+
end
|
8
|
+
attr_reader :range
|
9
|
+
|
10
|
+
def self.int(i)
|
11
|
+
new(i..i)
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_int
|
15
|
+
@range.first
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.str(s)
|
19
|
+
from = s[/^(\d)/,1].to_i * 100
|
20
|
+
new(from...from+100)
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_str
|
24
|
+
"#{@range.first/100}xx"
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_i
|
28
|
+
@range.first
|
29
|
+
end
|
30
|
+
|
31
|
+
def ===(status)
|
32
|
+
range === status
|
33
|
+
end
|
34
|
+
|
35
|
+
def ==(other)
|
36
|
+
other.is_a?(StatusRange) && self.range == other.range
|
37
|
+
end
|
38
|
+
alias :eql? :==
|
39
|
+
|
40
|
+
def hash
|
41
|
+
@range.hash
|
42
|
+
end
|
43
|
+
|
44
|
+
end # class StatusRange
|
45
|
+
end # module Support
|
46
|
+
end # module Webspicy
|
data/lib/webspicy/version.rb
CHANGED
@@ -53,7 +53,7 @@ module Webspicy
|
|
53
53
|
expect(subject).to be_a(Resource::Service::TestCase)
|
54
54
|
expect(subject.description).to eql("Hello world")
|
55
55
|
expect(subject.expected).to eql({
|
56
|
-
status: 200,
|
56
|
+
status: Support::StatusRange.int(200),
|
57
57
|
content_type: "application/json"
|
58
58
|
})
|
59
59
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
module Webspicy
|
3
|
+
module Support
|
4
|
+
describe StatusRange do
|
5
|
+
|
6
|
+
it 'has a int information contract' do
|
7
|
+
expect(StatusRange.int(100).range).to eql(100..100)
|
8
|
+
expect(StatusRange.int(100).to_int).to eql(100)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'has a str information contract' do
|
12
|
+
expect(StatusRange.str("3xx").range).to eql(300...400)
|
13
|
+
expect(StatusRange.str("3xx").to_str).to eql("3xx")
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'has a to_i that returns the first status of the range' do
|
17
|
+
expect(StatusRange.int(300).to_i).to eql(300)
|
18
|
+
expect(StatusRange.str("3xx").to_i).to eql(300)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'has a matching method' do
|
22
|
+
expect(StatusRange.str("3xx") === 300).to eql(true)
|
23
|
+
expect(StatusRange.str("3xx") === 302).to eql(true)
|
24
|
+
expect(StatusRange.str("3xx") === 400).to eql(false)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
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.15.
|
4
|
+
version: 0.15.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -224,6 +224,8 @@ files:
|
|
224
224
|
- lib/webspicy/resource/service/invocation.rb
|
225
225
|
- lib/webspicy/resource/service/test_case.rb
|
226
226
|
- lib/webspicy/scope.rb
|
227
|
+
- lib/webspicy/support.rb
|
228
|
+
- lib/webspicy/support/status_range.rb
|
227
229
|
- lib/webspicy/tester.rb
|
228
230
|
- lib/webspicy/tester/asserter.rb
|
229
231
|
- lib/webspicy/tester/assertions.rb
|
@@ -239,6 +241,7 @@ files:
|
|
239
241
|
- spec/unit/scope/test_expand_example.rb
|
240
242
|
- spec/unit/scope/test_to_real_url.rb
|
241
243
|
- spec/unit/spec_helper.rb
|
244
|
+
- spec/unit/support/test_status_range.rb
|
242
245
|
- spec/unit/test_configuration.rb
|
243
246
|
- spec/unit/tester/test_assertions.rb
|
244
247
|
- tasks/gem.rake
|