Skip to content

Instantly share code, notes, and snippets.

@marocchino
Last active August 29, 2015 13:56
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 marocchino/9028034 to your computer and use it in GitHub Desktop.
Save marocchino/9028034 to your computer and use it in GitHub Desktop.
instance variable test
class Problem
ERROR:
tooComplicated: new Error "I can't do that"
constructor: ->
@tokens = ["some", "tokens"]
answer: ->
if @tokens
throw @ERROR.tooComplicated
describe 'Problem', ->
it 'can catch throw', ->
problem = new Problem
expect(problem.answer()).toThrow(problem.ERROR.tooComplicated)
it 'can retrieve @tokens', ->
problem = new Problem
expect(problem.answer).toThrow(problem.ERROR.tooComplicated)
$ jasmine-node --version
1.13.1
$ node -v
v0.10.25
$ jasmine-node --coffee user_before_test.spec.coffee
FF
Failures:
1) Problem can catch throw
Message:
Error: I can't do that
Stacktrace:
Error: I can't do that
at /Users/marocchino/Documents/exercism/coffeescript/wordy/user_test.spec.coffee:3:25
at Object.<anonymous> (/Users/marocchino/Documents/exercism/coffeescript/wordy/user_test.spec.coffee:21:5)
at Object.<anonymous> (/Users/marocchino/Documents/exercism/coffeescript/wordy/user_test.spec.coffee:1:1)
at Module._compile (module.js:456:26)
at Object.loadFile (/usr/local/share/npm/lib/node_modules/jasmine-node/node_modules/coffee-script/lib/coffee-script/register.js:16:19)
at Module.load (/usr/local/share/npm/lib/node_modules/jasmine-node/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.jasmine.executeSpecsInFolder (/usr/local/share/npm/lib/node_modules/jasmine-node/lib/jasmine-node/index.js:159:9)
at Object.<anonymous> (/usr/local/share/npm/lib/node_modules/jasmine-node/lib/jasmine-node/cli.js:244:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/share/npm/lib/node_modules/jasmine-node/bin/jasmine-node:6:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
2) Problem can retrieve @tokens
Message:
Expected function to throw an exception.
Stacktrace:
Error: Expected function to throw an exception.
at [object Object].<anonymous> (/Users/marocchino/Documents/exercism/coffeescript/wordy/user_test.spec.coffee:19:28)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
Finished in 0.029 seconds
2 tests, 2 assertions, 2 failures, 0 skipped
class Problem
ERROR:
tooComplicated: new Error "I can't do that"
constructor: ->
@tokens = ["some", "tokens"]
answer: ->
if @tokens
throw @ERROR.tooComplicated
describe 'Problem', ->
it 'can not retrieve @tokens', ->
problem = new Problem
expect(problem.answer).not.toThrow(problem.ERROR.tooComplicated)
it 'can catch throw', ->
problem = new Problem
expect(-> problem.answer()).toThrow(problem.ERROR.tooComplicated)
jasmine-node --coffee user_after_test.spec.coffee
..
Finished in 0.007 seconds
2 tests, 2 assertions, 0 failures, 0 skipped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment