rspec-matcher 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspec/matcher.rb +50 -7
- data/lib/rspec/matcher/identity.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7532489552ab193eb37e60fa4ce1842d8c0f4930
|
4
|
+
data.tar.gz: 6272b0ed34cfbfae5e47027beba52ed09a842ef1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8051875b6eccdfee13f989e4ac44f96ef241bed02b7c82adc72f7331653ea149c9d706915f11493c66afd22679c5ec3df173fe46317db40ca15f6311660784a8
|
7
|
+
data.tar.gz: 635c5c03852de53e9ee053ac664b1905f8ceda58f8c3a0150d4eb66c016f81967601160a0af992c3dd901274a38bb2f0f9ca990d1bf49493ba6b94ff4135cc3d
|
data/lib/rspec/matcher.rb
CHANGED
@@ -42,6 +42,45 @@ module RSpec
|
|
42
42
|
attr_accessor :expected, :actual
|
43
43
|
end
|
44
44
|
|
45
|
+
# @api private
|
46
|
+
# Ensures hook is always called and takes care of control jumps.
|
47
|
+
class RescueAndCatch
|
48
|
+
attr_accessor :context, :catchable, :to_catch, :rescuable, :to_rescue
|
49
|
+
|
50
|
+
def initialize context, &block
|
51
|
+
self.context = context
|
52
|
+
instance_eval(&block)
|
53
|
+
end
|
54
|
+
|
55
|
+
def result
|
56
|
+
r = catch catchable do
|
57
|
+
cdo(&to_catch)
|
58
|
+
end
|
59
|
+
cdo(&to_rescue)
|
60
|
+
|
61
|
+
r
|
62
|
+
rescue rescuable => e
|
63
|
+
cdo(&to_rescue)
|
64
|
+
raise e
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def catching catchable, &block
|
70
|
+
self.to_catch = block
|
71
|
+
self.catchable = catchable
|
72
|
+
end
|
73
|
+
|
74
|
+
def ensuring rescuable, &block
|
75
|
+
self.to_rescue = block
|
76
|
+
self.rescuable = rescuable
|
77
|
+
end
|
78
|
+
|
79
|
+
def cdo &block
|
80
|
+
context.instance_eval(&block)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
45
84
|
# @api private
|
46
85
|
# Used to let user define initialize
|
47
86
|
module PrependedMethods #:nodoc:
|
@@ -97,14 +136,13 @@ module RSpec
|
|
97
136
|
# Hides RSpec internal api
|
98
137
|
def matches? actual
|
99
138
|
self.actual = actual
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
match
|
104
|
-
else
|
105
|
-
match actual
|
139
|
+
RescueAndCatch.new self do
|
140
|
+
catching(:resolution) do
|
141
|
+
method(:match).arity == 0 ? match : match(actual)
|
106
142
|
end
|
107
|
-
|
143
|
+
|
144
|
+
ensuring(Exception) { clean_up }
|
145
|
+
end.result
|
108
146
|
end
|
109
147
|
|
110
148
|
# @method actual
|
@@ -171,6 +209,11 @@ module RSpec
|
|
171
209
|
false
|
172
210
|
end
|
173
211
|
|
212
|
+
# Always gets called after decision is made.
|
213
|
+
# @return [void]
|
214
|
+
def clean_up
|
215
|
+
end
|
216
|
+
|
174
217
|
private
|
175
218
|
|
176
219
|
# @api public
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-matcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pooyan Khosravi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|