Skip to content

Instantly share code, notes, and snippets.

@jcbozonier
Created October 25, 2009 18:24
Show Gist options
  • Save jcbozonier/218178 to your computer and use it in GitHub Desktop.
Save jcbozonier/218178 to your computer and use it in GitHub Desktop.
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