Created
October 25, 2009 18:24
-
-
Save jcbozonier/218178 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
given["a two number addition solver"] | |
.with("solver", new additionSolver()) | |
.with("number", [1, 2]) | |
.withParametersAs("number") | |
.when("they are added", this.solver.add) | |
.itShould("sum them", function () this.result.shouldEqual(number[1] + number[2])) | |
.itShould("not subtract them", function () this.result.shouldNotBeDumb()); | |
given["a two number addition solver"] | |
.with("solver", new additionSolver()) | |
.with("anotherDependency", new dependencyObject()) | |
.with("params", [1, 2, this.given.anotherDependency]) | |
.when("they are added", this.solver.add) | |
.itShould("sum them", function () this.result.shouldEqual(this.parameters[1] + this.parameters[2])) | |
.itShould("not subtract them", function () this.result.shouldNotBeDumb()); | |
given["a two number addition solver"] | |
.with("solver", new additionSolver()) | |
.andWith("number", [1, 2]) | |
.andWithParametersAs("number") | |
.when("they are added", this.solver.add) | |
.itShould("sum them", function () this.result.shouldEqual(number[1] + number[2])) | |
.itShouldAlso("not subtract them", function () this.result.shouldNotBeDumb()); | |
// Though dependencies get a bit uglier. | |
given("a two number addition solver") | |
.with("parameters", [1, 2]) | |
.with("solver", function(context) new additionSolver(context.solverDependencies)) | |
.when("they are added", this.solver.add) | |
.itShould("sum them", function () this.result.shouldEqual(this.num1 + this.num2)) | |
.itShould("not subtract them", function () this.result.shouldNotBeDumb()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment