Sha256: 40717a21ab965bb3d7c315ff7a3aa690b0e0787cd60030f47d24e3c2e2566a96

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

require 'spidr/page'

require 'spec_helper'
require 'page_examples'
require 'helpers/page'

describe Page do
  describe "html" do
    before(:all) do
      @page = get_page('http://spidr.rubyforge.org/course/start.html')
    end

    it_should_behave_like "Page"

    it "should be OK" do
      @page.should be_ok
    end

    it "should have a content-type" do
      @page.content_type.should =~ /text\/html/
    end

    it "should be a html page" do
      @page.should be_html
    end

    it "should have provide a document" do
      @page.doc.class.should == Nokogiri::HTML::Document
    end

    it "should allow searching the document" do
      @page.doc.search('//p').length.should == 2
      @page.doc.at('//p[2]').inner_text.should == 'Ready! Set! Go!'
    end

    it "should have a title" do
      @page.title.should == 'Spidr :: Web-Spider Obstacle Course :: Start'
    end

    it "should have links" do
      @page.links.should_not be_empty
    end
  end

  describe "txt" do
    before(:all) do
      @page = get_page('http://www.ruby-lang.org/en/LICENSE.txt')
    end

    it_should_behave_like "Page"

    it "should be OK" do
      @page.should be_ok
    end

    it "should have a content-type" do
      @page.content_type.should =~ /text\/plain/
    end

    it "should be a txt page" do
      @page.should be_txt
    end

    it "should not have provide a document" do
      @page.doc.should be_nil
    end

    it "should not allow searching the document" do
      @page.search('//p').should be_empty
      @page.at('//p').should be_nil
    end

    it "should not have links" do
      @page.links.should be_empty
    end

    it "should not have a title" do
      @page.title.should be_nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spidr-0.2.1 spec/page_spec.rb
spidr-0.2.0 spec/page_spec.rb