Class: CarrierWave::Test::Matchers::BeNoTallerThan

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(height) ⇒ BeNoTallerThan

Returns a new instance of BeNoTallerThan.



248
249
250
# File 'lib/carrierwave/test/matchers.rb', line 248

def initialize(height)
  @height = height
end

Instance Method Details

#descriptionObject



268
269
270
# File 'lib/carrierwave/test/matchers.rb', line 268

def description
  "have a height less than or equal to #{@height}"
end

#failure_messageObject



260
261
262
# File 'lib/carrierwave/test/matchers.rb', line 260

def failure_message
  "expected #{@actual.current_path.inspect} to be no taller than #{@height}, but it was #{@actual_height}."
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


252
253
254
255
256
257
258
# File 'lib/carrierwave/test/matchers.rb', line 252

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

#negative_failure_messageObject



264
265
266
# File 'lib/carrierwave/test/matchers.rb', line 264

def negative_failure_message
  "expected #{@actual.current_path.inspect} not to be taller than #{@height}, but it is."
end