Class: CarrierWave::Test::Matchers::BeNoWiderThan

Inherits:
Object
  • Object
show all
Defined in:
lib/carrierwave/test/matchers.rb

Overview

:nodoc:

Instance Method Summary (collapse)

Constructor Details

- (BeNoWiderThan) initialize(width)



218
219
220
# File 'lib/carrierwave/test/matchers.rb', line 218

def initialize(width)
  @width = width
end

Instance Method Details

- (Object) description



238
239
240
# File 'lib/carrierwave/test/matchers.rb', line 238

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

- (Object) failure_message



230
231
232
# File 'lib/carrierwave/test/matchers.rb', line 230

def failure_message
  "expected #{@actual.current_path.inspect} to be no wider than #{@width}, but it was #{@actual_width}."
end

- (Boolean) matches?(actual)



222
223
224
225
226
227
228
# File 'lib/carrierwave/test/matchers.rb', line 222

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_width = image.width
  @actual_width <= @width
end

- (Object) negative_failure_message



234
235
236
# File 'lib/carrierwave/test/matchers.rb', line 234

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