assert_dirs_equal 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: daf396e81ffce0b83fd79a9218cf036385b0c695
4
- data.tar.gz: 000fafee50178f01fd58bc5da8cb01948091f592
3
+ metadata.gz: aa4cdc7043d5798e78745e4a6fa8e03659516168
4
+ data.tar.gz: 54334a10d86c433bafa573757102dbd0a915a906
5
5
  SHA512:
6
- metadata.gz: 5396b72a55da522376094401f159b0ef3bc46e96503532c8e3d766132e4ac44bb5e7935903e19d7c4777e722e955a132a2e19388f81e08b47bc512d7045a0737
7
- data.tar.gz: caff9934d55bb2000b8b4059ab0e339b86491ad91db47f5a27934a17539c4bf951411dd8eee3852e47730fbe03eb55cdc64996f6b62bd1d203968c838f681cd2
6
+ metadata.gz: b61f753c46796ed63928ee2f0ab1fe06b1ed0be71f6f6cb6cb180d0e31b9eb8667d993131070938833b247b71d3ed77b31096a14d3dc9d0a2fda6eb2acc3dbaf
7
+ data.tar.gz: 606d3e449e37a2050a84834363513cb6dfdb576a8e9c02ac73574b800b460136f1bb02b6bdf5c6a4d455ca4a53058645485708100c7e7fc6dc3a894c8f6ecf10
data/CHANGELOG.md CHANGED
@@ -1 +1,7 @@
1
1
  ## Unreleased
2
+
3
+ ## 0.1.1
4
+
5
+ ### Bug fixes
6
+
7
+ * Binary files are compared by content, not by size
data/README.md CHANGED
@@ -12,7 +12,7 @@ Production ready.
12
12
 
13
13
  ## Documentation
14
14
 
15
- [Released version](http://rubydoc.info/gems/assert_dirs_equal/0.1.0)
15
+ [Released version](http://rubydoc.info/gems/assert_dirs_equal/0.1.1)
16
16
 
17
17
  ## Why
18
18
 
@@ -58,6 +58,12 @@ end
58
58
 
59
59
  TODO
60
60
 
61
+ ## Known issues
62
+
63
+ Due that Rubinius String#strip doesn't fail on binary data (undocumented behaviour), the library will
64
+ try to actually diff binary files. Depending on your test framework's diffing tool, it may or may not
65
+ be a problem. For example, Minitest is not affected, since it uses shell `diff` under the hood.
66
+
61
67
  ## Origin
62
68
 
63
69
  Extracted from [Torba][torba-github] library since it looks more like a standalone component.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "assert_dirs_equal"
3
- spec.version = "0.1.0"
3
+ spec.version = "0.1.1"
4
4
  spec.authors = ["Andrii Malyshko"]
5
5
  spec.email = ["mail@nashbridges.me"]
6
6
  spec.description = "Test assertion for directories equality by tree and content comparison"
@@ -46,18 +46,18 @@ module AssertDirsEqual
46
46
  def assert_equal_content(expected, target)
47
47
  return true if File.directory?(expected) && File.directory?(target)
48
48
 
49
- expected_content = File.read(expected).strip
50
- target_content = File.read(target).strip
49
+ expected_content = File.read(expected)
50
+ target_content = File.read(target)
51
+
52
+ expected_content = expected_content.strip
53
+ target_content = target_content.strip
51
54
 
52
55
  expected_content == target_content || fail_with(
53
56
  "expected #{target.inspect} to have same content as #{expected.inspect}:\n#{Diff.perform(expected_content, target_content)}"
54
57
  )
55
58
  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}"
59
+ expected_content == target_content || fail_with(
60
+ "expected #{target.inspect} to be the same as #{expected.inspect}"
61
61
  )
62
62
  end
63
63
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/test/matcher_test.rb CHANGED
@@ -31,23 +31,12 @@ module AssertDirsEqual
31
31
  assert_equal "expected \"#{target_dir}\" to be a directory", matcher.failure_message
32
32
  end
33
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
34
  def test_missing_file_in_target
40
35
  @case_directory = "test/cases/missing_file_in_target"
41
36
  refute matcher.matches?(target_dir)
42
37
  assert_equal "expected \"#{target_dir}/file\" to exist since \"#{expected_dir}/file\" exists", matcher.failure_message
43
38
  end
44
39
 
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
40
  def test_missing_nested_file_in_target
52
41
  @case_directory = "test/cases/missing_nested_file_in_target"
53
42
  refute matcher.matches?(target_dir)
@@ -74,21 +63,29 @@ MSG
74
63
  assert matcher.matches?(target_dir), matcher.failure_message
75
64
  end
76
65
 
66
+ def test_same_text_files_with_trailing_newline
67
+ @case_directory = "test/cases/same_text_files_with_trailing_newline"
68
+ assert matcher.matches?(target_dir), matcher.failure_message
69
+ end
70
+
77
71
  def test_different_binary_files
72
+ skip_rubinius_string_strip
78
73
  @case_directory = "test/cases/different_binary_files"
79
74
  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
75
+ assert_equal "expected \"#{target_dir}/file.png\" to be the same as \"#{expected_dir}/file.png\"", matcher.failure_message
81
76
  end
82
77
 
83
78
  def test_same_binary_files
79
+ skip_rubinius_string_strip
84
80
  @case_directory = "test/cases/same_binary_files"
85
81
  assert matcher.matches?(target_dir), matcher.failure_message
86
82
  end
87
83
 
88
84
  def test_binary_and_text_files
85
+ skip_rubinius_string_strip
89
86
  @case_directory = "test/cases/binary_and_text_files"
90
87
  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
88
+ assert_equal "expected \"#{target_dir}/file.txt\" to be the same as \"#{expected_dir}/file.txt\"", matcher.failure_message
92
89
  end
93
90
 
94
91
  def test_extra_file_in_target
@@ -4,7 +4,7 @@ require "minitest/assert_dirs_equal"
4
4
  module AssertDirsEqual
5
5
  class MinitestIntegrationTest < Minitest::Test
6
6
  def test_successful_assert
7
- @case_directory = "test/cases/empty_dirs_are_equal"
7
+ @case_directory = "test/cases/empty_files_are_equal"
8
8
  assert_dirs_equal expected_dir, target_dir
9
9
  end
10
10
 
@@ -24,7 +24,7 @@ module AssertDirsEqual
24
24
  end
25
25
 
26
26
  def test_failed_refute
27
- @case_directory = "test/cases/empty_dirs_are_equal"
27
+ @case_directory = "test/cases/empty_files_are_equal"
28
28
 
29
29
  error = assert_raises(Minitest::Assertion) do
30
30
  refute_dirs_equal expected_dir, target_dir
data/test/test_helper.rb CHANGED
@@ -9,4 +9,10 @@ class Minitest::Test
9
9
  def target_dir
10
10
  File.join(@case_directory, "target")
11
11
  end
12
+
13
+ def skip_rubinius_string_strip
14
+ if RUBY_ENGINE == "rbx"
15
+ skip "Rubinius doesn't fail on binary data with String#strip"
16
+ end
17
+ end
12
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert_dirs_equal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrii Malyshko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-27 00:00:00.000000000 Z
11
+ date: 2016-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,15 +80,25 @@ files:
80
80
  - test/cases/empty_files_are_equal/expected/file
81
81
  - test/cases/empty_files_are_equal/target/file
82
82
  - test/cases/expected_is_not_a_dir/expected
83
+ - test/cases/expected_is_not_a_dir/target/.keep
84
+ - test/cases/extra_file_in_target/expected/.keep
85
+ - test/cases/extra_file_in_target/target/.keep
83
86
  - test/cases/extra_file_in_target/target/file
84
87
  - test/cases/large_different_text_files/expected/file
85
88
  - test/cases/large_different_text_files/target/file
89
+ - test/cases/missing_expected/.keep
86
90
  - test/cases/missing_file_in_target/expected/file
91
+ - test/cases/missing_file_in_target/target/.keep
87
92
  - test/cases/missing_nested_file_in_target/expected/nested/file
93
+ - test/cases/missing_nested_file_in_target/target/nested/.keep
94
+ - test/cases/missing_target/expected/.keep
88
95
  - test/cases/same_binary_files/expected/file.png
89
96
  - test/cases/same_binary_files/target/file.png
90
97
  - test/cases/same_text_files/expected/file
91
98
  - test/cases/same_text_files/target/file
99
+ - test/cases/same_text_files_with_trailing_newline/expected/file
100
+ - test/cases/same_text_files_with_trailing_newline/target/file
101
+ - test/cases/target_is_not_a_dir/expected/.keep
92
102
  - test/cases/target_is_not_a_dir/target
93
103
  - test/matcher_test.rb
94
104
  - test/minitest_integration_test.rb
@@ -127,15 +137,25 @@ test_files:
127
137
  - test/cases/empty_files_are_equal/expected/file
128
138
  - test/cases/empty_files_are_equal/target/file
129
139
  - test/cases/expected_is_not_a_dir/expected
140
+ - test/cases/expected_is_not_a_dir/target/.keep
141
+ - test/cases/extra_file_in_target/expected/.keep
142
+ - test/cases/extra_file_in_target/target/.keep
130
143
  - test/cases/extra_file_in_target/target/file
131
144
  - test/cases/large_different_text_files/expected/file
132
145
  - test/cases/large_different_text_files/target/file
146
+ - test/cases/missing_expected/.keep
133
147
  - test/cases/missing_file_in_target/expected/file
148
+ - test/cases/missing_file_in_target/target/.keep
134
149
  - test/cases/missing_nested_file_in_target/expected/nested/file
150
+ - test/cases/missing_nested_file_in_target/target/nested/.keep
151
+ - test/cases/missing_target/expected/.keep
135
152
  - test/cases/same_binary_files/expected/file.png
136
153
  - test/cases/same_binary_files/target/file.png
137
154
  - test/cases/same_text_files/expected/file
138
155
  - test/cases/same_text_files/target/file
156
+ - test/cases/same_text_files_with_trailing_newline/expected/file
157
+ - test/cases/same_text_files_with_trailing_newline/target/file
158
+ - test/cases/target_is_not_a_dir/expected/.keep
139
159
  - test/cases/target_is_not_a_dir/target
140
160
  - test/matcher_test.rb
141
161
  - test/minitest_integration_test.rb