lib/rspec/wait/handler.rb in rspec-wait-0.0.1 vs lib/rspec/wait/handler.rb in rspec-wait-0.0.2

- old
+ new

@@ -7,20 +7,18 @@ module Wait module Handler TIMEOUT = 10 DELAY = 0.1 - # From: https://github.com/rspec/rspec-expectations/blob/v2.14.5/lib/rspec/expectations/handler.rb#L16-L64 - def handle_matcher(actual, *) + def handle_matcher(target, *args, &block) failure = nil Timeout.timeout(TIMEOUT) do loop do - actual = actual.call if actual.respond_to?(:call) - begin - super + actual = target.respond_to?(:call) ? target.call : target + super(actual, *args, &block) break rescue RSpec::Expectations::ExpectationNotMetError => failure sleep DELAY retry end @@ -29,13 +27,15 @@ rescue Timeout::Error raise failure || TimeoutError end end + # From: https://github.com/rspec/rspec-expectations/blob/v3.0.0/lib/rspec/expectations/handler.rb#L44-L63 class PositiveHandler < RSpec::Expectations::PositiveExpectationHandler extend Handler end + # From: https://github.com/rspec/rspec-expectations/blob/v3.0.0/lib/rspec/expectations/handler.rb#L66-L93 class NegativeHandler < RSpec::Expectations::NegativeExpectationHandler extend Handler end end end