views:

105

answers:

2

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.

  1. Should I switch to using a Ruby SVN library and if so, which one?

  2. 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.

A: 

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

Jamie Wong
@Jamie: thanks for the response. I have specs that mock the calls at the lowest level. I guess I'm looking for an end to end solution that is flexible enough that I can specify the SVN revisions of files.
Bryan Ash
A: 

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.

Bryan Ash