0
0
Fork 0

Add simple response object

This commit is contained in:
Stormwind 2012-11-16 17:56:34 +01:00
parent f37cc87fe5
commit 0986ca27f5
3 changed files with 39 additions and 0 deletions

View File

@ -2,3 +2,4 @@ require_relative 'controller'
require_relative 'router'
require_relative 'renderer'
require_relative 'request'
require_relative 'response'

19
lib/zero/response.rb Normal file
View File

@ -0,0 +1,19 @@
module Zero
# This is the representation of a response
#
class Response
attr_accessor :status, :header, :body
# Returns the data of the response as an array:
# [status, header, body]
# to be usable by any webserver
#
# @return Array
#
def to_a()
[@status, @header, @body]
end
end
end

View File

@ -0,0 +1,19 @@
require 'spec_helper'
describe Zero::Response, '#finish' do
subject { Zero::Response.new() }
it "returns an array within status header and body" do
subject.status = 200
subject.header = {}
subject.body = []
value = subject.to_a
value.should be_an_instance_of(Array)
value[0].should eq(200) # Status code
value[1].should eq({}) # Headers
value[2].should eq([]) # Body
end
end