Class: CarrierWave::Test::Matchers::BeFormat

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ BeFormat

Returns a new instance of BeFormat


303
304
305
# File 'lib/carrierwave/test/matchers.rb', line 303

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject


323
324
325
# File 'lib/carrierwave/test/matchers.rb', line 323

def description
  "have #{@expected} format"
end

#failure_messageObject


315
316
317
# File 'lib/carrierwave/test/matchers.rb', line 315

def failure_message
  "expected #{@actual.current_path.inspect} to have #{@expected} format, but it was #{@actual_expected}."
end

#failure_message_when_negatedObject Also known as: negative_failure_message


319
320
321
# File 'lib/carrierwave/test/matchers.rb', line 319

def failure_message_when_negated
  "expected #{@actual.current_path.inspect} not to have #{@expected} format, but it did."
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)

307
308
309
310
311
312
313
# File 'lib/carrierwave/test/matchers.rb', line 307

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_expected = image.format
  !@expected.nil? && @actual_expected.casecmp(@expected).zero?
end