assert_dirs_equal 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.travis.yml +9 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +1 -0
- data/CONTRIBUTING.md +47 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +66 -0
- data/Rakefile +7 -0
- data/assert_dirs_equal.gemspec +19 -0
- data/lib/assert_dirs_equal/matcher.rb +95 -0
- data/lib/minitest/assert_dirs_equal.rb +24 -0
- data/test/cases/binary_and_text_files/expected/file.txt +1 -0
- data/test/cases/binary_and_text_files/target/file.txt +0 -0
- data/test/cases/different_binary_files/expected/file.png +0 -0
- data/test/cases/different_binary_files/target/file.png +0 -0
- data/test/cases/different_text_files/expected/file +1 -0
- data/test/cases/different_text_files/target/file +1 -0
- data/test/cases/empty_files_are_equal/expected/file +0 -0
- data/test/cases/empty_files_are_equal/target/file +0 -0
- data/test/cases/expected_is_not_a_dir/expected +0 -0
- data/test/cases/extra_file_in_target/target/file +0 -0
- data/test/cases/large_different_text_files/expected/file +19 -0
- data/test/cases/large_different_text_files/target/file +19 -0
- data/test/cases/missing_file_in_target/expected/file +0 -0
- data/test/cases/missing_nested_file_in_target/expected/nested/file +0 -0
- data/test/cases/same_binary_files/expected/file.png +0 -0
- data/test/cases/same_binary_files/target/file.png +0 -0
- data/test/cases/same_text_files/expected/file +1 -0
- data/test/cases/same_text_files/target/file +1 -0
- data/test/cases/target_is_not_a_dir/target +0 -0
- data/test/matcher_test.rb +106 -0
- data/test/minitest_integration_test.rb +59 -0
- data/test/test_helper.rb +12 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: daf396e81ffce0b83fd79a9218cf036385b0c695
|
4
|
+
data.tar.gz: 000fafee50178f01fd58bc5da8cb01948091f592
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5396b72a55da522376094401f159b0ef3bc46e96503532c8e3d766132e4ac44bb5e7935903e19d7c4777e722e955a132a2e19388f81e08b47bc512d7045a0737
|
7
|
+
data.tar.gz: caff9934d55bb2000b8b4059ab0e339b86491ad91db47f5a27934a17539c4bf951411dd8eee3852e47730fbe03eb55cdc64996f6b62bd1d203968c838f681cd2
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--no-private
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
## Unreleased
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
## Adding a feature
|
4
|
+
|
5
|
+
1. Open an issue and explain what you're planning to do. It is better to discuss new idea first,
|
6
|
+
rather when diving into code.
|
7
|
+
2. Add some tests.
|
8
|
+
3. Write the code.
|
9
|
+
4. Make sure all tests pass.
|
10
|
+
5. Commit with detailed explanation what you've done in a message.
|
11
|
+
6. Open pull request.
|
12
|
+
|
13
|
+
## Breaking/removing a feature
|
14
|
+
|
15
|
+
1. Add deprecation warning and fallback to old behaivour if possible.
|
16
|
+
2. Explain how to migrate to the new code in CHANGELOG.
|
17
|
+
3. Update/remove tests.
|
18
|
+
4. Update the code.
|
19
|
+
5. Make sure all tests pass.
|
20
|
+
6. Commit with detailed explanation what you've done in a message.
|
21
|
+
7. Open pull request.
|
22
|
+
|
23
|
+
## Fixing a bug
|
24
|
+
|
25
|
+
1. Add failing test.
|
26
|
+
2. Fix the bug.
|
27
|
+
3. Make sure all tests pass.
|
28
|
+
4. Commit with detailed explanation what you've done in a message.
|
29
|
+
5. Open pull request.
|
30
|
+
|
31
|
+
## Fixing a typo
|
32
|
+
|
33
|
+
1. Commit with a message that include "[ci skip]" remark.
|
34
|
+
2. Open pull request.
|
35
|
+
|
36
|
+
## Running the tests
|
37
|
+
|
38
|
+
```
|
39
|
+
rake test
|
40
|
+
```
|
41
|
+
|
42
|
+
## Working with documentation
|
43
|
+
|
44
|
+
```
|
45
|
+
yard server -dr
|
46
|
+
open http://localhost:8808
|
47
|
+
```
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Andrii Malyshko
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# AssertDirsEqual
|
2
|
+
|
3
|
+
[![Build Status](https://img.shields.io/travis/torba-rb/assert_dirs_equal.svg)](https://travis-ci.org/torba-rb/assert_dirs_equal)
|
4
|
+
[![Gem version](https://img.shields.io/gem/v/assert_dirs_equal.svg)](https://rubygems.org/gems/assert_dirs_equal)
|
5
|
+
|
6
|
+
**AssertDirsEqual** is a test framework-agnostic expectation/assertion for directories equality
|
7
|
+
by tree and content comparison.
|
8
|
+
|
9
|
+
## Status
|
10
|
+
|
11
|
+
Production ready.
|
12
|
+
|
13
|
+
## Documentation
|
14
|
+
|
15
|
+
[Released version](http://rubydoc.info/gems/assert_dirs_equal/0.1.0)
|
16
|
+
|
17
|
+
## Why
|
18
|
+
|
19
|
+
Sometimes it is easier to commit expected directory structure and compare it with a directory
|
20
|
+
created by a method under test.
|
21
|
+
|
22
|
+
If you prefer DSL-like expectations, see [minitest-filesystem][minitest-filesystem].
|
23
|
+
|
24
|
+
## Installation
|
25
|
+
|
26
|
+
Add this line to your application's Gemfile and run `bundle`:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
gem 'assert_dirs_equal', require: false
|
30
|
+
```
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
class MyWriter
|
35
|
+
def self.perform
|
36
|
+
File.write("/tmp/my_writer/result.txt", "Hello world!")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
```
|
41
|
+
|
42
|
+
Create a file "result.txt" with "Hello world!" in "test/fixtures/case01".
|
43
|
+
|
44
|
+
### Minitest
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
require 'minitest/assert_dirs_equal'
|
48
|
+
|
49
|
+
class MyWriterTest < Minitest::Test
|
50
|
+
def test_perform
|
51
|
+
MyWriter.perform
|
52
|
+
assert_dirs_equal "test/fixtures/case01", "/tmp/my_writer"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
### RSpec
|
58
|
+
|
59
|
+
TODO
|
60
|
+
|
61
|
+
## Origin
|
62
|
+
|
63
|
+
Extracted from [Torba][torba-github] library since it looks more like a standalone component.
|
64
|
+
|
65
|
+
[minitest-filesystem]: https://github.com/stefanozanella/minitest-filesystem
|
66
|
+
[torba-github]: https://github.com/torba-rb/torba
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "assert_dirs_equal"
|
3
|
+
spec.version = "0.1.0"
|
4
|
+
spec.authors = ["Andrii Malyshko"]
|
5
|
+
spec.email = ["mail@nashbridges.me"]
|
6
|
+
spec.description = "Test assertion for directories equality by tree and content comparison"
|
7
|
+
spec.summary = spec.description
|
8
|
+
spec.homepage = "https://github.com/torba-rb/assert_dirs_equal"
|
9
|
+
spec.license = "MIT"
|
10
|
+
|
11
|
+
spec.files = `git ls-files`.split($/)
|
12
|
+
spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
17
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
18
|
+
spec.add_development_dependency "minitest", "~> 5.4"
|
19
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# @since 0.1.0
|
2
|
+
module AssertDirsEqual
|
3
|
+
class Diff
|
4
|
+
# @return [String] human readable diff between `expected` and `actual`.
|
5
|
+
# @abstract Reuse existing test framework diff functionality to override this method.
|
6
|
+
def self.perform(expected, actual)
|
7
|
+
"Expected: #{expected.inspect}\n Actual: #{actual.inspect}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# Confirms with RSpec3 custom matcher protocol.
|
12
|
+
# @see https://github.com/rspec/rspec-expectations/blob/3-0-maintenance/lib/rspec/matchers.rb#L130
|
13
|
+
class Matcher
|
14
|
+
# @return [String]
|
15
|
+
attr_reader :failure_message
|
16
|
+
|
17
|
+
def initialize(expected)
|
18
|
+
@expected = expected
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [true] if `target` mirrors subdirectory of `expected` directory.
|
22
|
+
# @return [false] if `target` lacks some files, or has extra files, or any file in subdirectory differs from according file content.
|
23
|
+
def matches?(target)
|
24
|
+
@target = target
|
25
|
+
assert_exists(@expected) && assert_exists(@target) &&
|
26
|
+
assert_directory(@expected) && assert_directory(@target) &&
|
27
|
+
assert_target_contains_all_expected_entries &&
|
28
|
+
refute_extra_files_in_target
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [String]
|
32
|
+
def failure_message_when_negated
|
33
|
+
"expected #{@target.inspect} to not be equal to #{@expected.inspect}, but they are equal"
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def assert_exists(path, msg = nil)
|
39
|
+
File.exist?(path) || fail_with(msg || "expected #{path.inspect} to exist")
|
40
|
+
end
|
41
|
+
|
42
|
+
def assert_directory(directory)
|
43
|
+
File.directory?(directory) || fail_with("expected #{directory.inspect} to be a directory")
|
44
|
+
end
|
45
|
+
|
46
|
+
def assert_equal_content(expected, target)
|
47
|
+
return true if File.directory?(expected) && File.directory?(target)
|
48
|
+
|
49
|
+
expected_content = File.read(expected).strip
|
50
|
+
target_content = File.read(target).strip
|
51
|
+
|
52
|
+
expected_content == target_content || fail_with(
|
53
|
+
"expected #{target.inspect} to have same content as #{expected.inspect}:\n#{Diff.perform(expected_content, target_content)}"
|
54
|
+
)
|
55
|
+
rescue ArgumentError # strip on binary file
|
56
|
+
expected_size = File.size(expected)
|
57
|
+
target_size = File.size(target)
|
58
|
+
|
59
|
+
expected_size == target_size || fail_with(
|
60
|
+
"expected #{target.inspect} to be the same size as #{expected.inspect}"
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
def assert_target_contains_all_expected_entries
|
65
|
+
both_paths_in(@expected, @target).all? do |expected_path, target_path|
|
66
|
+
exists_msg = "expected #{target_path.inspect} to exist since #{expected_path.inspect} exists"
|
67
|
+
assert_exists(target_path, exists_msg) && assert_equal_content(expected_path, target_path)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def refute_extra_files_in_target
|
72
|
+
expected_files = both_paths_in(@expected, @target).map { |pair| pair[1] }
|
73
|
+
actual_expected_files = Dir.glob(File.join(@target, "**/*"))
|
74
|
+
diff = actual_expected_files - expected_files
|
75
|
+
diff.empty? || fail_with("found unexpected files #{diff.inspect}")
|
76
|
+
end
|
77
|
+
|
78
|
+
def fail_with(message)
|
79
|
+
@failure_message = message
|
80
|
+
false
|
81
|
+
end
|
82
|
+
|
83
|
+
def both_paths_in(expected, target)
|
84
|
+
Enumerator.new do |y|
|
85
|
+
glob = File.join(expected, "**/*")
|
86
|
+
Dir.glob(glob).each do |expected_full_path|
|
87
|
+
path = expected_full_path.sub(expected, "")
|
88
|
+
target_full_path = File.join(target, path)
|
89
|
+
y << [expected_full_path, target_full_path]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "minitest"
|
2
|
+
require "assert_dirs_equal/matcher"
|
3
|
+
|
4
|
+
module AssertDirsEqual
|
5
|
+
class Diff
|
6
|
+
extend Minitest::Assertions
|
7
|
+
|
8
|
+
def self.perform(expected, actual)
|
9
|
+
diff(expected, actual)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Minitest::Test
|
15
|
+
def assert_dirs_equal(expected, target)
|
16
|
+
matcher = AssertDirsEqual::Matcher.new(expected)
|
17
|
+
assert matcher.matches?(target), matcher.failure_message
|
18
|
+
end
|
19
|
+
|
20
|
+
def refute_dirs_equal(expected, target)
|
21
|
+
matcher = AssertDirsEqual::Matcher.new(expected)
|
22
|
+
refute matcher.matches?(target), matcher.failure_message_when_negated
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
hello
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
hello
|
@@ -0,0 +1 @@
|
|
1
|
+
world
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
hello
|
@@ -0,0 +1 @@
|
|
1
|
+
hello
|
File without changes
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "assert_dirs_equal/matcher"
|
3
|
+
|
4
|
+
module AssertDirsEqual
|
5
|
+
class MatcherTest < Minitest::Test
|
6
|
+
def matcher
|
7
|
+
@matcher ||= Matcher.new(expected_dir)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_missing_expected
|
11
|
+
@case_directory = "test/cases/missing_expected"
|
12
|
+
refute matcher.matches?(target_dir)
|
13
|
+
assert_equal "expected \"#{expected_dir}\" to exist", matcher.failure_message
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_missing_target
|
17
|
+
@case_directory = "test/cases/missing_target"
|
18
|
+
refute matcher.matches?(target_dir)
|
19
|
+
assert_equal "expected \"#{target_dir}\" to exist", matcher.failure_message
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_expected_is_not_a_dir
|
23
|
+
@case_directory = "test/cases/expected_is_not_a_dir"
|
24
|
+
refute matcher.matches?(target_dir)
|
25
|
+
assert_equal "expected \"#{expected_dir}\" to be a directory", matcher.failure_message
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_target_is_not_a_dir
|
29
|
+
@case_directory = "test/cases/target_is_not_a_dir"
|
30
|
+
refute matcher.matches?(target_dir)
|
31
|
+
assert_equal "expected \"#{target_dir}\" to be a directory", matcher.failure_message
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_empty_dirs_are_equal
|
35
|
+
@case_directory = "test/cases/empty_dirs_are_equal"
|
36
|
+
assert matcher.matches?(target_dir), matcher.failure_message
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_missing_file_in_target
|
40
|
+
@case_directory = "test/cases/missing_file_in_target"
|
41
|
+
refute matcher.matches?(target_dir)
|
42
|
+
assert_equal "expected \"#{target_dir}/file\" to exist since \"#{expected_dir}/file\" exists", matcher.failure_message
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_missing_directory_in_target
|
46
|
+
@case_directory = "test/cases/missing_directory_in_target"
|
47
|
+
refute matcher.matches?(target_dir)
|
48
|
+
assert_equal "expected \"#{target_dir}/directory\" to exist since \"#{expected_dir}/directory\" exists", matcher.failure_message
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_missing_nested_file_in_target
|
52
|
+
@case_directory = "test/cases/missing_nested_file_in_target"
|
53
|
+
refute matcher.matches?(target_dir)
|
54
|
+
assert_equal "expected \"#{target_dir}/nested/file\" to exist since \"#{expected_dir}/nested/file\" exists", matcher.failure_message
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_empty_files_are_equal
|
58
|
+
@case_directory = "test/cases/empty_files_are_equal"
|
59
|
+
assert matcher.matches?(target_dir), matcher.failure_message
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_different_text_files
|
63
|
+
@case_directory = "test/cases/different_text_files"
|
64
|
+
refute matcher.matches?(target_dir)
|
65
|
+
assert_equal <<MSG.strip, matcher.failure_message
|
66
|
+
expected "#{target_dir}/file" to have same content as "#{expected_dir}/file":
|
67
|
+
Expected: "hello"
|
68
|
+
Actual: "world"
|
69
|
+
MSG
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_same_text_files
|
73
|
+
@case_directory = "test/cases/same_text_files"
|
74
|
+
assert matcher.matches?(target_dir), matcher.failure_message
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_different_binary_files
|
78
|
+
@case_directory = "test/cases/different_binary_files"
|
79
|
+
refute matcher.matches?(target_dir)
|
80
|
+
assert_equal "expected \"#{target_dir}/file.png\" to be the same size as \"#{expected_dir}/file.png\"", matcher.failure_message
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_same_binary_files
|
84
|
+
@case_directory = "test/cases/same_binary_files"
|
85
|
+
assert matcher.matches?(target_dir), matcher.failure_message
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_binary_and_text_files
|
89
|
+
@case_directory = "test/cases/binary_and_text_files"
|
90
|
+
refute matcher.matches?(target_dir)
|
91
|
+
assert_equal "expected \"#{target_dir}/file.txt\" to be the same size as \"#{expected_dir}/file.txt\"", matcher.failure_message
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_extra_file_in_target
|
95
|
+
@case_directory = "test/cases/extra_file_in_target"
|
96
|
+
refute matcher.matches?(target_dir)
|
97
|
+
assert_equal "found unexpected files [\"#{target_dir}/file\"]", matcher.failure_message
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_failure_message_negated
|
101
|
+
@case_directory = "test/cases/empty_dirs_are_equal"
|
102
|
+
matcher.matches?(target_dir)
|
103
|
+
assert_equal "expected \"#{target_dir}\" to not be equal to \"#{expected_dir}\", but they are equal", matcher.failure_message_when_negated
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "minitest/assert_dirs_equal"
|
3
|
+
|
4
|
+
module AssertDirsEqual
|
5
|
+
class MinitestIntegrationTest < Minitest::Test
|
6
|
+
def test_successful_assert
|
7
|
+
@case_directory = "test/cases/empty_dirs_are_equal"
|
8
|
+
assert_dirs_equal expected_dir, target_dir
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_failed_assert
|
12
|
+
@case_directory = "test/cases/missing_expected"
|
13
|
+
|
14
|
+
error = assert_raises(Minitest::Assertion) do
|
15
|
+
assert_dirs_equal expected_dir, target_dir
|
16
|
+
end
|
17
|
+
|
18
|
+
assert_equal "expected \"#{expected_dir}\" to exist", error.message
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_successful_refute
|
22
|
+
@case_directory = "test/cases/missing_expected"
|
23
|
+
refute_dirs_equal expected_dir, target_dir
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_failed_refute
|
27
|
+
@case_directory = "test/cases/empty_dirs_are_equal"
|
28
|
+
|
29
|
+
error = assert_raises(Minitest::Assertion) do
|
30
|
+
refute_dirs_equal expected_dir, target_dir
|
31
|
+
end
|
32
|
+
|
33
|
+
assert_equal "expected \"#{target_dir}\" to not be equal to \"#{expected_dir}\", but they are equal", error.message
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_minitest_powered_diff
|
37
|
+
@case_directory = "test/cases/large_different_text_files"
|
38
|
+
|
39
|
+
error = assert_raises(Minitest::Assertion) do
|
40
|
+
assert_dirs_equal expected_dir, target_dir
|
41
|
+
end
|
42
|
+
|
43
|
+
assert_equal <<MSG, error.message
|
44
|
+
expected "#{target_dir}/file" to have same content as "#{expected_dir}/file":
|
45
|
+
--- expected
|
46
|
+
+++ actual
|
47
|
+
@@ -11,7 +11,7 @@
|
48
|
+
minitest
|
49
|
+
minitest
|
50
|
+
minitest
|
51
|
+
-minitest
|
52
|
+
+rspec
|
53
|
+
minitest
|
54
|
+
minitest
|
55
|
+
minitest
|
56
|
+
MSG
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: assert_dirs_equal
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrii Malyshko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.4'
|
55
|
+
description: Test assertion for directories equality by tree and content comparison
|
56
|
+
email:
|
57
|
+
- mail@nashbridges.me
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- ".yardopts"
|
65
|
+
- CHANGELOG.md
|
66
|
+
- CONTRIBUTING.md
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- assert_dirs_equal.gemspec
|
72
|
+
- lib/assert_dirs_equal/matcher.rb
|
73
|
+
- lib/minitest/assert_dirs_equal.rb
|
74
|
+
- test/cases/binary_and_text_files/expected/file.txt
|
75
|
+
- test/cases/binary_and_text_files/target/file.txt
|
76
|
+
- test/cases/different_binary_files/expected/file.png
|
77
|
+
- test/cases/different_binary_files/target/file.png
|
78
|
+
- test/cases/different_text_files/expected/file
|
79
|
+
- test/cases/different_text_files/target/file
|
80
|
+
- test/cases/empty_files_are_equal/expected/file
|
81
|
+
- test/cases/empty_files_are_equal/target/file
|
82
|
+
- test/cases/expected_is_not_a_dir/expected
|
83
|
+
- test/cases/extra_file_in_target/target/file
|
84
|
+
- test/cases/large_different_text_files/expected/file
|
85
|
+
- test/cases/large_different_text_files/target/file
|
86
|
+
- test/cases/missing_file_in_target/expected/file
|
87
|
+
- test/cases/missing_nested_file_in_target/expected/nested/file
|
88
|
+
- test/cases/same_binary_files/expected/file.png
|
89
|
+
- test/cases/same_binary_files/target/file.png
|
90
|
+
- test/cases/same_text_files/expected/file
|
91
|
+
- test/cases/same_text_files/target/file
|
92
|
+
- test/cases/target_is_not_a_dir/target
|
93
|
+
- test/matcher_test.rb
|
94
|
+
- test/minitest_integration_test.rb
|
95
|
+
- test/test_helper.rb
|
96
|
+
homepage: https://github.com/torba-rb/assert_dirs_equal
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.4.5.1
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Test assertion for directories equality by tree and content comparison
|
120
|
+
test_files:
|
121
|
+
- test/cases/binary_and_text_files/expected/file.txt
|
122
|
+
- test/cases/binary_and_text_files/target/file.txt
|
123
|
+
- test/cases/different_binary_files/expected/file.png
|
124
|
+
- test/cases/different_binary_files/target/file.png
|
125
|
+
- test/cases/different_text_files/expected/file
|
126
|
+
- test/cases/different_text_files/target/file
|
127
|
+
- test/cases/empty_files_are_equal/expected/file
|
128
|
+
- test/cases/empty_files_are_equal/target/file
|
129
|
+
- test/cases/expected_is_not_a_dir/expected
|
130
|
+
- test/cases/extra_file_in_target/target/file
|
131
|
+
- test/cases/large_different_text_files/expected/file
|
132
|
+
- test/cases/large_different_text_files/target/file
|
133
|
+
- test/cases/missing_file_in_target/expected/file
|
134
|
+
- test/cases/missing_nested_file_in_target/expected/nested/file
|
135
|
+
- test/cases/same_binary_files/expected/file.png
|
136
|
+
- test/cases/same_binary_files/target/file.png
|
137
|
+
- test/cases/same_text_files/expected/file
|
138
|
+
- test/cases/same_text_files/target/file
|
139
|
+
- test/cases/target_is_not_a_dir/target
|
140
|
+
- test/matcher_test.rb
|
141
|
+
- test/minitest_integration_test.rb
|
142
|
+
- test/test_helper.rb
|
143
|
+
has_rdoc:
|