Permalink
Browse files

BuildScript allows calling addJob method.

  • Loading branch information...
1 parent b5d2d5c commit 7720aea7878835db4e16707a8b7d16ef46d4430d @mbezjak mbezjak committed Aug 6, 2011
@@ -16,12 +16,17 @@ abstract class BuildScript extends Script {
def methodMissing(String name, args) {
if (args.size() == 1 && args[0] instanceof Closure) {
- def job = new Job(name)
- job.with args[0]
- _build.add job
+ addJob name, args[0]
} else {
throw new MissingMethodException(name, delegate, args)
}
}
+ Job addJob(String name, Closure configurer) {
+ def job = new Job(name)
+ job.with configurer
+ _build.add job
+ job
+ }
+
}
@@ -67,4 +67,22 @@ class RunnerSpec extends Specification {
jobs.quux.deploy == true
}
+ def "run should allow calling addJob method"() {
+ when:
+ def build = runner.run("""
+ addJob 'foo', {
+ a = 1
+ b = 2
+ }
+ """)
+
+ then:
+ def jobs = build.jobs
+ jobs.size() == 1
+
+ and:
+ jobs.foo.a == 1
+ jobs.foo.b == 2
+ }
+
}

0 comments on commit 7720aea

Please sign in to comment.