Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
166 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
require "../spec_helper" | ||
|
||
describe Crest do | ||
describe "Streaming" do | ||
it "should stream Response#execute" do | ||
body = String::Builder.new | ||
request = Crest::Request.new(:get, "#{TEST_SERVER_URL}/") | ||
|
||
request.execute do |resp| | ||
while line = resp.body_io.gets | ||
body << line | ||
end | ||
end | ||
|
||
body.to_s.should eq("Hello World!") | ||
end | ||
|
||
it "should stream Request.execute" do | ||
body = String::Builder.new | ||
Crest::Request.get("#{TEST_SERVER_URL}/") do |resp| | ||
while line = resp.body_io.gets | ||
body << line | ||
end | ||
end | ||
|
||
body.to_s.should eq("Hello World!") | ||
end | ||
|
||
it "should stream Request.get" do | ||
body = String::Builder.new | ||
Crest::Request.execute(:get, "#{TEST_SERVER_URL}/") do |resp| | ||
while line = resp.body_io.gets | ||
body << line | ||
end | ||
end | ||
|
||
body.to_s.should eq("Hello World!") | ||
end | ||
|
||
it "should stream Crest#get" do | ||
body = String::Builder.new | ||
Crest.get("#{TEST_SERVER_URL}/") do |resp| | ||
while line = resp.body_io.gets | ||
body << line | ||
end | ||
end | ||
|
||
body.to_s.should eq("Hello World!") | ||
end | ||
|
||
it "should stream Crest#get with redirects" do | ||
body = String::Builder.new | ||
|
||
Crest.get("#{TEST_SERVER_URL}/redirect/2") do |resp| | ||
while line = resp.body_io.gets | ||
body << line | ||
end | ||
end | ||
|
||
body.to_s.should eq("Hello World!") | ||
end | ||
|
||
it "should stream Response#execute with redirects" do | ||
body = String::Builder.new | ||
request = Crest::Request.new(:get, "#{TEST_SERVER_URL}/redirect/2") | ||
|
||
request.execute do |resp| | ||
while line = resp.body_io.gets | ||
body << line | ||
end | ||
end | ||
|
||
body.to_s.should eq("Hello World!") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters