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



272
273
274
# File 'lib/carrierwave/test/matchers.rb', line 272

def initialize(height)
  @height = height
end

Instance Method Details

#descriptionObject



292
293
294
# File 'lib/carrierwave/test/matchers.rb', line 292

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

#failure_messageObject



284
285
286
# File 'lib/carrierwave/test/matchers.rb', line 284

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

#failure_message_when_negatedObject Also known as: negative_failure_message



288
289
290
# File 'lib/carrierwave/test/matchers.rb', line 288

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

#matches?(actual) ⇒ Boolean



276
277
278
279
280
281
282
# File 'lib/carrierwave/test/matchers.rb', line 276

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