Class: CarrierWave::Test::Matchers::BeNoLargerThan

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(width, height) ⇒ BeNoLargerThan



105
106
107
# File 'lib/carrierwave/test/matchers.rb', line 105

def initialize(width, height)
  @width, @height = width, height
end

Instance Method Details

#descriptionObject



126
127
128
# File 'lib/carrierwave/test/matchers.rb', line 126

def description
  "be no larger than #{@width} by #{@height}"
end

#failure_messageObject



118
119
120
# File 'lib/carrierwave/test/matchers.rb', line 118

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

#failure_message_when_negatedObject Also known as: negative_failure_message



122
123
124
# File 'lib/carrierwave/test/matchers.rb', line 122

def failure_message_when_negated
  "expected #{@actual.current_path.inspect} to be larger than #{@width} by #{@height}, but it wasn't."
end

#matches?(actual) ⇒ Boolean



109
110
111
112
113
114
115
116
# File 'lib/carrierwave/test/matchers.rb', line 109

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_height = image.height
  @actual_width <= @width && @actual_height <= @height
end