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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed0430976fc54c18c7fc029c01b368e607b74454
4
- data.tar.gz: 4f66f94b2c64ae03a9d5c4a5bca605510dcfda37
3
+ metadata.gz: d8cbc120933f6ab6460124a0cd2382bf96c1c6f7
4
+ data.tar.gz: 7b2ab64c10d3dadbc4367cee535c97b35a69e039
5
5
  SHA512:
6
- metadata.gz: 2c973b928de0cf53c2a9ef231cf5b57312402c041dd18923d577639bcd0688f12400ab21092d4e9b7ece0eda0352fd35d920f8d498d0fbeceb346e678b2a228e
7
- data.tar.gz: 142dc325c4e1e60bc626b4b2b2797e98ebbd16f361fc1d2a500305e7971bd661c909f7fccd04260b49223f7a4727f1a69e2912f43181bce1e9f9b3c16223020d
6
+ metadata.gz: 2aae9a6546d15e32025975e08defb8d1bd4ea6c23eb488f4801dcd40006c939b35b02a5b0a65f475c413e80d557031ab43eb45cfa80722aa8bf1bbcdafa94af7
7
+ data.tar.gz: 2bcfe967fd2d61bcada02684da836a4000ba67ac37a9755c49ca5624a321c24aa2fab3b39bc89d75eeb17c38eff61e9c8d171b7fc14e36f7f9c2a201f4529e3e
@@ -1,3 +1,3 @@
1
1
  module WaitingRspecMatchers
2
- VERSION = "0.1"
2
+ VERSION = "0.2"
3
3
  end
@@ -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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waiting_rspec_matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Botalov