minitest-filesystem 1.0.1 → 1.1.0

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: 8147560c2e1b553781d1fe64aa3d16922e660fbb
4
- data.tar.gz: fcf37de46bdce50cd7021be4b3fb59a3c7d00b28
3
+ metadata.gz: db73e422e4760423081870612b857aaa490430d8
4
+ data.tar.gz: 77e25a5ca198b8b23706db1c57f182a123446eae
5
5
  SHA512:
6
- metadata.gz: 405554b5210ed89120068bb0e596c35b026323741ff91321fd6f96daab54f05d218e5bd41f99c313e27f1ac6bc297f769a1ca20921ad4d66665256df0749363c
7
- data.tar.gz: bb04b93b924a0f67d284a19ded922f76c660182bf5210c924fa73405d7d51f5c66c6b61071a74a3c47edf1ef1e22b2ed99a89784881f720fe185ab90bba78b67
6
+ metadata.gz: 5e58da2037fbc107914fdfbc7787c7040e203ce0b7081c79e1793050aacbdc20a84471e90f70f49362853e605cedf6e008626ba8979dec746729f662978a20cc
7
+ data.tar.gz: d829f92388c3762ddadbf0e82342b72f8e21ab8ada64ca7f9f81334f4fb2cda0e3c1961b958c52bc34b6528ba1c7d6d85f845329f5fb6dca80a10b508d692341
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ Ȃ/_Q5� �������KeUA�n�(ĕղn�H8 Q&#C
2
+ Z=�P|����a��1mQ<���o�OR�/B�9KqT&���E4�̜P5CQ"t���0^�qN.t��\-��\=�*Wl�.���E=�π��V��L���.�+;�i�b2L9����_V�sW��RRtx,�L;�4}��$�W�8!((����͑:�a�2��q
data/.gitignore CHANGED
@@ -5,6 +5,7 @@
5
5
  *.rbc
6
6
  .bundle
7
7
  .config
8
+ .envrc
8
9
  .yardoc
9
10
  .yardopts
10
11
  Gemfile.lock
data/README.md CHANGED
@@ -39,6 +39,9 @@ Let's suppose the following filesystem structure exists:
39
39
  * `subfile_2`
40
40
  * `subsubdir_1/`
41
41
  * `subdir_2/`
42
+ * `subdir_3/`
43
+ * `link_1`
44
+ * `link_2`, `'../../file_1'`
42
45
 
43
46
  You can check if `root_dir` contains a specific structure:
44
47
 
@@ -49,6 +52,9 @@ assert_contains_filesystem("root_dir") do
49
52
  file "subfile_1"
50
53
  end
51
54
  dir "subdir_2"
55
+ dir "subdir_3" do
56
+ link "link_1"
57
+ end
52
58
  end
53
59
  ```
54
60
 
@@ -61,6 +67,9 @@ filesystem {
61
67
  file "subfile_1"
62
68
  end
63
69
  dir "subdir_2"
70
+ dir "subdir_3" do
71
+ link "link_1"
72
+ end
64
73
  }.must_exist_within "root_dir"
65
74
  ```
66
75
 
@@ -77,6 +86,10 @@ directories inside `root_dir` that the matcher won't care about).
77
86
 
78
87
  ## Changelog
79
88
 
89
+ ### 1.1.0
90
+
91
+ * Add support for testing symbolic links
92
+
80
93
  ### 1.0.1
81
94
 
82
95
  * Remove CamelCase naming.
@@ -13,6 +13,10 @@ module Minitest
13
13
  entry(file, :file) && is_a?(file, :file)
14
14
  end
15
15
 
16
+ def link(link, target=nil)
17
+ entry(link, :symlink) && is_a?(link, :symlink) && is_target_correct?(link, target)
18
+ end
19
+
16
20
  def dir(dir, &block)
17
21
  matcher = self.class.new(@actual_tree.expand_path(dir), &block) if block_given?
18
22
 
@@ -36,10 +40,22 @@ module Minitest
36
40
  not_found_msg_for(entry, kind))
37
41
  end
38
42
 
43
+ def is_target_correct?(link, target)
44
+ return true unless target
45
+
46
+ update_matching_status(
47
+ @actual_tree.expand_path(target) == follow_link(@actual_tree.expand_path(link)),
48
+ link_target_mismatch_msg_for(link, target))
49
+ end
50
+
39
51
  def subtree(matcher)
40
52
  update_matching_status(matcher.match_found?, matcher.message) if matcher
41
53
  end
42
54
 
55
+ def follow_link(link)
56
+ Pathname.new(File.readlink(link))
57
+ end
58
+
43
59
  def is_a?(entry, kind)
44
60
  update_matching_status(
45
61
  @actual_tree.is_a?(entry, kind),
@@ -61,6 +77,10 @@ module Minitest
61
77
  "Expected `#{entry}` to be a #{kind}, but it was not."
62
78
  end
63
79
 
80
+ def link_target_mismatch_msg_for(link, target)
81
+ "Expected `#{link}` to point to `#{target}`, but it pointed to #{File.readlink(@actual_tree.expand_path(link))}"
82
+ end
83
+
64
84
  def set_failure_msg(msg)
65
85
  @failure_msg ||= msg
66
86
  end
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Filesystem
3
- VERSION = "1.0.1"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -1,8 +1,12 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ $:.unshift(lib) unless $:.include?(lib)
4
+
5
+ require 'pathname'
4
6
  require 'minitest/filesystem/version'
5
7
 
8
+ signing_key_file = ENV['RUBYGEMS_SIGNING_KEY_FILE']
9
+
6
10
  Gem::Specification.new do |gem|
7
11
  gem.name = "minitest-filesystem"
8
12
  gem.version = Minitest::Filesystem::VERSION
@@ -23,4 +27,7 @@ Gem::Specification.new do |gem|
23
27
  gem.add_development_dependency "rake"
24
28
  gem.add_development_dependency "minitest"
25
29
  gem.add_development_dependency "coveralls"
30
+
31
+ gem.signing_key = Pathname.new(signing_key_file).expand_path if signing_key_file
32
+ gem.cert_chain = ["rubygems-stefanozanella.crt"]
26
33
  end
@@ -0,0 +1,20 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDQDCCAiigAwIBAgIBADANBgkqhkiG9w0BAQUFADBGMRgwFgYDVQQDDA96YW5l
3
+ bGxhLnN0ZWZhbm8xFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixk
4
+ ARkWA2NvbTAeFw0xMzA4MDcxOTA2MDZaFw0xNDA4MDcxOTA2MDZaMEYxGDAWBgNV
5
+ BAMMD3phbmVsbGEuc3RlZmFubzEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYK
6
+ CZImiZPyLGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
7
+ 2JCnJCnjjs62MR/Tw/4WgSG42ruiCEqXV1ECMsXymHPE8xyHkYAwLXvBRzOkZ/IA
8
+ puJ1XhScduMRcUuE0ZPA5N2HBZI0WsmyyNTYBjOob8m0SNInoRZfIMloj3D8QzB7
9
+ /6G5HLMWNx60JEpIDgfXvIuSRKNKQ0/0+/G/H4COgj72pd3F4dYltvx+mSwPRq7Q
10
+ MdZsK3T5Q3d4eLBY1VSlJpq0wkwdEWTXAhR0Mfmbn1D8m9IhJfubgXuXVBY4OPO8
11
+ KAF/wWqTkzA6guVQlSKdZR4vwms7OpeFkotnivBKa6JwUQSXO8AZEyy53V8cSYDu
12
+ dbaFi53YbEwOWSMQnW8/kQIDAQABozkwNzAdBgNVHQ4EFgQUcBKkmJAvSTKfDf7z
13
+ LEu1wE+Rk+swCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwDQYJKoZIhvcNAQEFBQAD
14
+ ggEBAMeqfk1l4Y0iZ8jNiu0afcQ60DVqBkRtrT/rsZEqGsdOw11bntOE4yWpo4Kd
15
+ Y0C/kYrVQ/mIN7IGKbCSjES3aYdQftV9SRW77FA25m2KXRbnEYtJDUX35gAqSdRY
16
+ 9IiYivsMq2dr70eKPNFrFOwWvmwhcGyEG8EDvYoXWllke7RGz1Dn/AZx6jPnShO+
17
+ 0ru4OXsM9++md3sGXIugEFNygvo2/1yQoTe6+XiBocS+pWsJd6JZBfkxPRT4Dz4H
18
+ RigBD0E3/t/ABjCXkmqwp5gnAZmP8JiVUkn8rp5E0FXvC8T7nsPs2TW/TAmUV6rN
19
+ hK25FX8YWgT9fD9y3PpWjiYcrCo=
20
+ -----END CERTIFICATE-----
@@ -14,7 +14,11 @@ describe "assert_contains_filesystem" do
14
14
  (@root_dir + 'unchecked_dir').mkdir
15
15
 
16
16
  FileUtils.touch(@root_dir + 'a_file')
17
+ FileUtils.touch(@root_dir + 'actual_file')
18
+ FileUtils.ln_s(@root_dir + 'doesnt_matter', @root_dir + 'a_link')
19
+ FileUtils.ln_s(@root_dir + 'actual_file', @root_dir + 'link_to')
17
20
  FileUtils.touch(@root_dir + 'not_a_dir')
21
+ FileUtils.touch(@root_dir + 'not_a_link')
18
22
  FileUtils.touch(@root_dir + 'a_subdirectory' + 'deeper_subdirectory' + 'another_file')
19
23
  FileUtils.touch(@root_dir + 'unchecked_file')
20
24
  end
@@ -33,6 +37,18 @@ describe "assert_contains_filesystem" do
33
37
  end
34
38
  end
35
39
 
40
+ it "passes when single link found" do
41
+ assert_contains_filesystem(@root_dir) do
42
+ link "a_link"
43
+ end
44
+ end
45
+
46
+ it "passes when a link points to the correct target" do
47
+ assert_contains_filesystem(@root_dir) do
48
+ link "link_to", "actual_file"
49
+ end
50
+ end
51
+
36
52
  it "passes when single directory found" do
37
53
  assert_contains_filesystem(@root_dir) do
38
54
  dir "a_directory"
@@ -58,6 +74,24 @@ describe "assert_contains_filesystem" do
58
74
  error.message.must_match(/expected `#{@root_dir}` to contain file `foo`/im)
59
75
  end
60
76
 
77
+ it "fails when an expected symlink isn't found" do
78
+ l = lambda { assert_contains_filesystem(@root_dir) do
79
+ link "foo"
80
+ end }
81
+
82
+ error = assert_raises(Minitest::Assertion, &l)
83
+ error.message.must_match(/expected `#{@root_dir}` to contain symlink `foo`/im)
84
+ end
85
+
86
+ it "fails when a symlink points to the wrong file" do
87
+ l = lambda { assert_contains_filesystem(@root_dir) do
88
+ link "link_to", "nonexistent_target"
89
+ end }
90
+
91
+ error = assert_raises(Minitest::Assertion, &l)
92
+ error.message.must_match(/expected `link_to` to point to `nonexistent_target`/im)
93
+ end
94
+
61
95
  it "fails when an expected directory isn't found" do
62
96
  l = lambda { assert_contains_filesystem(@root_dir) do
63
97
  dir "bar"
@@ -97,6 +131,15 @@ describe "assert_contains_filesystem" do
97
131
  error.message.must_match(/expected `not_a_dir` to be a directory/im)
98
132
  end
99
133
 
134
+ it "fails when a file is expected to be a symlink" do
135
+ l = lambda { assert_contains_filesystem(@root_dir) do
136
+ link "not_a_link"
137
+ end }
138
+
139
+ error = assert_raises(Minitest::Assertion, &l)
140
+ error.message.must_match(/expected `not_a_link` to be a symlink/im)
141
+ end
142
+
100
143
  it "allows to print custom error messages" do
101
144
  failure_msg = "I really miss this file a lot"
102
145
 
metadata CHANGED
@@ -1,14 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-filesystem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Zanella
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
11
- date: 2013-06-21 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDQDCCAiigAwIBAgIBADANBgkqhkiG9w0BAQUFADBGMRgwFgYDVQQDDA96YW5l
14
+ bGxhLnN0ZWZhbm8xFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixk
15
+ ARkWA2NvbTAeFw0xMzA4MDcxOTA2MDZaFw0xNDA4MDcxOTA2MDZaMEYxGDAWBgNV
16
+ BAMMD3phbmVsbGEuc3RlZmFubzEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYK
17
+ CZImiZPyLGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
18
+ 2JCnJCnjjs62MR/Tw/4WgSG42ruiCEqXV1ECMsXymHPE8xyHkYAwLXvBRzOkZ/IA
19
+ puJ1XhScduMRcUuE0ZPA5N2HBZI0WsmyyNTYBjOob8m0SNInoRZfIMloj3D8QzB7
20
+ /6G5HLMWNx60JEpIDgfXvIuSRKNKQ0/0+/G/H4COgj72pd3F4dYltvx+mSwPRq7Q
21
+ MdZsK3T5Q3d4eLBY1VSlJpq0wkwdEWTXAhR0Mfmbn1D8m9IhJfubgXuXVBY4OPO8
22
+ KAF/wWqTkzA6guVQlSKdZR4vwms7OpeFkotnivBKa6JwUQSXO8AZEyy53V8cSYDu
23
+ dbaFi53YbEwOWSMQnW8/kQIDAQABozkwNzAdBgNVHQ4EFgQUcBKkmJAvSTKfDf7z
24
+ LEu1wE+Rk+swCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwDQYJKoZIhvcNAQEFBQAD
25
+ ggEBAMeqfk1l4Y0iZ8jNiu0afcQ60DVqBkRtrT/rsZEqGsdOw11bntOE4yWpo4Kd
26
+ Y0C/kYrVQ/mIN7IGKbCSjES3aYdQftV9SRW77FA25m2KXRbnEYtJDUX35gAqSdRY
27
+ 9IiYivsMq2dr70eKPNFrFOwWvmwhcGyEG8EDvYoXWllke7RGz1Dn/AZx6jPnShO+
28
+ 0ru4OXsM9++md3sGXIugEFNygvo2/1yQoTe6+XiBocS+pWsJd6JZBfkxPRT4Dz4H
29
+ RigBD0E3/t/ABjCXkmqwp5gnAZmP8JiVUkn8rp5E0FXvC8T7nsPs2TW/TAmUV6rN
30
+ hK25FX8YWgT9fD9y3PpWjiYcrCo=
31
+ -----END CERTIFICATE-----
32
+ date: 2013-09-04 00:00:00.000000000 Z
12
33
  dependencies:
13
34
  - !ruby/object:Gem::Dependency
14
35
  name: bundler
@@ -84,6 +105,7 @@ files:
84
105
  - lib/minitest/filesystem/matcher.rb
85
106
  - lib/minitest/filesystem/version.rb
86
107
  - minitest-filesystem.gemspec
108
+ - rubygems-stefanozanella.crt
87
109
  - test/assertion_test.rb
88
110
  - test/expectation_test.rb
89
111
  - test/test_helper.rb
metadata.gz.sig ADDED
Binary file