2012-11-16 17:56:34 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2012-11-18 16:38:38 +01:00
|
|
|
describe Zero::Response do
|
2012-11-16 17:56:34 +01:00
|
|
|
subject { Zero::Response.new() }
|
|
|
|
|
2012-11-18 16:38:38 +01:00
|
|
|
describe '#finish' do
|
|
|
|
it "returns an array within status header and body" do
|
|
|
|
subject.status = 200
|
|
|
|
subject.header = {}
|
|
|
|
subject.body = []
|
|
|
|
|
|
|
|
value = subject.to_a
|
2012-11-17 14:35:15 +01:00
|
|
|
|
2012-11-18 16:38:38 +01:00
|
|
|
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
|
2012-11-17 14:35:15 +01:00
|
|
|
end
|
2012-11-17 14:46:53 +01:00
|
|
|
|
2012-11-18 16:38:38 +01:00
|
|
|
describe '#status' do
|
|
|
|
it "must return the status always as an integer" do
|
|
|
|
subject.status = "foobar"
|
|
|
|
subject.status.should eq(0)
|
|
|
|
|
|
|
|
subject.status = 240.5
|
|
|
|
subject.status.should eq(240)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "must return 200, if no status code was set" do
|
|
|
|
subject.status.should eq(200)
|
|
|
|
end
|
2012-11-17 14:46:53 +01:00
|
|
|
end
|
2012-11-18 15:02:07 +01:00
|
|
|
|
2012-11-18 16:38:38 +01:00
|
|
|
describe '#header' do
|
|
|
|
it "must return an empty hash, if no header was set" do
|
|
|
|
subject.header.should eq({})
|
|
|
|
end
|
2012-11-18 15:02:07 +01:00
|
|
|
end
|
2012-11-18 16:09:41 +01:00
|
|
|
|
2012-11-18 16:38:38 +01:00
|
|
|
describe '#body' do
|
|
|
|
it "must return an empty array, if no body was set" do
|
|
|
|
subject.body.should eq([])
|
|
|
|
end
|
2012-11-18 16:09:41 +01:00
|
|
|
end
|
2012-11-18 16:38:38 +01:00
|
|
|
|
|
|
|
end
|