spec/weary/request_spec.rb in weary-0.2.1 vs spec/weary/request_spec.rb in weary-0.2.3

- old
+ new

@@ -1,9 +1,6 @@ -require 'rubygems' -gem 'rspec' -require 'spec' -require File.join(File.dirname(__FILE__), '../..', 'lib', 'weary') +require File.join(File.dirname(__FILE__), '..', 'spec_helper') describe Weary::Request do it "should contain a url" do test = Weary::Request.new("http://google.com") @@ -18,9 +15,27 @@ it "should craft a Net/HTTP Request" do test = Weary::Request.new("http://google.com").send :http test.class.should == Net::HTTP end + it "should perform the request and retrieve a response" do + test = Weary::Request.new("http://foo.bar") + method = test.method + response = Weary::Response.new(mock_response(method, 301, {'Location' => 'http://bar.foo'}), method) + test.stub!(:perform).and_return(response) + test.perform.code.should == 301 + test.perform.redirected?.should == true + end + it "should follow redirects" do - pending "Not sure how to test this" + test = Weary::Request.new("http://foo.bar") + method = test.method + response = Weary::Response.new(mock_response(method, 301, {'Location' => 'http://bar.foo'}), method) + response.stub!(:follow_redirect).and_return Weary::Response.new(mock_response(method, 200, {}), method) + test.stub!(:perform).and_return(response) + test.perform.code.should == 301 + test.perform.redirected?.should == true + test.perform.follow_redirect.code.should == 200 + # not exactly kosher. end + end \ No newline at end of file