From 87ab7632862a04ffa3b4c14737dc0f682342d3ed Mon Sep 17 00:00:00 2001 From: Hiroyuki Sano Date: Tue, 11 Aug 2015 12:05:38 +0900 Subject: [PATCH] Add test for the error response without JSON output --- test/templates/config.ru | 6 ++++++ test/templates/spec/repl_console_spec.js | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/test/templates/config.ru b/test/templates/config.ru index 7fcdcb4c..1a09f293 100644 --- a/test/templates/config.ru +++ b/test/templates/config.ru @@ -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 diff --git a/test/templates/spec/repl_console_spec.js b/test/templates/spec/repl_console_spec.js index 1ed7f56e..7047deb4 100644 --- a/test/templates/spec/repl_console_spec.js +++ b/test/templates/spec/repl_console_spec.js @@ -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() {