Class: CarrierWave::Test::Matchers::BeNoLargerThan
- Inherits:
-
Object
- Object
- CarrierWave::Test::Matchers::BeNoLargerThan
- Defined in:
- lib/carrierwave/test/matchers.rb
Overview
:nodoc:
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(width, height) ⇒ BeNoLargerThan
constructor
A new instance of BeNoLargerThan.
- #matches?(actual) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(width, height) ⇒ BeNoLargerThan
Returns a new instance of BeNoLargerThan.
55 56 57 |
# File 'lib/carrierwave/test/matchers.rb', line 55 def initialize(width, height) @width, @height = width, height end |
Instance Method Details
#failure_message ⇒ Object
69 70 71 |
# File 'lib/carrierwave/test/matchers.rb', line 69 def "expected #{@actual.inspect} to be no larger than #{@width} by #{@height}, but it was #{@actual_height} by #{@actual_width}." end |
#matches?(actual) ⇒ Boolean
59 60 61 62 63 64 65 66 67 |
# File 'lib/carrierwave/test/matchers.rb', line 59 def matches?(actual) @actual = actual # Satisfy expectation here. Return false or raise an error if it's not met. require 'RMagick' img = ::Magick::Image.read(@actual.path).first @actual_width = img.columns @actual_height = img.rows @actual_width <= @width && @actual_height <= @height end |
#negative_failure_message ⇒ Object
73 74 75 |
# File 'lib/carrierwave/test/matchers.rb', line 73 def "expected #{@actual.inspect} to be larger than #{@width} by #{@height}, but it wasn't." end |