Sha256: 91a46abff1b97207d52aa883af46c2c32e15d879014b873f984b024758193925

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe Google::Scholar::AuthorsProfileDocument do
  subject {Google::Scholar::AuthorsProfileDocument.new(author_profile_page)}
  it "should have a valid subject" do
    subject
  end
  describe ".has_next_page?" do
    context "if the document has a next page" do
      it "should return true" do
        subject.should have_next_page
      end
    end
    context "if the document doesn't have a next page" do
      let(:author_profile_page) {Nokogiri::HTML::DocumentFragment.parse(File.open(File.join(FIXTURE_DIR,"author_profile_page.htm")).read.to_s.gsub('Next',''))}
      it "should return false" do
        subject.should_not have_next_page
      end
    end
  end
  describe ".next_page_url" do
    it "should return the url for the next page" do
      subject.next_page_url.should == "http://scholar.google.com/citations?hl=en&user=M7uPknsAAAAJ&view_op=list_works&cstart=20"
    end
  end
  describe ".articles" do
    it "should return the articles for this page" do
      subject.articles.length.should == 20
    end
    it "should return article summary objects" do
      subject.articles.first.should be_kind_of Google::Scholar::ArticleSummary
    end
    it "should have the right titles" do
      subject.articles.first.title.should == "Weblogs and the 'middle space'for learning"
    end
  end
end
def author_profile_page
  @author_profile ||= Nokogiri::HTML::DocumentFragment.parse(File.open(File.join(FIXTURE_DIR,"author_profile_page.htm")).read)
end

Version data entries

2 entries across 2 versions & 1 rubygems

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