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.



72
73
74
# File 'lib/carrierwave/test/matchers.rb', line 72

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject



90
91
92
# File 'lib/carrierwave/test/matchers.rb', line 90

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

#failure_messageObject



82
83
84
# File 'lib/carrierwave/test/matchers.rb', line 82

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 & 0o777).to_s(8)}"
end

#failure_message_when_negatedObject Also known as: negative_failure_message



86
87
88
# File 'lib/carrierwave/test/matchers.rb', line 86

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)


76
77
78
79
80
# File 'lib/carrierwave/test/matchers.rb', line 76

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 & 0o777) == @expected
end