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
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object (also: #negative_failure_message)
-
#initialize(width, height) ⇒ HaveDimensions
constructor
A new instance of HaveDimensions.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(width, height) ⇒ HaveDimensions
Returns a new instance of HaveDimensions.
137 138 139 |
# File 'lib/carrierwave/test/matchers.rb', line 137 def initialize(width, height) @width, @height = width, height end |
Instance Method Details
#description ⇒ Object
158 159 160 |
# File 'lib/carrierwave/test/matchers.rb', line 158 def description "have an exact size of #{@width} by #{@height}" end |
#failure_message ⇒ Object
150 151 152 |
# File 'lib/carrierwave/test/matchers.rb', line 150 def "expected #{@actual.current_path.inspect} to have an exact size of #{@width} by #{@height}, but it was #{@actual_width} by #{@actual_height}." end |
#failure_message_when_negated ⇒ Object Also known as: negative_failure_message
154 155 156 |
# File 'lib/carrierwave/test/matchers.rb', line 154 def "expected #{@actual.current_path.inspect} not to have an exact size of #{@width} by #{@height}, but it did." end |
#matches?(actual) ⇒ Boolean
141 142 143 144 145 146 147 148 |
# File 'lib/carrierwave/test/matchers.rb', line 141 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 |