lib/wildcard_finders/matchers.rb in wildcard_finders-0.1.1 vs lib/wildcard_finders/matchers.rb in wildcard_finders-0.2.0

- old
+ new

@@ -17,28 +17,24 @@ rspec_matcher_method_without_block = method.to_s.sub("find", "have") + "_without_block" rspec_no_matcher_method = method.to_s.sub("find", "have_no") rspec_no_matcher_method_without_block = method.to_s.sub("find", "have_no") + "_without_block" define_method(matcher_method) do |*args, &block| - wait_method = respond_to?(:synchronize) ? :synchronize : :wait_until - - __send__(wait_method) do - result = __send__(method, *args, &block) - result or return(false) + begin + __send__(method, *args, &block) + true + rescue ::Capybara::ElementNotFound + false end - - true end define_method(no_matcher_method) do |*args, &block| - wait_method = respond_to?(:synchronize) ? :synchronize : :wait_until - - __send__(wait_method) do - result = __send__(method, *args, &block) - result and return(false) + begin + __send__(method, *args, &block) + false + rescue ::Capybara::ElementNotFound + true end - - true end RSpec::Matchers.define(rspec_matcher_method_without_block) do |expected| match do |page| page.__send__(matcher_method, expected)