Skip to content

Instantly share code, notes, and snippets.

@MichaelMartinez
Created March 11, 2012 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelMartinez/2014544 to your computer and use it in GitHub Desktop.
Save MichaelMartinez/2014544 to your computer and use it in GitHub Desktop.
CoffeeScript StrCalc Kata - Jasmine Spec's
describe "StringCalc", ->
describe "constructor with null", ->
beforeEach ->
@mystrCalc = new StrCalc()
it 'replaces null with 0', ->
(expect @mystrCalc.firstNum).toEqual 0
describe "constructor with zero ", ->
beforeEach ->
@mystrCalc = new StrCalc('0')
it 'replaces "0" with 0', ->
(expect @mystrCalc.firstNum).toEqual 0
describe "constructor with multiple numbers", ->
beforeEach ->
@mystrCalc = new StrCalc('1, 2, 3')
it 'matches first arg to firstNum', ->
(expect @mystrCalc.firstNum).toEqual 1
it 'matches second arg to secondNum', ->
(expect @mystrCalc.secondNum).toEqual 2
it 'matches third arg to thirdNum', ->
(expect @mystrCalc.thirdNum).toEqual 3
describe "add method", ->
beforeEach ->
@mystrCalc = new StrCalc('2, 4, 6')
it 'adds three arguments of StrCalc', ->
(expect @mystrCalc.total).toEqual 12
describe "add method with bigger numbers", ->
beforeEach ->
@mystrCalc = new StrCalc('20\n40, 60')
it 'adds three arguments for big numbers and wacky delimiters', ->
(expect @mystrCalc.total).toEqual 120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment