Sha256: 3bcb6085bab37d3287f0349eb82d0978a677f7f933a9cbf3dea8e9890ad2ff22
Contents?: true
Size: 1.93 KB
Versions: 1
Compression:
Stored size: 1.93 KB
Contents
require File.expand_path("#{File.dirname(__FILE__)}/../unit_spec_helper") module Thin describe JsTestCoreConnection do describe "#process" do attr_reader :connection, :result before do @connection = JsTestCoreConnection.new('signature') stub(connection).socket_address {'0.0.0.0'} @result = "" stub(EventMachine).send_data do |signature, data, data_length| result << data end end describe "and the call is successful" do describe "and the body is not empty" do attr_reader :somedir_resource before do mock(app = Object.new).call(is_a(Hash)) do [200, {}, 'The Body'] end connection.app = app end it "sends the response to the socket and closes the connection" do mock(connection).close_connection_after_writing connection.receive_data "GET /specs HTTP/1.1\r\nHost: _\r\n\r\n" result.should include("The Body") end end describe "and the body is empty" do attr_reader :somedir_resource before do mock(app = Object.new).call(is_a(Hash)) do [200, {}, []] end connection.app = app end it "keeps the connection open" do dont_allow(connection).close_connection_after_writing connection.receive_data "GET /specs HTTP/1.1\r\nHost: _\r\n\r\n" end end end describe "and the call raises an error" do it "logs the error and closes the connection" do mock(app = Object.new).call(is_a(Hash)) do raise "An Error" end connection.app = app mock(connection).log(anything).at_least(1) mock(connection).close_connection connection.receive_data "GET /specs HTTP/1.1\r\nHost: _\r\n\r\n" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
btakita-screw_unit-0.1.0 | vendor/js_test_core/spec/unit/thin/js_spec_connection_spec.rb |