Sha256: 430ca7ee2a550bcad51e754351f263d96ed272f2517102e2354a9b4bc645d338

Contents?: true

Size: 984 Bytes

Versions: 3

Compression:

Stored size: 984 Bytes

Contents

require File.dirname(__FILE__) + '/../test_helper'

class Crags::FetchTest < Test::Unit::TestCase
  context "Fetch" do
    setup do
      extend Crags::Fetch
    end

    should "fetch doc should hpricot fetched html" do
      stubs(:fetch_html).with("url").returns("html")
      Hpricot.expects(:parse).with("html").returns("doc")
      fetch_doc("url").should == "doc"
    end

    should "fetch html should fetch_request a url" do
      curb = stub(:body_str => "uhh")
      expects(:fetch_request).with("url").returns(curb)
      fetch_html("url").should == "uhh"
    end

    should "create a new request" do
      req = stub(:follow_location= => nil, :perform => nil)
      Curl::Easy.expects(:new).with("url").returns(req)
      fetch_request("url").should == req
    end
    
    should "follow redirects for fetched requests" do
      req = mock(:follow_location= => nil, :perform => nil)
      Curl::Easy.stubs(:new).returns(req)
      fetch_request("url")
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
gotascii-crags-1.4.9 test/crags/fetch_test.rb
crags-1.6.0 test/crags/fetch_test.rb
crags-1.5.9 test/crags/fetch_test.rb