spectre-core 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b3c5faed7a6a34d2c9fe9e2c3b637ce8cc818e8ea597649e7b1c386dd444fde
4
- data.tar.gz: 330492cacaad784dea242b35bd539a75660268022485afde75e47cdc99d374a7
3
+ metadata.gz: 76697e95cde1f8359db1f305ba1d15869bd53903d49a0575fa1ee6f2cda7bf98
4
+ data.tar.gz: 72562ba547d8f8ff68e880d8f196bd31c7da8f1fd5639231bb56aa838830879a
5
5
  SHA512:
6
- metadata.gz: 02b2682ae4911e462be2c9e48622c0dca079916719a9b2ce519bae1d7945290a989572e16c8c21768201f811177ef5580d3077f2a0f50ce0225639a93c1c1b9a
7
- data.tar.gz: 140ebcba6bbbd1056510bd8c231fe16b0e63a6d0a4209abb69701fdfc9d99b2a2655742e334880e31e3fbda55cf0a434d2dee1290a95a7513a5a64699bb5a288
6
+ metadata.gz: e1ce860bd80ee58af11d506ad9e297f9a432a6f71f62b7702574c5dd52af0f6a6de7fa8bd2e35c167e387e063f86f97a77f51e0541399a866133c0a3524b22a9
7
+ data.tar.gz: eebfbac67335a7663f407a26094336ee9815a02ebe74789b82254a45ca6539ccc036f289a3eed37cfc581b8e178986f70cbdf5d3c1af49a657ebce4c9ce7246b
data/lib/spectre.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Spectre
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 9
4
+ MINOR = 10
5
5
  TINY = 0
6
6
  end
7
7
 
@@ -6,7 +6,7 @@ module Spectre
6
6
  module Assertion
7
7
  class ::Object
8
8
  def should_be(val)
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
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
- 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
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
- raise AssertionFailure.new("The value '#{self.to_s.trim}' should not exist, but it does", val, self) unless self.to_s != nil
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
- raise AssertionFailure.new("The text '#{self.trim}' should not be '#{val.to_s.trim}'", val, self) unless self != val
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 value
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 value, nil
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 value, other
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 value, other
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}")
@@ -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
@@ -218,9 +218,8 @@ module Spectre
218
218
  else
219
219
  str = JSON.dump(json)
220
220
  end
221
- # rescue => e
222
- # # do nothing
223
- # @@logger.error(e)
221
+ rescue
222
+ # do nothing
224
223
  end
225
224
 
226
225
  str
@@ -97,6 +97,7 @@ module Spectre::Reporter
97
97
  str += " line.....: #{line}\n"
98
98
  str += " type.....: #{error.class}\n"
99
99
  str += " message..: #{error.message}\n"
100
+ str += " backtrace: \n #{error.backtrace.join("\n ")}\n" if @config['debug']
100
101
  str
101
102
  end
102
103
  end
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.9.0
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-01 00:00:00.000000000 Z
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