Class: CarrierWave::Test::Matchers::HaveDimensions

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

Overview

:nodoc:

Instance Method Summary (collapse)

Constructor Details

- (HaveDimensions) initialize(width, height)



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

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

Instance Method Details

- (Object) description



148
149
150
# File 'lib/carrierwave/test/matchers.rb', line 148

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

- (Object) failure_message



140
141
142
# File 'lib/carrierwave/test/matchers.rb', line 140

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

- (Boolean) matches?(actual)



131
132
133
134
135
136
137
138
# File 'lib/carrierwave/test/matchers.rb', line 131

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

- (Object) negative_failure_message



144
145
146
# File 'lib/carrierwave/test/matchers.rb', line 144

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