Class: CarrierWave::Test::Matchers::HaveDimensions
- Inherits:
-
Object
- Object
- CarrierWave::Test::Matchers::HaveDimensions
- Defined in:
- lib/carrierwave/test/matchers.rb
Overview
:nodoc:
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(width, height) ⇒ HaveDimensions
constructor
A new instance of HaveDimensions.
- #matches?(actual) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(width, height) ⇒ HaveDimensions
Returns a new instance of HaveDimensions.
83 84 85 |
# File 'lib/carrierwave/test/matchers.rb', line 83 def initialize(width, height) @width, @height = width, height end |
Instance Method Details
#failure_message ⇒ Object
97 98 99 |
# File 'lib/carrierwave/test/matchers.rb', line 97 def "expected #{@actual.inspect} to have an exact size of #{@width} by #{@height}, but it was #{@actual_height} by #{@actual_width}." end |
#matches?(actual) ⇒ Boolean
87 88 89 90 91 92 93 94 95 |
# File 'lib/carrierwave/test/matchers.rb', line 87 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
101 102 103 |
# File 'lib/carrierwave/test/matchers.rb', line 101 def "expected #{@actual.inspect} not to have an exact size of #{@width} by #{@height}, but it did." end |