lib/juxtapose/rspec.rb in motion-juxtapose-0.2.0 vs lib/juxtapose/rspec.rb in motion-juxtapose-0.3.0
- old
+ new
@@ -1,7 +1,14 @@
if defined?(RSpec::Matchers)
- RSpec::Matchers.define :look_like do |predicate|
- match do |page|
- page.looks_like?(predicate) == true
+ RSpec::Matchers.define :look_like do |expected, options={}|
+ match do |actual|
+ if actual.respond_to?(:looks_like?)
+ actual.looks_like?(expected) == true
+ else
+ matcher = ImageMatcher.new(options)
+ matcher.identical?(expected, actual).tap do
+ matcher.cleanup
+ end
+ end
end
end
end