Class: AssertDirsEqual::Matcher
- Inherits:
-
Object
- Object
- AssertDirsEqual::Matcher
- Defined in:
- lib/assert_dirs_equal/matcher.rb
Overview
Confirms with RSpec3 custom matcher protocol.
Instance Attribute Summary collapse
- #failure_message ⇒ String readonly
Instance Method Summary collapse
- #failure_message_when_negated ⇒ Object
-
#initialize(expected, options = {}) ⇒ Matcher
constructor
A new instance of Matcher.
-
#matches?(target) ⇒ true, false
Takes each file that exists in
expecteddirectory and expects to find exactly the same (by name and by content) file intargetdirectory.
Constructor Details
#initialize(expected, options = {}) ⇒ Matcher
Returns a new instance of Matcher.
23 24 25 26 |
# File 'lib/assert_dirs_equal/matcher.rb', line 23 def initialize(expected, = {}) @expected = expected @exact_match = .fetch(:exact_match, true) end |
Instance Attribute Details
#failure_message ⇒ String (readonly)
17 18 19 |
# File 'lib/assert_dirs_equal/matcher.rb', line 17 def end |
Instance Method Details
#failure_message_when_negated ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/assert_dirs_equal/matcher.rb', line 59 def if @exact_match "expected #{@target.inspect} to not be equal to #{@expected.inspect}, but they are equal" else "expected files from #{@target.inspect} to not be present in #{@expected.inspect}, but they are" end end |
#matches?(target) ⇒ true, false
Takes each file that exists in expected directory and expects to find exactly the same (by name and by content) file in target directory.
Since 0.3.0 you can use glob patterns in a filename. This is handy, for example, than you match fingerprinted files and don’t want to deal with fingerprinting algorithm. Pattern should be percent-encoded. Make sure it is strict enough to match only one file in target directory.
49 50 51 52 53 54 55 |
# File 'lib/assert_dirs_equal/matcher.rb', line 49 def matches?(target) @target = target assert_exists(@expected) && assert_exists(@target) && assert_directory(@expected) && assert_directory(@target) && assert_target_contains_all_expected_entries && refute_extra_files_in_target end |