Permalink
Browse files

Added a basic initial test for FailedAssertionMessage.

  • Loading branch information...
1 parent f832287 commit dadb60be4da2a47f9f6a3272eb8edc95c431d897 @raroni committed Apr 6, 2012
Showing with 22 additions and 9 deletions.
  1. +7 −7 src/failed_assertion_message.coffee
  2. +2 −2 src/presenter.coffee
  3. +13 −0 test/failed_assertion_test_message_test.coffee
@@ -1,16 +1,16 @@
-module.exports = class
+module.exports = class FailedAssertionMessage
constructor: (failedAssert) ->
@type = failedAssert.type
@options = failedAssert.options
- message: ->
- if @[@type]
- @[@type]()
- else
- "Unknown assert fail: #{@type}"
-
equal: ->
"#{@options.val1} does not equal #{@options.val2}"
true: ->
"#{@options.exp} is not true"
+
+ toString: ->
+ if @[@type]
+ @[@type]()
+ else
+ "Unknown assert fail: #{@type}"
View
@@ -1,4 +1,4 @@
-FailedAssertMessageResolver = require './failed_assertion_message'
+FailedAssertionMessage = require './failed_assertion_message'
module.exports = class
constructor: (@tests, @options) ->
@@ -26,7 +26,7 @@ module.exports = class
"#{failedAssert.run.constructor.name}[#{failedAssert.run.methodName}]: #{@failedAssertMessage(failedAssert)}"
failedAssertMessage: (failedAssert) ->
- new FailedAssertMessageResolver(failedAssert).message()
+ new FailedAssertionMessage(failedAssert).toString()
summaryMessage: ->
"COMPLETE: #{@asserts} asserts, #{@failedAsserts} failed, #{@succeeded_asserts} succeeded"
@@ -0,0 +1,13 @@
+Janitor = require '../.'
+FailedAssertionMessage = require '../src/failed_assertion_message'
+
+module.exports = class FailedAssertionMessageTest extends Janitor.TestCase
+ 'test equal': ->
+ failedAssertion =
+ type: 'equal'
+ options:
+ val1: 'a'
+ val2: 'b'
+
+ message = new FailedAssertionMessage failedAssertion
+ @assertEqual 'a does not equal b', message.toString()

0 comments on commit dadb60b

Please sign in to comment.