I'm developing a tool that accesses SVN by running the command line SVN to get info and export.
I'd like to write some Cucumber features so I don't have to keep manually testing but I'd like to mock out the SVN accesses.
Should I switch to using a Ruby SVN library and if so, which one?
Or is there a fake svn.exe that will provide programmable responses?
EDIT:
The tool takes a file path, finds the revision of parent URL a few levels up, then exports a bunch of files and 开发者_如何转开发folders at that revision into a new directory. I'd like to write something like:
Given the file "extra1.txt" contains:
"""
extra1
"""
And the file "file.txt" contains:
"""
file
"""
And SVN holds the following files at revisions:
| tests/extras/extra1.txt | 123 | extra1.txt |
| tests/path/part05/file.txt | 73 | file.txt |
When I run "ruby dry_run_create c:\tests\path\part05\file.txt"
Then the file "c:\tests\path\part05\dry_run\extra1.txt" should contain:
"""
extra1
"""
And the file "c:\tests\path\part05\dry_run\file.txt" should contain:
"""
file
"""
With examples like these I could demonstrate forever more that the correct revisions were being extracted from SVN without having to actually create a repository.
If you don't need to actually test the SVN functionality, just mock out the calls completely.
Mocha is great for this
Check out (no pun intended) http://blog.floehopper.org/articles/2006/09/01/mocha-quickstart
I gave up looking and waiting and wrote my own, MockVersion.
This provides some basic svn
and svnadmin
functionality so that I can create a mock repository with specific revisions and verify that those files are exported.
If anyone is interested in seeing more functionality, please open an issue on github.
精彩评论