lib/watirsplash/rspec_patches.rb in watirsplash-1.2.1 vs lib/watirsplash/rspec_patches.rb in watirsplash-1.3.0

- old
+ new

@@ -101,20 +101,28 @@ # # expect { # div.click # }.to make {another_div.present?}.in(5) # +# expect { +# div.click +# }.to change {another_div.text}.soon +# # use with ActiveSupport to use descriptive methods for numbers: # require "active_support" # another_div.should exist.in(5.minutes) RSpec::Matchers.constants.each do |const| RSpec::Matchers.const_get(const).class_eval do def in(timeout) @timeout = timeout self end + def soon + self.in(30) + end + inst_methods = instance_methods.map {|m| m.to_sym} if inst_methods.include? :matches? alias_method :__matches?, :matches? @@ -126,9 +134,13 @@ if inst_methods.include? :does_not_match? alias_method :__does_not_match?, :does_not_match? def does_not_match?(actual) @timeout ? (Watir::Wait.until(@timeout) {__does_not_match?(actual)} rescue false) : __does_not_match?(actual) + end + else + def does_not_match?(actual) + @timeout ? !(Watir::Wait.while(@timeout) {__matches?(actual)} rescue true) : !__matches?(actual) end end end end