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

- (BeNoTallerThan) initialize(height)



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

def initialize(height)
  @height = height
end

Instance Method Details

- (Object) description



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

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

- (Object) failure_message



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

- (Boolean) matches?(actual)



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

- (Object) negative_failure_message



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