Created
August 11, 2011 16:11
-
-
Save haydenmuhl/1140037 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Class under test | |
class Repo { | |
static listRepos() { | |
def dir = new File("repos") | |
def repos = [] | |
dir.listFiles().each { | |
def regex = /repos\/(.+)\.git/ | |
def match = it =~ regex | |
if(match.size() > 0) { | |
repos.push(match[0][1]) | |
} | |
} | |
return repos | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Snippet of test | |
void testShowRefBranch() { | |
def mockRepo = new MockFor(Repo, true) | |
mockRepo.demand.refName(1..1) { type, ref -> | |
Repo.refName(type, ref) | |
} | |
mockRepo.use() { | |
assertEquals(model, controller.showRef()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment