Skip to content

Instantly share code, notes, and snippets.

@haydenmuhl
Created August 11, 2011 16:11
Show Gist options
  • Save haydenmuhl/1140037 to your computer and use it in GitHub Desktop.
Save haydenmuhl/1140037 to your computer and use it in GitHub Desktop.
// 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
}
}
// 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