have_files
Version, currently 0.4.014 versions
- 0.4.0latestJun 7, 2018
- 0.3.4not indexedMar 29, 2021
- 0.3.3not indexedMar 29, 2021
- 0.3.2not indexedMar 29, 2021
- 0.3.1.1not indexedMar 29, 2021
- 0.3.0not indexedMar 29, 2021
- 0.2.2not indexedMar 29, 2021
- 0.2.1not indexedMar 29, 2021
- 0.2.0not indexedMar 29, 2021
- 0.1.4not indexedMar 29, 2021
- 0.1.3not indexedMar 29, 2021
- 0.1.2not indexedMar 29, 2021
- 0.1.1not indexedMar 29, 2021
- 0.1.0not indexedMar 29, 2021
github.com/mosop/have_files
A Crystal Spec/spec2 matcher for testing if two file trees are identical.
Installation
# Add this to your shard.yml
dependencies:
have_files:
github: mosop/have_files
version: ~> 0.4.0Then run:
shards installshard.yml
- Crystal
0.24.2- License
- MIT
- Author
- mosop
Dependencies
Runtime Dependencies
- stdio~> 0.1.4github: mosop/stdio
Development Dependencies
- spec2~> 0.9github: waterlink/spec2.crdev
README
have_files
A Crystal Spec/spec2 matcher for testing if two file trees are identical.
Requirements
- Git (git diff) - is used for file comparison.
Installation
Add this to your application's shard.yml:
dependencies:
have_files:
github: mosop/have_files
Usage
require "spec"
require "have_files/spec"
it "may work" do
"/path/to/actual".should have_files "/path/to/expected"
end
If test fails, have_files generates a diff message like:
Failures:
1) may work
Failure/Error: nil.should have_files("/path/to/expected") do |dir|
diff/test.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/diff/test.txt b/diff/test.txt
index 8ab686e..415b41d 100644
--- a/diff/test.txt
+++ b/diff/test.txt
@@ -1 +1 @@
-Hello, World!
+Hello, Worlb!
# ./spec/hello_spec.cr:8
Finished in 203.09 milliseconds
1 examples, 1 failures, 0 errors, 0 pending
Preventing Namespace Pollution
To prevent pollution of top level namespace, you can directly create expectations.
require "spec"
require "have_files/spec/expectation"
it "may work" do
"/path/to/actual".should HaveFiles::Spec::Expectation.new("/path/to/expected")
end
Or you can define the have_files method anywhere you like.
require "spec"
require "have_files/spec/dsl"
module Test
extend HaveFiles::Spec::Dsl
it "may work" do
"/path/to/actual".should have_files "/path/to/expected"
end
end
have_files "/path/to/expected" # => compile error
With spec2
You can also use have_files with spec2.
require "spec2"
require "have_files/spec2"
Spec2.describe "with spec2" do
it "is expected to work" do
expect("/path/to/actual") have_files "/path/to/expected"
end
end
API
have_files
Parameters
- expected_dir : A path to your expected file tree. (required)
- base_dir : A base path of working directory. To compare file trees with
git diff, have_files makes a working directory, that is temporary and uniquely named, under this path and copies all of target files into the working directory. (default:/tmp) - cleanup : Determines whether working directory will be deleted after test ends. (default:
true)
Details
have_files treats an actual value as a path of directory whose actual files. Then have_files copies the directory into a working directory and compares it to an expected file tree.
Releases
- v0.3.0
- (Breaking Change) nil can't be passed as an actual value any longer.
- v0.2.0
- (Experimental) spec2 matcher
- (Breaking Change) Move HaveFiles::Expectation to HaveFiles::Spec::Expectation
- (Breaking Change) Move HaveFiles::Dsl to HaveFiles::Spec::Dsl
- v0.1.2
- HaveFiles::Expectation
- HaveFiles::Dsl
Development
[WIP]
Contributing
- Fork it ( https://github.com/mosop/have_files/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- mosop - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.4.0- Tagged
- Jun 7, 2018
- Commit
a53412323383- Crystal
0.24.2- Indexed
- yes
Dependents
Repository
github.com/mosop/have_files
Metadata
- Created
- Aug 12, 2026
- Updated
- Sep 25, 2026
- Synced
- Sep 25, 2026
- Versions
- 14