rspec-xunit 0.6.0 → 0.7.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 +4 -4
- data/lib/rspec/xunit/assertions.rb +41 -36
- data/lib/rspec/xunit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '04009d5542971db2f091421378bd23230927d68f9e9460732f86e4346b6b4cb2'
|
4
|
+
data.tar.gz: d1bdc1445ef25609d1840169dd721cf3231c91f2f9a37635f016ec3d9f0e7af7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22ebc3763e0dd50d6740df2d8d3fdc3bef5f954ae66e7d65913985ceffdf6628645a67fb4754c5db33c6a34389a95d1c4e17415b9205de86c6231bb0f7388410
|
7
|
+
data.tar.gz: 36db704352be7b0c495e2c0692930c664578e148be19575cf90d8826ea307b4c2cfde9ba3695700181dbbc15f10e5f5a0bc8e319212ab76a70857dc4fef1ac10
|
@@ -13,39 +13,37 @@ module RSpec
|
|
13
13
|
#
|
14
14
|
# - `assert_eq` roughly `expect(action).to eq(expected)`
|
15
15
|
# - `assert_not_eq` roughly `expect(action).to_not eq(expected)`
|
16
|
-
def assertion_match(matcher, suffix = matcher)
|
17
|
-
define_method "assert_#{suffix}" do |value, *args, &block|
|
18
|
-
expect(value).to send(matcher, *args, &block)
|
19
|
-
rescue Expectations::ExpectationNotMetError => e
|
20
|
-
raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
|
21
|
-
end
|
22
|
-
|
23
|
-
define_method "assert_not_#{suffix}" do |value, *args, &block|
|
24
|
-
expect(value).to_not send(matcher, *args, &block)
|
25
|
-
rescue Expectations::ExpectationNotMetError => e
|
26
|
-
raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Assertion match block converts RSpec block matchers into XUnit
|
31
|
-
# friendly assertions.
|
32
16
|
#
|
33
|
-
# For
|
34
|
-
# generate two methods:
|
17
|
+
# For block expectation, `assertion_match :raises, :raise_error, block: true`
|
18
|
+
# will generate two methods:
|
35
19
|
#
|
36
20
|
# - `assert_raises` roughly `expect { bloc }.to raise_error`
|
37
21
|
# - `assert_not_raises` roughly `expect { bloc }.to_not raise_error`
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
22
|
+
def assertion_match(matcher, suffix = matcher, block: false)
|
23
|
+
if block
|
24
|
+
define_method "assert_#{suffix}" do |*args, &block|
|
25
|
+
expect(&block).to send(matcher, *args)
|
26
|
+
rescue Expectations::ExpectationNotMetError => e
|
27
|
+
raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
|
28
|
+
end
|
29
|
+
|
30
|
+
define_method "assert_not_#{suffix}" do |*args, &block|
|
31
|
+
expect(&block).to_not send(matcher, *args)
|
32
|
+
rescue Expectations::ExpectationNotMetError => e
|
33
|
+
raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
|
34
|
+
end
|
35
|
+
else
|
36
|
+
define_method "assert_#{suffix}" do |value, *args, &blk|
|
37
|
+
expect(value).to send(matcher, *args, &blk)
|
38
|
+
rescue Expectations::ExpectationNotMetError => e
|
39
|
+
raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
|
40
|
+
end
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
define_method "assert_not_#{suffix}" do |value, *args, &blk|
|
43
|
+
expect(value).to_not send(matcher, *args, &blk)
|
44
|
+
rescue Expectations::ExpectationNotMetError => e
|
45
|
+
raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
|
46
|
+
end
|
49
47
|
end
|
50
48
|
end
|
51
49
|
end
|
@@ -60,8 +58,8 @@ module RSpec
|
|
60
58
|
assertion_match :be_between, :between
|
61
59
|
assertion_match :be_within, :within
|
62
60
|
|
63
|
-
|
64
|
-
|
61
|
+
assertion_match :raise_error, :raise, block: true
|
62
|
+
assertion_match :raise_error, :raises, block: true
|
65
63
|
|
66
64
|
# Exceptions to the block matcher rule.
|
67
65
|
assertion_match :satisfy
|
@@ -106,6 +104,7 @@ module RSpec
|
|
106
104
|
private
|
107
105
|
|
108
106
|
ASSERTION_REGEX = /^assert_(.*)$/.freeze
|
107
|
+
ASSERTION_NEGATIVE_REGEX = /^assert_not_(.*)$/.freeze
|
109
108
|
ASSERTION_PREDICATE_REGEX = /^assert_(.*)\?$/.freeze
|
110
109
|
ASSERTION_NEGATIVE_PREDICATE_REGEX = /^assert_not_(.*)\?$/.freeze
|
111
110
|
|
@@ -124,18 +123,24 @@ module RSpec
|
|
124
123
|
expect(value).to Matchers::BuiltIn::BePredicate.new(matcher, *args, &block)
|
125
124
|
end
|
126
125
|
|
126
|
+
return if ASSERTION_NEGATIVE_REGEX.match(method.to_s) do |match|
|
127
|
+
matcher = match[1]
|
128
|
+
|
129
|
+
RSpec::XUnit::Assertions.module_eval do
|
130
|
+
assertion_match matcher, block: block
|
131
|
+
end
|
132
|
+
|
133
|
+
send "assert_not_#{matcher}", *args, &block
|
134
|
+
end
|
135
|
+
|
127
136
|
return if ASSERTION_REGEX.match(method.to_s) do |match|
|
128
137
|
matcher = match[1]
|
129
138
|
|
130
139
|
RSpec::XUnit::Assertions.module_eval do
|
131
|
-
|
132
|
-
assertion_match matcher
|
133
|
-
else
|
134
|
-
assertion_match_block matcher
|
135
|
-
end
|
140
|
+
assertion_match matcher, block: block
|
136
141
|
end
|
137
142
|
|
138
|
-
send "assert_#{
|
143
|
+
send "assert_#{matcher}", *args, &block
|
139
144
|
end
|
140
145
|
|
141
146
|
super
|
data/lib/rspec/xunit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-xunit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genadi Samokovarov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|