Class: CarrierWave::Test::Matchers::HavePermissions

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ HavePermissions

Returns a new instance of HavePermissions



43
44
45
# File 'lib/carrierwave/test/matchers.rb', line 43

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject



61
62
63
# File 'lib/carrierwave/test/matchers.rb', line 61

def description
  "have permissions #{@expected.to_s(8)}"
end

#failure_messageObject



53
54
55
# File 'lib/carrierwave/test/matchers.rb', line 53

def failure_message
  "expected #{@actual.current_path.inspect} to have permissions #{@expected.to_s(8)}, but they were #{(File.stat(@actual.path).mode & 0777).to_s(8)}"
end

#failure_message_when_negatedObject Also known as: negative_failure_message



57
58
59
# File 'lib/carrierwave/test/matchers.rb', line 57

def failure_message_when_negated
  "expected #{@actual.current_path.inspect} not to have permissions #{@expected.to_s(8)}, but it did"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
50
51
# File 'lib/carrierwave/test/matchers.rb', line 47

def matches?(actual)
  @actual = actual
  # Satisfy expectation here. Return false or raise an error if it's not met.
  (File.stat(@actual.path).mode & 0777) == @expected
end