Class: CarrierWave::Test::Matchers::HaveHeight

Inherits:
Object
  • Object
show all
Defined in:
lib/carrierwave/test/matchers.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(height) ⇒ HaveHeight

Returns a new instance of HaveHeight



173
174
175
# File 'lib/carrierwave/test/matchers.rb', line 173

def initialize(height)
  @height = height
end

Instance Method Details

#descriptionObject



193
194
195
# File 'lib/carrierwave/test/matchers.rb', line 193

def description
  "have an exact height of #{@height}"
end

#failure_messageObject



185
186
187
# File 'lib/carrierwave/test/matchers.rb', line 185

def failure_message
  "expected #{@actual.current_path.inspect} to have an exact size of #{@height}, but it was #{@actual_height}."
end

#failure_message_when_negatedObject Also known as: negative_failure_message



189
190
191
# File 'lib/carrierwave/test/matchers.rb', line 189

def failure_message_when_negated
  "expected #{@actual.current_path.inspect} not to have an exact size of #{@height}, but it did."
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


177
178
179
180
181
182
183
# File 'lib/carrierwave/test/matchers.rb', line 177

def matches?(actual)
  @actual = actual
  # Satisfy expectation here. Return false or raise an error if it's not met.
  image = ImageLoader.load_image(@actual.current_path)
  @actual_height = image.height
  @actual_height == @height
end