Class: Utensils::CustomMatchers::HaveImage

Inherits:
Object
  • Object
show all
Defined in:
lib/utensils/custom_matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(image) ⇒ HaveImage

Returns a new instance of HaveImage.



69
70
71
# File 'lib/utensils/custom_matchers.rb', line 69

def initialize(image)
  @image = image
end

Instance Method Details

#failure_messageObject



82
83
84
# File 'lib/utensils/custom_matchers.rb', line 82

def failure_message
  "expected html to contain image: #{@image.inspect}"
end

#failure_message_when_negatedObject



86
87
88
# File 'lib/utensils/custom_matchers.rb', line 86

def failure_message_when_negated
  "expected html to not contain image: #{@image.inspect}"
end

#matches?(page) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
76
77
78
79
80
# File 'lib/utensils/custom_matchers.rb', line 73

def matches?(page)
  @page = page
  if @image.is_a?(String)
    find_by_url || find_lazy_loaded_image
  else
    find_dragonfly_image
  end
end