文件名称:fakefs:伪造的文件系统。 在测试中使用它
文件大小:67KB
文件格式:ZIP
更新时间:2024-03-11 23:01:35
Ruby
虚假文件 模拟对FileUtils或File的调用意味着将测试与实现紧密耦合。 it "creates a directory" do FileUtils . expects ( :mkdir ) . with ( "directory" ) . once Library . add "directory" end 如果mkdir_p ,上述测试将mkdir_p 。 重构代码不需要重构测试。 如果要使用相对目录,则更好的方法是使用临时目录。 require 'tmpdir' it "creates a directory" do Dir . mktmpdir do | dir | Dir . chdir dir do Library . add "directory" assert File . directory? ( "direct
【文件预览】:
fakefs-master
----.gitignore(102B)
----.rspec(7B)
----etc()
--------git-rank-contributors(2KB)
----CONTRIBUTORS(5KB)
----.autotest(117B)
----.rubocop.yml(2KB)
----LICENSE(1KB)
----CHANGELOG.md(559B)
----.github()
--------workflows()
----fakefs.gemspec(870B)
----spec()
--------spec.opts(8B)
--------fakefs()
--------spec_helper.rb(89B)
----README.md(5KB)
----lib()
--------fakefs()
--------fakefs.rb(40B)
----Gemfile(40B)
----Rakefile(728B)
----test()
--------pathname_test.rb(3KB)
--------fake()
--------dir()
--------file()
--------kernel_test.rb(1KB)
--------safe_test.rb(2KB)
--------fakefs_test.rb(133KB)
--------test_helper.rb(1013B)
--------verify.rb(926B)
--------globber_test.rb(2KB)