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

- (HaveDirectoryPermissions) initialize(expected)



68
69
70
# File 'lib/carrierwave/test/matchers.rb', line 68

def initialize(expected)
  @expected = expected
end

Instance Method Details

- (Object) description



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

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

- (Object) failure_message



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

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

- (Boolean) matches?(actual)



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

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

- (Object) negative_failure_message



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

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