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.



158
159
160
# File 'lib/carrierwave/test/matchers.rb', line 158

def initialize(height)
  @height = height
end

Instance Method Details

#descriptionObject



178
179
180
# File 'lib/carrierwave/test/matchers.rb', line 178

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

#failure_messageObject



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

def failure_message
  "expected #{@actual.current_path.inspect} to have an exact size of #{@height}, but it was #{@actual_height}."
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


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

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



174
175
176
# File 'lib/carrierwave/test/matchers.rb', line 174

def negative_failure_message
  "expected #{@actual.current_path.inspect} not to have an exact size of #{@height}, but it did."
end