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.



160
161
162
# File 'lib/carrierwave/test/matchers.rb', line 160

def initialize(height)
  @height = height
end

Instance Method Details

#descriptionObject



180
181
182
# File 'lib/carrierwave/test/matchers.rb', line 180

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

#failure_messageObject



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

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)


164
165
166
167
168
169
170
# File 'lib/carrierwave/test/matchers.rb', line 164

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



176
177
178
# File 'lib/carrierwave/test/matchers.rb', line 176

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