Class: CarrierWave::Test::Matchers::HaveWidth

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

Overview

:nodoc:

Instance Method Summary (collapse)

Constructor Details

- (HaveWidth) initialize(width)

Returns a new instance of HaveWidth



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

def initialize(width)
  @width = width
end

Instance Method Details

- (Object) description



208
209
210
# File 'lib/carrierwave/test/matchers.rb', line 208

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

- (Object) failure_message



200
201
202
# File 'lib/carrierwave/test/matchers.rb', line 200

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

- (Boolean) matches?(actual)

Returns:

  • (Boolean)


192
193
194
195
196
197
198
# File 'lib/carrierwave/test/matchers.rb', line 192

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



204
205
206
# File 'lib/carrierwave/test/matchers.rb', line 204

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