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



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

def initialize(height)
  @height = height
end

Instance Method Details

#descriptionObject



191
192
193
# File 'lib/carrierwave/test/matchers.rb', line 191

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

#failure_messageObject



183
184
185
# File 'lib/carrierwave/test/matchers.rb', line 183

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



187
188
189
# File 'lib/carrierwave/test/matchers.rb', line 187

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)


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

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