waiting_rspec_matchers 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/waiting_rspec_matchers/version.rb +1 -1
- data/lib/waiting_rspec_matchers.rb +8 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8cbc120933f6ab6460124a0cd2382bf96c1c6f7
|
4
|
+
data.tar.gz: 7b2ab64c10d3dadbc4367cee535c97b35a69e039
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2aae9a6546d15e32025975e08defb8d1bd4ea6c23eb488f4801dcd40006c939b35b02a5b0a65f475c413e80d557031ab43eb45cfa80722aa8bf1bbcdafa94af7
|
7
|
+
data.tar.gz: 2bcfe967fd2d61bcada02684da836a4000ba67ac37a9755c49ca5624a321c24aa2fab3b39bc89d75eeb17c38eff61e9c8d171b7fc14e36f7f9c2a201f4529e3e
|
@@ -24,6 +24,9 @@ module WaitingRspecMatchers
|
|
24
24
|
def method_missing(method_name, *args, &expected_block)
|
25
25
|
if m = method_name.to_s.match(BECOME_REGEX)
|
26
26
|
rspec_matcher_name = m[1]
|
27
|
+
unless respond_to?(rspec_matcher_name)
|
28
|
+
raise ArgumentError, "Matcher #{rspec_matcher_name.inspect} doesn't exist"
|
29
|
+
end
|
27
30
|
matcher_class_name = "Become#{rspec_matcher_name.capitalize}Matcher"
|
28
31
|
if ::WaitingRspecMatchers.const_defined?(matcher_class_name)
|
29
32
|
k = ::WaitingRspecMatchers.const_get(matcher_class_name)
|
@@ -32,7 +35,7 @@ module WaitingRspecMatchers
|
|
32
35
|
::WaitingRspecMatchers.const_set(matcher_class_name, k)
|
33
36
|
end
|
34
37
|
|
35
|
-
k.new(rspec_matcher_name, *args, &expected_block)
|
38
|
+
k.new(rspec_matcher_name, self, *args, &expected_block)
|
36
39
|
else
|
37
40
|
super
|
38
41
|
end
|
@@ -47,11 +50,11 @@ module WaitingRspecMatchers
|
|
47
50
|
include ::RSpec::Matchers
|
48
51
|
include ::RSpec::Matchers::Composable
|
49
52
|
|
50
|
-
def initialize(rspec_matcher_name, *args, &expected_block)
|
53
|
+
def initialize(rspec_matcher_name, where_included, *args, &expected_block)
|
51
54
|
@rspec_matcher_name = rspec_matcher_name
|
55
|
+
@where_included = where_included
|
52
56
|
@args = args
|
53
57
|
@expected_block = expected_block
|
54
|
-
|
55
58
|
@chains = []
|
56
59
|
end
|
57
60
|
|
@@ -77,11 +80,11 @@ module WaitingRspecMatchers
|
|
77
80
|
def match_helper(to_or_not_to, &block)
|
78
81
|
start_time = Time.now
|
79
82
|
begin
|
80
|
-
matcher = __send__(@rspec_matcher_name.to_sym, *@args, &@expected_block)
|
83
|
+
matcher = @where_included.__send__(@rspec_matcher_name.to_sym, *@args, &@expected_block)
|
81
84
|
@chains.each do |chain|
|
82
85
|
matcher = matcher.__send__(chain[0], *chain[1])
|
83
86
|
end
|
84
|
-
if matcher.supports_block_expectations?
|
87
|
+
if matcher.respond_to?(:supports_block_expectations?) && matcher.supports_block_expectations?
|
85
88
|
expect { block.call }.__send__(to_or_not_to, matcher)
|
86
89
|
else
|
87
90
|
expect(block.call).__send__(to_or_not_to, matcher)
|