Restructure response specs
Also no change in behaviour
This commit is contained in:
parent
e6e3b0bd27
commit
2e073a07fa
@ -1,44 +1,47 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Zero::Response, '#finish' do
|
describe Zero::Response do
|
||||||
subject { Zero::Response.new() }
|
subject { Zero::Response.new() }
|
||||||
|
|
||||||
it "returns an array within status header and body" do
|
describe '#finish' do
|
||||||
subject.status = 200
|
it "returns an array within status header and body" do
|
||||||
subject.header = {}
|
subject.status = 200
|
||||||
subject.body = []
|
subject.header = {}
|
||||||
|
subject.body = []
|
||||||
|
|
||||||
value = subject.to_a
|
value = subject.to_a
|
||||||
|
|
||||||
value.should be_an_instance_of(Array)
|
value.should be_an_instance_of(Array)
|
||||||
value[0].should eq(200) # Status code
|
value[0].should eq(200) # Status code
|
||||||
value[1].should eq({}) # Headers
|
value[1].should eq({}) # Headers
|
||||||
value[2].should eq([]) # Body
|
value[2].should eq([]) # Body
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
describe Zero::Response, '#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
|
|
||||||
end
|
|
||||||
|
|
||||||
describe Zero::Response, '#header' do
|
|
||||||
it "must return an empty hash, if no header was set" do
|
|
||||||
subject.header.should eq({})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe Zero::Response, '#body' do
|
|
||||||
it "must return an empty array, if no body was set" do
|
|
||||||
subject.body.should eq([])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#header' do
|
||||||
|
it "must return an empty hash, if no header was set" do
|
||||||
|
subject.header.should eq({})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#body' do
|
||||||
|
it "must return an empty array, if no body was set" do
|
||||||
|
subject.body.should eq([])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user