Converts any input in status to an integer
This commit is contained in:
parent
41cf83c525
commit
633d5fb7c8
|
@ -3,7 +3,17 @@ module Zero
|
|||
# This is the representation of a response
|
||||
#
|
||||
class Response
|
||||
attr_accessor :status, :header, :body
|
||||
attr_reader :status
|
||||
attr_accessor :header, :body
|
||||
|
||||
# Sets the status.
|
||||
# Also converts every input directly to an integer
|
||||
#
|
||||
# @param [Integer] status
|
||||
#
|
||||
def status=(status)
|
||||
@status = status.to_i
|
||||
end
|
||||
|
||||
# Returns the data of the response as an array:
|
||||
# [status, header, body]
|
||||
|
|
|
@ -15,5 +15,15 @@ describe Zero::Response, '#finish' do
|
|||
value[1].should eq({}) # Headers
|
||||
value[2].should eq([]) # Body
|
||||
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
|
||||
end
|
Loading…
Reference in New Issue