Class: Minitest::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/assert_dirs_equal.rb

Instance Method Summary collapse

Instance Method Details

#assert_dir_included(expected, target) ⇒ Object

Note:

Extra files in ‘target` are ignored.

Fails if ‘target` lacks some files, or any file in the directory differs from according content in `expected`. Should be read as ’Content from ‘expected` is expected to be “included” in `target`’.

Parameters:

  • expected (String)

    path to a directory which contains expected structure and content.

  • target (String)

    path to a directory which contains result of executing a method under test.

Raises:

  • (Minitest::Assertion)

Since:

  • 0.2.0



44
45
46
47
# File 'lib/minitest/assert_dirs_equal.rb', line 44

def assert_dir_included(expected, target)
  matcher = AssertDirsEqual::Matcher.new(expected, exact_match: false)
  assert matcher.matches?(target), matcher.failure_message
end

#assert_dirs_equal(expected, target) ⇒ Object

Fails if ‘target` lacks some files, or has extra files, or any file in the directory differs from according content in `expected`.

Parameters:

  • expected (String)

    path to a directory which contains expected structure and content.

  • target (String)

    path to a directory which contains result of executing a method under test.

Raises:

  • (Minitest::Assertion)

Since:

  • 0.1.0



22
23
24
25
# File 'lib/minitest/assert_dirs_equal.rb', line 22

def assert_dirs_equal(expected, target)
  matcher = AssertDirsEqual::Matcher.new(expected)
  assert matcher.matches?(target), matcher.failure_message
end

#refute_dir_included(expected, target) ⇒ Object

Note:

Extra files in ‘target` are ignored.

Fails if ‘target` includes the same files from `expected`.

Parameters:

  • expected (String)

    path to a directory which contains expected structure and content.

  • target (String)

    path to a directory which contains result of executing a method under test.

Since:

  • 0.2.0



54
55
56
57
# File 'lib/minitest/assert_dirs_equal.rb', line 54

def refute_dir_included(expected, target)
  matcher = AssertDirsEqual::Matcher.new(expected, exact_match: false)
  refute matcher.matches?(target), matcher.failure_message_when_negated
end

#refute_dirs_equal(expected, target) ⇒ Object

Fails if ‘target` has exactly the same file tree structure and content.

Parameters:

  • expected (String)

    path to a directory which contains expected structure and content.

  • target (String)

    path to a directory which contains result of executing a method under test.

Raises:

  • (Minitest::Assertion)

Since:

  • 0.1.0



32
33
34
35
# File 'lib/minitest/assert_dirs_equal.rb', line 32

def refute_dirs_equal(expected, target)
  matcher = AssertDirsEqual::Matcher.new(expected)
  refute matcher.matches?(target), matcher.failure_message_when_negated
end