Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Commit

Permalink
Added spec for gh-17 and actually really fixed it this time.
Browse files Browse the repository at this point in the history
  • Loading branch information
turboladen committed Nov 14, 2012
1 parent 6f5b161 commit 38b863c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/rtsp/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def split_head_and_body_from raw_response
#
# @param [String] line The String containing the status line info.
def extract_status_line(line)
line =~ /RTSP|HTTP\/(\d\.\d) (\d\d\d) ([^\r\n]+)/
@rtsp_version = $1
@code = $2.to_i
@message = $3
line =~ /(RTSP|HTTP)\/(\d\.\d) (\d\d\d) ([^\r\n]+)/
@rtsp_version = $2
@code = $3.to_i
@message = $4

if @rtsp_version.nil?
raise RTSP::Error, "Status line corrupted: #{line}"
Expand Down
30 changes: 30 additions & 0 deletions spec/rtsp/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,36 @@
end
end

describe "#extract_status_line" do
before do
RTSP::Response.any_instance.stub(:split_head_and_body_from)
RTSP::Response.any_instance.stub(:parse_head)
RTSP::Response.any_instance.stub(:parse_body)
end

subject { RTSP::Response.new " " }

context "RTSP response" do
let(:status_line) { "RTSP/1.0 200 OK\r\n" }
before { subject.extract_status_line(status_line) }
specify {
subject.rtsp_version.should == "1.0"
subject.code.should == 200
subject.message.should == "OK"
}
end

context "HTTP response" do
let(:status_line) { "HTTP/1.1 200 OK\r\n" }
before { subject.extract_status_line(status_line) }
specify {
subject.rtsp_version.should == "1.1"
subject.code.should == 200
subject.message.should == "OK"
}
end
end

describe "#parse_head" do
let(:head) do
head = double "head"
Expand Down

0 comments on commit 38b863c

Please sign in to comment.