spectre-core 1.9.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spectre.rb +1 -1
- data/lib/spectre/assertion.rb +12 -18
- data/lib/spectre/helpers.rb +18 -0
- data/lib/spectre/http.rb +2 -3
- data/lib/spectre/reporter/console.rb +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76697e95cde1f8359db1f305ba1d15869bd53903d49a0575fa1ee6f2cda7bf98
|
4
|
+
data.tar.gz: 72562ba547d8f8ff68e880d8f196bd31c7da8f1fd5639231bb56aa838830879a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1ce860bd80ee58af11d506ad9e297f9a432a6f71f62b7702574c5dd52af0f6a6de7fa8bd2e35c167e387e063f86f97a77f51e0541399a866133c0a3524b22a9
|
7
|
+
data.tar.gz: eebfbac67335a7663f407a26094336ee9815a02ebe74789b82254a45ca6539ccc036f289a3eed37cfc581b8e178986f70cbdf5d3c1af49a657ebce4c9ce7246b
|
data/lib/spectre.rb
CHANGED
data/lib/spectre/assertion.rb
CHANGED
@@ -6,7 +6,7 @@ module Spectre
|
|
6
6
|
module Assertion
|
7
7
|
class ::Object
|
8
8
|
def should_be(val)
|
9
|
-
|
9
|
+
raise AssertionFailure.new("The value '#{self.to_s.trim}' should be '#{val.to_s.trim}'", val, self) unless self.to_s == val.to_s
|
10
10
|
end
|
11
11
|
|
12
12
|
def should_be_empty
|
@@ -14,11 +14,11 @@ module Spectre
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def should_not_be(val)
|
17
|
-
|
17
|
+
raise AssertionFailure.new("The value '#{self.to_s.trim}' should not be '#{val.to_s.trim}'", val, self) unless self.to_s != val.to_s
|
18
18
|
end
|
19
19
|
|
20
20
|
def should_not_exist
|
21
|
-
|
21
|
+
raise AssertionFailure.new("The value '#{self.to_s.trim}' should not exist, but it does", val, self) unless self.to_s != nil
|
22
22
|
end
|
23
23
|
|
24
24
|
def should_not_be_empty
|
@@ -76,7 +76,7 @@ module Spectre
|
|
76
76
|
val = OpenStruct.new(val)
|
77
77
|
end
|
78
78
|
|
79
|
-
raise AssertionFailure.new("The list [#{list.join(', ').trim}] should contain '#{val.trim}'", val, list) unless list.include? val
|
79
|
+
raise AssertionFailure.new("The list [#{list.join(', ').trim}] should contain '#{val.to_s.trim}'", val, list) unless list.include? val
|
80
80
|
end
|
81
81
|
|
82
82
|
def should_not_contain(val)
|
@@ -87,7 +87,7 @@ module Spectre
|
|
87
87
|
val = OpenStruct.new(val)
|
88
88
|
end
|
89
89
|
|
90
|
-
raise AssertionFailure.new("The list [#{list.join(', ').trim}] should not contain '#{val.trim}'", val, list) if list.include? val
|
90
|
+
raise AssertionFailure.new("The list [#{list.join(', ').trim}] should not contain '#{val.to_s.trim}'", val, list) if list.include? val
|
91
91
|
end
|
92
92
|
|
93
93
|
def should_be_empty
|
@@ -110,7 +110,7 @@ module Spectre
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def should_not_be(val)
|
113
|
-
|
113
|
+
raise AssertionFailure.new("The text '#{self.trim}' should not be '#{val.to_s.trim}'", val, self) unless self != val
|
114
114
|
end
|
115
115
|
|
116
116
|
def should_not_be_empty
|
@@ -118,8 +118,10 @@ module Spectre
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def should_contain(value)
|
121
|
+
raise AssertionFailure.new("`value' must not be nil") if value.nil?
|
122
|
+
|
121
123
|
predicate = proc { |x| self.include? x.to_s }
|
122
|
-
evaluation = SingleEvaluation.new
|
124
|
+
evaluation = SingleEvaluation.new(value)
|
123
125
|
success = evaluation.call(predicate)
|
124
126
|
|
125
127
|
return if success
|
@@ -165,7 +167,7 @@ module Spectre
|
|
165
167
|
|
166
168
|
class SingleEvaluation < Evaluation
|
167
169
|
def initialize value
|
168
|
-
super
|
170
|
+
super(value, nil)
|
169
171
|
end
|
170
172
|
|
171
173
|
def call predicate
|
@@ -180,7 +182,7 @@ module Spectre
|
|
180
182
|
|
181
183
|
class OrEvaluation < Evaluation
|
182
184
|
def initialize value, other
|
183
|
-
super
|
185
|
+
super(value, other)
|
184
186
|
end
|
185
187
|
|
186
188
|
def call predicate
|
@@ -195,7 +197,7 @@ module Spectre
|
|
195
197
|
|
196
198
|
class AndEvaluation < Evaluation
|
197
199
|
def initialize value, other
|
198
|
-
super
|
200
|
+
super(value, other)
|
199
201
|
end
|
200
202
|
|
201
203
|
def call predicate
|
@@ -222,14 +224,6 @@ module Spectre
|
|
222
224
|
class << self
|
223
225
|
@@success = nil
|
224
226
|
|
225
|
-
def eval_assertion predicate, val
|
226
|
-
if val.is_a? Proc
|
227
|
-
val.call(predicate)
|
228
|
-
else
|
229
|
-
predicate.call(val)
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
227
|
def expect desc
|
234
228
|
begin
|
235
229
|
Logger.log_process("expect #{desc}")
|
data/lib/spectre/helpers.rb
CHANGED
@@ -2,6 +2,7 @@ require 'securerandom'
|
|
2
2
|
require 'json'
|
3
3
|
require 'date'
|
4
4
|
require 'ostruct'
|
5
|
+
require 'jsonpath'
|
5
6
|
|
6
7
|
class ::String
|
7
8
|
def as_json
|
@@ -52,6 +53,17 @@ class ::String
|
|
52
53
|
|
53
54
|
self
|
54
55
|
end
|
56
|
+
|
57
|
+
def pick path
|
58
|
+
raise ArgumentError.new("`path' must not be nil or empty") if path.nil? or path.empty?
|
59
|
+
|
60
|
+
begin
|
61
|
+
JsonPath.on(self, path)
|
62
|
+
|
63
|
+
rescue MultiJson::ParseError
|
64
|
+
# do nothing and return nil
|
65
|
+
end
|
66
|
+
end
|
55
67
|
end
|
56
68
|
|
57
69
|
|
@@ -59,6 +71,12 @@ class ::OpenStruct
|
|
59
71
|
def to_json *args, **kwargs
|
60
72
|
self.to_h.inject({}) { |memo, (k,v)| memo[k] = v.is_a?(OpenStruct) ? v.to_h : v; memo }.to_json(*args, **kwargs)
|
61
73
|
end
|
74
|
+
|
75
|
+
def pick path
|
76
|
+
raise ArgumentError.new("`path' must not be nil or empty") if path.nil? or path.empty?
|
77
|
+
|
78
|
+
JsonPath.on(self, path)
|
79
|
+
end
|
62
80
|
end
|
63
81
|
|
64
82
|
|
data/lib/spectre/http.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spectre-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Neubauer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ectoplasm
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jsonpath
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.0
|
27
41
|
description: A DSL and command line tool to describe and run automated tests
|
28
42
|
email:
|
29
43
|
- me@christianneubauer.de
|