Skip to content

Instantly share code, notes, and snippets.

@hhariri
Created October 12, 2012 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hhariri/3879379 to your computer and use it in GitHub Desktop.
Save hhariri/3879379 to your computer and use it in GitHub Desktop.
package samples
import kspec.framework.*
spec public fun calculatorSpecs() {
given("a calculator", {
val calculator = Calculator()
on("calling sum with two numbers", {
val sum = calculator.sum(2, 4)
it("should return the result of adding the first number to the second", {
shouldEqual(6, sum)
})
})
})
}
@jfromaniello
Copy link

I like more arbitrary nested describe("xxx") with it. This means no given and on. For instance:

describe('app', function(){
  describe('GET /users', function(){
    it('respond with an array of users')
  })
})

or

describe('Array', function(){
  describe('#indexOf()', function(){
    it('should return -1 unless present', function(){

    })

    it('should return the index when present', function(){

    })
  })
})

These examples are from mocha.

@jfromaniello
Copy link

your example might look like this:

describe("calculator", {
  val calculator = Calculator()
  describe("adding two numbers", {
    val sum = calculator.sum(2, 4)
    it("should return the result of adding the first number to the second", {
      shouldEqual(6, sum)
    })
  })
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment