Skip to content

Commit

Permalink
Add test for the error response without JSON output
Browse files Browse the repository at this point in the history
  • Loading branch information
sh19910711 committed Aug 12, 2015
1 parent d8a373c commit 87ab763
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/templates/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ map "/mock/repl/error" do
body = [ { output: 'fake-error-message' }.to_json ]
run lambda { |env| [ 400, headers, body ] }
end

map "/mock/repl_sessions/error.txt" do
headers = { 'Content-Type' => 'plain/text' }
body = [ 'error message' ]
run lambda { |env| [ 400, headers, body ] }
end
15 changes: 15 additions & 0 deletions test/templates/spec/repl_console_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ describe("REPLConsole", function() {
assert.ok(hasClass(this.message, 'error-message'));
});
});

context("remotePath: /mock/repl_sessions/error.txt", function() {
beforeEach(function(done) {
var self = this;
var options = { remotePath: '/mock/repl_sessions/error.txt' };
self.console = REPLConsole.installInto('console', options);
self.console.commandHandle('fake-input', function(result, response) {
self.message = self.elm.getElementsByClassName('console-message')[0];
done();
});
});
it("should output HTTP status code", function() {
assert.match(this.message.innerHTML, /400 Bad Request/);
});
});
});

describe(".installInto()", function() {
Expand Down

0 comments on commit 87ab763

Please sign in to comment.