minitest-filesystem 1.1.1 → 1.2.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: a1f50869c9e1a8567409b58a165057b3e23766bc
4
- data.tar.gz: f51c45d5eb02b7efa117ba22ae50086750379e04
3
+ metadata.gz: 3112ef0d0c7fec41ca692952474b708b221a0eb6
4
+ data.tar.gz: 28ccf465c1ac8610e782050e335c05f187a464a8
5
5
  SHA512:
6
- metadata.gz: e482bc5bfe18c51fcc4288d57462f5927b9c6378b84e291d99eadd425731332beddaa6674ad66ecc021ba7f522d4e1c91e3922fe0f01a99b8c875da763e13de3
7
- data.tar.gz: 5f4e68d4dc3563af02e74348e69c2fbb2c2c9ab647d3ccc8e338c54c6d69a95beea86209de2abeb3bf71492b950c847edd783a86ffd1d2f66849055a315a87c7
6
+ metadata.gz: 21056eab24d7f14771b6873c81b692a6da6fa5bc88b081b607387103559a832fc016f6492b0f008894a37e7bf08e784686c663cbd5daa2f13df84bdf59022ac2
7
+ data.tar.gz: c705157c1ebd517dd702d8397c7e19a1f18718866b3c8a7fee8ec416a5d4cc757d9caac47252ada8db240937bfd52ee3ffa1cd1ac79f3120d3bc68bb5a069a4b
Binary file
data.tar.gz.sig CHANGED
Binary file
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ spec/reports
20
20
  test/tmp
21
21
  test/version_tmp
22
22
  tmp
23
+ vendor
@@ -1 +1 @@
1
- 2.0.0-p195
1
+ ruby-2.1
@@ -2,13 +2,11 @@
2
2
  language: ruby
3
3
 
4
4
  rvm:
5
- - 1.8.7
6
5
  - 1.9.3
7
6
  - 2.0.0
8
- - jruby-18mode
7
+ - 2.1
9
8
  - jruby-19mode
10
- - rbx-18mode
11
- - rbx-19mode
9
+ - rbx
12
10
 
13
11
  bundler_args: --path vendor/bundle
14
12
 
data/README.md CHANGED
@@ -29,6 +29,7 @@ require 'minitest/filesystem'
29
29
 
30
30
  ## Usage
31
31
 
32
+ ### Testing for a filesystem subtree
32
33
  Let's suppose the following filesystem structure exists:
33
34
 
34
35
  * `root_dir/`
@@ -76,6 +77,37 @@ filesystem {
76
77
  Note that the match **need not to be exact** (i.e. there can be other files and
77
78
  directories inside `root_dir` that the matcher won't care about).
78
79
 
80
+ ### Syntactic sugar
81
+
82
+ As a nicety, some custom assertions/matchers are provided to make your test
83
+ suites look better. They're almost just syntactic sugar around the methods
84
+ provided by `File`, `Dir` et al, but allow for improved code readability. So,
85
+ for example, instead of writing
86
+
87
+ assert File.exists? "/a/file"
88
+
89
+ you can write
90
+
91
+ assert_exists "/a/file"
92
+
93
+ or, even better
94
+
95
+ "/a/file".must_exist
96
+
97
+ **Assertions**
98
+
99
+ * `assert_exists`: test whether a specific path exists (no matter if file, dir,
100
+ symlink)
101
+ * `refute_exists`: test whether a specific path doesn't exist (no matter if file, dir,
102
+ symlink)
103
+
104
+ **Expectations**
105
+
106
+ The meaning of the following expectation is the same as their assertive
107
+ counterpart:
108
+ * `must_exist`
109
+ * `wont_exist`
110
+
79
111
  ## Contributing
80
112
 
81
113
  1. Fork it
@@ -86,6 +118,11 @@ directories inside `root_dir` that the matcher won't care about).
86
118
 
87
119
  ## Changelog
88
120
 
121
+ ### 1.2.0
122
+
123
+ * Added `assert_exists`, `refute_exists`, `must_exist`, `wont_exist`
124
+ * Refactored previous test code to lighter syntax
125
+
89
126
  ### 1.1.1
90
127
 
91
128
  * Minor refactorings and project infrastructure updates.
@@ -7,6 +7,14 @@ module Minitest::Assertions
7
7
  assert matcher.match_found?, msg || matcher.message
8
8
  end
9
9
 
10
+ def assert_exists(path, msg = nil, &block)
11
+ assert File.exists?(path), msg || "expected `#{path}` to exist, but it doesn't"
12
+ end
13
+
14
+ def refute_exists(path, msg = nil, &block)
15
+ refute File.exists?(path), msg || "expected `#{path}` not to exist, but it does"
16
+ end
17
+
10
18
  def filesystem(&block)
11
19
  block
12
20
  end
@@ -14,4 +22,6 @@ end
14
22
 
15
23
  module Minitest::Expectations
16
24
  infect_an_assertion :assert_contains_filesystem, :must_exist_within
25
+ infect_an_assertion :assert_exists, :must_exist, :unary
26
+ infect_an_assertion :refute_exists, :wont_exist, :unary
17
27
  end
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Filesystem
3
- VERSION = "1.1.1"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -1,62 +1,58 @@
1
1
  require 'test_helper'
2
2
 
3
- require 'tmpdir'
4
- require 'fileutils'
5
-
6
3
  describe "assert_contains_filesystem" do
4
+ let(:root_dir) { Pathname.new(Dir.mktmpdir('minitestfs')) }
7
5
  before do
8
- @root_dir = Pathname.new(Dir.mktmpdir('minitestfs'))
9
-
10
- (@root_dir + 'a_directory').mkdir
11
- (@root_dir + 'a_subdirectory').mkdir
12
- (@root_dir + 'a_subdirectory' + 'deeper_subdirectory').mkdir
13
- (@root_dir + 'not_a_file').mkdir
14
- (@root_dir + 'unchecked_dir').mkdir
6
+ (root_dir + 'a_directory').mkdir
7
+ (root_dir + 'a_subdirectory').mkdir
8
+ (root_dir + 'a_subdirectory' + 'deeper_subdirectory').mkdir
9
+ (root_dir + 'not_a_file').mkdir
10
+ (root_dir + 'unchecked_dir').mkdir
15
11
 
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')
20
- FileUtils.touch(@root_dir + 'not_a_dir')
21
- FileUtils.touch(@root_dir + 'not_a_link')
22
- FileUtils.touch(@root_dir + 'a_subdirectory' + 'deeper_subdirectory' + 'another_file')
23
- FileUtils.touch(@root_dir + 'unchecked_file')
12
+ touch root_dir + 'a_file'
13
+ touch root_dir + 'actual_file'
14
+ symlink root_dir + 'doesnt_matter', root_dir + 'a_link'
15
+ symlink root_dir + 'actual_file', root_dir + 'link_to'
16
+ touch root_dir + 'not_a_dir'
17
+ touch root_dir + 'not_a_link'
18
+ touch root_dir + 'a_subdirectory' + 'deeper_subdirectory' + 'another_file'
19
+ touch root_dir + 'unchecked_file'
24
20
  end
25
21
 
26
22
  after do
27
- FileUtils.rm_rf @root_dir
23
+ rm root_dir
28
24
  end
29
25
 
30
26
  it "passes with empty expected tree" do
31
- assert_contains_filesystem(@root_dir) {}
27
+ assert_contains_filesystem(root_dir) {}
32
28
  end
33
29
 
34
30
  it "passes when single file found" do
35
- assert_contains_filesystem(@root_dir) do
31
+ assert_contains_filesystem(root_dir) do
36
32
  file "a_file"
37
33
  end
38
34
  end
39
35
 
40
36
  it "passes when single link found" do
41
- assert_contains_filesystem(@root_dir) do
37
+ assert_contains_filesystem(root_dir) do
42
38
  link "a_link"
43
39
  end
44
40
  end
45
41
 
46
42
  it "passes when a link points to the correct target" do
47
- assert_contains_filesystem(@root_dir) do
43
+ assert_contains_filesystem(root_dir) do
48
44
  link "link_to", "actual_file"
49
45
  end
50
46
  end
51
47
 
52
48
  it "passes when single directory found" do
53
- assert_contains_filesystem(@root_dir) do
49
+ assert_contains_filesystem(root_dir) do
54
50
  dir "a_directory"
55
51
  end
56
52
  end
57
53
 
58
54
  it "passes when a file within a nested subtree is found" do
59
- assert_contains_filesystem(@root_dir) do
55
+ assert_contains_filesystem(root_dir) do
60
56
  dir "a_subdirectory" do
61
57
  dir "deeper_subdirectory" do
62
58
  file "another_file"
@@ -66,25 +62,25 @@ describe "assert_contains_filesystem" do
66
62
  end
67
63
 
68
64
  it "fails when an expected file isn't found" do
69
- l = lambda { assert_contains_filesystem(@root_dir) do
65
+ l = lambda { assert_contains_filesystem(root_dir) do
70
66
  file "foo"
71
67
  end }
72
68
 
73
69
  error = assert_raises(Minitest::Assertion, &l)
74
- error.message.must_match(/expected `#{@root_dir}` to contain file `foo`/im)
70
+ error.message.must_match(/expected `#{root_dir}` to contain file `foo`/im)
75
71
  end
76
72
 
77
73
  it "fails when an expected symlink isn't found" do
78
- l = lambda { assert_contains_filesystem(@root_dir) do
74
+ l = lambda { assert_contains_filesystem(root_dir) do
79
75
  link "foo"
80
76
  end }
81
77
 
82
78
  error = assert_raises(Minitest::Assertion, &l)
83
- error.message.must_match(/expected `#{@root_dir}` to contain symlink `foo`/im)
79
+ error.message.must_match(/expected `#{root_dir}` to contain symlink `foo`/im)
84
80
  end
85
81
 
86
82
  it "fails when a symlink points to the wrong file" do
87
- l = lambda { assert_contains_filesystem(@root_dir) do
83
+ l = lambda { assert_contains_filesystem(root_dir) do
88
84
  link "link_to", "nonexistent_target"
89
85
  end }
90
86
 
@@ -93,16 +89,16 @@ describe "assert_contains_filesystem" do
93
89
  end
94
90
 
95
91
  it "fails when an expected directory isn't found" do
96
- l = lambda { assert_contains_filesystem(@root_dir) do
92
+ l = lambda { assert_contains_filesystem(root_dir) do
97
93
  dir "bar"
98
94
  end }
99
95
 
100
96
  error = assert_raises(Minitest::Assertion, &l)
101
- error.message.must_match(/expected `#{@root_dir}` to contain directory `bar`/im)
97
+ error.message.must_match(/expected `#{root_dir}` to contain directory `bar`/im)
102
98
  end
103
99
 
104
100
  it "fails when an expected file within a subdirectory isn't found" do
105
- l = lambda { assert_contains_filesystem(@root_dir) do
101
+ l = lambda { assert_contains_filesystem(root_dir) do
106
102
  dir "a_subdirectory" do
107
103
  file "missing_file"
108
104
  end
@@ -110,11 +106,11 @@ describe "assert_contains_filesystem" do
110
106
 
111
107
  error = assert_raises(Minitest::Assertion, &l)
112
108
  error.message.must_match(
113
- /expected `#{@root_dir + 'a_subdirectory'}` to contain file `missing_file`/im)
109
+ /expected `#{root_dir + 'a_subdirectory'}` to contain file `missing_file`/im)
114
110
  end
115
111
 
116
112
  it "fails when a directory is expected to be a file" do
117
- l = lambda { assert_contains_filesystem(@root_dir) do
113
+ l = lambda { assert_contains_filesystem(root_dir) do
118
114
  file "not_a_file"
119
115
  end }
120
116
 
@@ -123,7 +119,7 @@ describe "assert_contains_filesystem" do
123
119
  end
124
120
 
125
121
  it "fails when a file is expected to be a directory" do
126
- l = lambda { assert_contains_filesystem(@root_dir) do
122
+ l = lambda { assert_contains_filesystem(root_dir) do
127
123
  dir "not_a_dir"
128
124
  end }
129
125
 
@@ -132,7 +128,7 @@ describe "assert_contains_filesystem" do
132
128
  end
133
129
 
134
130
  it "fails when a file is expected to be a symlink" do
135
- l = lambda { assert_contains_filesystem(@root_dir) do
131
+ l = lambda { assert_contains_filesystem(root_dir) do
136
132
  link "not_a_link"
137
133
  end }
138
134
 
@@ -143,7 +139,7 @@ describe "assert_contains_filesystem" do
143
139
  it "allows to print custom error messages" do
144
140
  failure_msg = "I really miss this file a lot"
145
141
 
146
- l = lambda { assert_contains_filesystem(@root_dir, failure_msg) do
142
+ l = lambda { assert_contains_filesystem(root_dir, failure_msg) do
147
143
  file "baz"
148
144
  end }
149
145
 
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+
3
+ describe "assert_exists" do
4
+ let(:root_dir) { Pathname.new(Dir.mktmpdir("minitestfs")) }
5
+ let(:a_path) { root_dir + "a_file" }
6
+
7
+ it "fails when the given path is not found" do
8
+ l = lambda { assert_exists(a_path) }
9
+
10
+ error = assert_raises(Minitest::Assertion, &l)
11
+ error.message.must_match(/expected `#{a_path}` to exist/im)
12
+ end
13
+
14
+ it "allows to print custom error messages" do
15
+ failure_msg = "I really miss this path a lot"
16
+
17
+ l = lambda { assert_exists(a_path, failure_msg) }
18
+
19
+ error = assert_raises(Minitest::Assertion, &l)
20
+ error.message.must_equal(failure_msg)
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+
3
+ describe "refute_exists" do
4
+ let(:root_dir) { Pathname.new(Dir.mktmpdir("minitestfs")) }
5
+
6
+ it "fails when the given path is found" do
7
+ l = lambda { refute_exists(root_dir) }
8
+
9
+ error = assert_raises(Minitest::Assertion, &l)
10
+ error.message.must_match(/expected `#{root_dir}` not to exist/im)
11
+ end
12
+ end
13
+
@@ -0,0 +1,45 @@
1
+ require 'test_helper'
2
+
3
+ describe "filesystem must_exist_within" do
4
+ let(:root_dir) { Pathname.new(Dir.mktmpdir('minitestfs')) }
5
+
6
+ before do
7
+ (root_dir + 'a_directory').mkdir
8
+ (root_dir + 'a_subdirectory').mkdir
9
+ (root_dir + 'a_subdirectory' + 'deeper_subdirectory').mkdir
10
+ (root_dir + 'not_a_file').mkdir
11
+ (root_dir + 'unchecked_dir').mkdir
12
+
13
+ touch root_dir + 'a_file'
14
+ touch root_dir + 'not_a_dir'
15
+ touch root_dir + 'a_subdirectory' + 'deeper_subdirectory' + 'another_file'
16
+ touch root_dir + 'unchecked_file'
17
+ end
18
+
19
+ after do
20
+ rm root_dir
21
+ end
22
+
23
+ it "passes when the expected tree is found" do
24
+ filesystem {
25
+ file "a_file"
26
+ dir "a_subdirectory" do
27
+ dir "deeper_subdirectory" do
28
+ file "another_file"
29
+ end
30
+ end
31
+ }.must_exist_within(root_dir)
32
+ end
33
+
34
+ it "fails when the expected tree is not found" do
35
+ l = lambda { filesystem {
36
+ file "a_file"
37
+ dir "a_subdirectory"
38
+ file "missing_file"
39
+ }.must_exist_within(root_dir) }
40
+
41
+ error = assert_raises(Minitest::Assertion, &l)
42
+ error.message.must_match(
43
+ /expected `#{root_dir}` to contain file `missing_file`/im)
44
+ end
45
+ end
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ describe "must_exist" do
4
+ let(:a_path) { Pathname.new("/lmao/if/this/exists") }
5
+
6
+ it "fails when the expected path doesn't exist" do
7
+ l = lambda { a_path.must_exist }
8
+ assert_raises(Minitest::Assertion, &l)
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ require 'test_helper'
2
+
3
+ describe "wont_exist" do
4
+ let(:a_path) { Pathname.new(Dir.mktmpdir('minitestfs')) }
5
+
6
+ it "fails when the expected path exists" do
7
+ l = lambda { a_path.wont_exist }
8
+ assert_raises(Minitest::Assertion, &l)
9
+ end
10
+ end
11
+
@@ -5,3 +5,18 @@ require 'minitest/autorun'
5
5
  require 'minitest/spec'
6
6
 
7
7
  require 'minitest/filesystem'
8
+
9
+ require 'tmpdir'
10
+ require 'fileutils'
11
+
12
+ def touch(path)
13
+ FileUtils.touch(path)
14
+ end
15
+
16
+ def rm(path)
17
+ FileUtils.rm_rf(path)
18
+ end
19
+
20
+ def symlink(path, link)
21
+ FileUtils.ln_s(path, link)
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-filesystem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Zanella
@@ -29,90 +29,90 @@ cert_chain:
29
29
  RigBD0E3/t/ABjCXkmqwp5gnAZmP8JiVUkn8rp5E0FXvC8T7nsPs2TW/TAmUV6rN
30
30
  hK25FX8YWgT9fD9y3PpWjiYcrCo=
31
31
  -----END CERTIFICATE-----
32
- date: 2013-09-06 00:00:00.000000000 Z
32
+ date: 2014-03-28 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: bundler
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  type: :development
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.3'
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rake
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: minitest
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  type: :development
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: coveralls
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  type: :development
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  - !ruby/object:Gem::Dependency
91
91
  name: flog
92
92
  requirement: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: flay
106
106
  requirement: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  type: :development
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  description: Minitest exstension to check filesystem contents
@@ -122,9 +122,9 @@ executables: []
122
122
  extensions: []
123
123
  extra_rdoc_files: []
124
124
  files:
125
- - .gitignore
126
- - .ruby-version
127
- - .travis.yml
125
+ - ".gitignore"
126
+ - ".ruby-version"
127
+ - ".travis.yml"
128
128
  - Gemfile
129
129
  - LICENSE.txt
130
130
  - README.md
@@ -134,8 +134,12 @@ files:
134
134
  - lib/minitest/filesystem/version.rb
135
135
  - minitest-filesystem.gemspec
136
136
  - rubygems-stefanozanella.crt
137
- - test/assertion_test.rb
138
- - test/expectation_test.rb
137
+ - test/assertions/assert_contains_filesystem_test.rb
138
+ - test/assertions/assert_exists_test.rb
139
+ - test/assertions/refute_exists_test.rb
140
+ - test/expectations/filesystem_must_exist_within_test.rb
141
+ - test/expectations/must_exist_test.rb
142
+ - test/expectations/wont_exist_test.rb
139
143
  - test/test_helper.rb
140
144
  homepage: https://github.com/stefanozanella/minitest-filesystem
141
145
  licenses:
@@ -147,22 +151,26 @@ require_paths:
147
151
  - lib
148
152
  required_ruby_version: !ruby/object:Gem::Requirement
149
153
  requirements:
150
- - - '>='
154
+ - - ">="
151
155
  - !ruby/object:Gem::Version
152
156
  version: '0'
153
157
  required_rubygems_version: !ruby/object:Gem::Requirement
154
158
  requirements:
155
- - - '>='
159
+ - - ">="
156
160
  - !ruby/object:Gem::Version
157
161
  version: '0'
158
162
  requirements: []
159
163
  rubyforge_project:
160
- rubygems_version: 2.0.2
164
+ rubygems_version: 2.2.0
161
165
  signing_key:
162
166
  specification_version: 4
163
167
  summary: Adds assertions and expectations to check the content of a filesystem tree
164
168
  with minitest
165
169
  test_files:
166
- - test/assertion_test.rb
167
- - test/expectation_test.rb
170
+ - test/assertions/assert_contains_filesystem_test.rb
171
+ - test/assertions/assert_exists_test.rb
172
+ - test/assertions/refute_exists_test.rb
173
+ - test/expectations/filesystem_must_exist_within_test.rb
174
+ - test/expectations/must_exist_test.rb
175
+ - test/expectations/wont_exist_test.rb
168
176
  - test/test_helper.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,48 +0,0 @@
1
- require 'test_helper'
2
-
3
- require 'tmpdir'
4
- require 'fileutils'
5
-
6
- describe "filesystem must_exist_within" do
7
- before do
8
- @root_dir = Pathname.new(Dir.mktmpdir('minitestfs'))
9
-
10
- (@root_dir + 'a_directory').mkdir
11
- (@root_dir + 'a_subdirectory').mkdir
12
- (@root_dir + 'a_subdirectory' + 'deeper_subdirectory').mkdir
13
- (@root_dir + 'not_a_file').mkdir
14
- (@root_dir + 'unchecked_dir').mkdir
15
-
16
- FileUtils.touch(@root_dir + 'a_file')
17
- FileUtils.touch(@root_dir + 'not_a_dir')
18
- FileUtils.touch(@root_dir + 'a_subdirectory' + 'deeper_subdirectory' + 'another_file')
19
- FileUtils.touch(@root_dir + 'unchecked_file')
20
- end
21
-
22
- after do
23
- FileUtils.rm_rf @root_dir
24
- end
25
-
26
- it "passes when the expected tree is found" do
27
- filesystem {
28
- file "a_file"
29
- dir "a_subdirectory" do
30
- dir "deeper_subdirectory" do
31
- file "another_file"
32
- end
33
- end
34
- }.must_exist_within(@root_dir)
35
- end
36
-
37
- it "fails when the expected tree is not found" do
38
- l = lambda { filesystem {
39
- file "a_file"
40
- dir "a_subdirectory"
41
- file "missing_file"
42
- }.must_exist_within(@root_dir) }
43
-
44
- error = assert_raises(Minitest::Assertion, &l)
45
- error.message.must_match(
46
- /expected `#{@root_dir}` to contain file `missing_file`/im)
47
- end
48
- end