Class: CarrierWave::Test::Matchers::HaveDirectoryPermissions

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ HaveDirectoryPermissions

Returns a new instance of HaveDirectoryPermissions



74
75
76
# File 'lib/carrierwave/test/matchers.rb', line 74

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject



92
93
94
# File 'lib/carrierwave/test/matchers.rb', line 92

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

#failure_messageObject



84
85
86
# File 'lib/carrierwave/test/matchers.rb', line 84

def failure_message
  "expected #{File.dirname @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



88
89
90
# File 'lib/carrierwave/test/matchers.rb', line 88

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


78
79
80
81
82
# File 'lib/carrierwave/test/matchers.rb', line 78

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