Skip to content

Commit

Permalink
Better error message for status code
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Kliment committed May 21, 2015
1 parent 4420ef6 commit bafedb7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/mixins/validatable-http-message.coffee
Expand Up @@ -291,6 +291,12 @@ class Validatable
results = validator.evaluateOutputToResults()
@validation.statusCode.results = results.concat @validation.statusCode.results

@validation.statusCode.results = @validation.statusCode.results.map (current, index, arr) ->
if current.message = 'Real and expected data does not match.'
current.message = "Status code is not '#{expected}'"
current


isJsonContentType: (contentType) ->
result = false

Expand Down
5 changes: 4 additions & 1 deletion test/unit/mixins/validatable-http-message-test.coffee
Expand Up @@ -1133,11 +1133,14 @@ describe "Http validatable mixin", () ->
instance.validate()

it 'should set error message to results', () ->
assert.notEqual instance.validation.statusCode.results.length, 0
assert.equal instance.validation.statusCode.results.length, 1

it 'should return false boolean result', () ->
assert.isFalse instance.isValid()

it 'should set beutiful error message', () ->
assert.equal instance.validation.statusCode.results[0].message, "Status code is not '201'"

describe '#isJsonContentType', () ->

jsonContentTypes = [
Expand Down

0 comments on commit bafedb7

Please sign in to comment.