spec/page_spec.rb in anemone-0.2.0 vs spec/page_spec.rb in anemone-0.2.1
- old
+ new
@@ -1,19 +1,18 @@
require File.dirname(__FILE__) + '/spec_helper'
module Anemone
describe Page do
-
+
+ before(:all) do
+ @http = Anemone::HTTP.new
+ end
+
before(:each) do
- @page = Page.fetch(FakePage.new('home').url)
+ @page = @http.fetch_page(FakePage.new('home').url)
end
- it "should be able to fetch a page" do
- @page.should_not be_nil
- @page.url.to_s.should include('home')
- end
-
it "should store the response headers when fetching a page" do
@page.headers.should_not be_nil
@page.headers.should have_key('content-type')
end
@@ -33,17 +32,21 @@
it "should indicate whether it was fetched after an HTTP redirect" do
@page.should respond_to(:redirect?)
@page.redirect?.should == false
- Page.fetch(FakePage.new('redir', :redirect => 'home').url).redirect?.should == true
+ @http.fetch_page(FakePage.new('redir', :redirect => 'home').url).redirect?.should == true
end
it "should have a method to tell if a URI is in the same domain as the page" do
@page.should respond_to(:in_domain?)
@page.in_domain?(URI(FakePage.new('test').url)).should == true
@page.in_domain?(URI('http://www.other.com/')).should == false
+ end
+
+ it "should include the response time for the HTTP request" do
+ @page.should respond_to(:response_time)
end
end
end