Sha256: 72af8e26a2ab56f14b35f4f8e2292608655696d8a0135f29d742167f1afdb891

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'

describe Google::Scholar::Scraper do
  describe ".initialize" do
    it "should require a url" do
      expect{Google::Scholar::Scraper.new}.to raise_error
    end
    it "should validate an http url" do
      expect{Google::Scholar::Scraper.new("bla@bla.org")}.to raise_error
      expect{Google::Scholar::Scraper.new("http://scholar.google.com")}.not_to raise_error
      expect{Google::Scholar::Scraper.new("ftp://scholar.google.com")}.to raise_error
    end
    it "should load up a nokogiri document" do
      Nokogiri::HTML::Document.should_receive(:parse)
      Google::Scholar::Scraper.should_receive(:open).with("http://scholar.google.com")
      Google::Scholar::Scraper.new("http://scholar.google.com")
    end
  end
  describe ".valid?" do
    it "should forward its valid method to its document" do
      doc = double("authors document")
      doc.should_receive(:valid?).and_return(true)
      Google::Scholar::AuthorsDocument.should_receive(:new).and_return(doc)
      Google::Scholar::Scraper.should_receive(:open)
      r = Google::Scholar::Scraper.new(Google::Scholar.author_search_url("test"))
      r.valid?
    end
  end
  describe ".has_more_pages?" do
    it "should forward it to the last document it has" do
      doc = double("authors document")
      doc.should_receive(:has_next_page?)
      Google::Scholar::AuthorsDocument.should_receive(:new).and_return(doc)
      Google::Scholar::Scraper.should_receive(:open)
      r = Google::Scholar::Scraper.new(Google::Scholar.author_search_url("test"))
      r.has_more_pages?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
google-scholar-0.0.2 spec/lib/google/scholar/scraper_spec.rb
google-scholar-0.0.1 spec/lib/google/scholar/scraper_spec.rb