Sha256: 234bdeb9fb8fa2795ed41555db04895121b6c9f4d9a3831877d115baa67fc5eb

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

describe RFlow::Components::HTTP::Server do

  it "should return a default HTTP response" do
    c = RFlow::Components::HTTP::Server::Connection.new('a')
    m = RFlow::Message.new("RFlow::Message::Data::HTTP::Response")

    expected_header = "HTTP/1.1 200 ...\r\nContent-Type: text/html\r\nContent-length: 0\r\nServer: Apache\r\n\r\n"
    expected_body = ""

    c.should_receive(:send_data) do |header|
      header.should == expected_header
    end
    c.should_receive(:send_data) do |body|
      body.should == expected_body
    end
    c.should_receive(:close_connection).any_number_of_times

    c.send_http_response(m)
  end

  it "should return a fully configured HTTP response" do
    c = RFlow::Components::HTTP::Server::Connection.new('a')

    m = RFlow::Message.new("RFlow::Message::Data::HTTP::Response")
    m.data.status_code = 1337
    m.data.status_reason_phrase = "JUST BECAUSE"
    m.data.headers['Boom'] = 'Town'
    m.data.content = 'boom'

    expected_header = "HTTP/1.1 1337 ...\r\nBoom: Town\r\nContent-Type: text/html\r\nContent-length: 4\r\nServer: Apache\r\n\r\n"
    expected_body = "boom"

    c.should_receive(:send_data) do |header|
      header.should == expected_header
    end
    c.should_receive(:send_data) do |body|
      body.should == expected_body
    end
    c.should_receive(:close_connection).any_number_of_times

    c.send_http_response(m)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rflow-components-http-1.0.0a2 spec/http_server_spec.rb
rflow-components-http-1.0.0a1 spec/http_server_spec.rb