Sha256: da37875e6333d3fe80661d4b2f761766d5bcdf79e9289f84bca08bc172551f41

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

# encoding: UTF-8
require 'spec_helper'

describe Grim::Pdf do

  it "should have a path" do
    Grim::Pdf.new(fixture_path("smoker.pdf")).path.should == fixture_path("smoker.pdf")
  end

  describe "#initialize" do
    it "should raise an error if pdf does not exist" do
      lambda { Grim::Pdf.new(fixture_path("booboo.pdf")) }.should raise_error(Grim::PdfNotFound)
    end

    it "should set path on pdf" do
      pdf = Grim::Pdf.new(fixture_path("smoker.pdf"))
      pdf.path.should == fixture_path("smoker.pdf")
    end
  end

  describe "#count" do
    it "should return 25" do
      pdf = Grim::Pdf.new(fixture_path("smoker.pdf"))
      pdf.count.should == 25
    end
  end

  describe "#[]" do
    before(:each) do
      @pdf = Grim::Pdf.new(fixture_path("smoker.pdf"))
    end

    it "should raise Grim::PageDoesNotExist if page doesn't exist" do
      lambda { @pdf[25] }.should raise_error(Grim::PageNotFound)
    end

    it "should return an instance of Grim::Page if page exists" do
      @pdf[24].class.should == Grim::Page
    end
  end

  describe "#each" do
    it "should be iterable" do
      pdf = Grim::Pdf.new(fixture_path("smoker.pdf"))
      pdf.map {|p| p.number }.should == (1..25).to_a
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grim-0.2.4 spec/lib/grim/pdf_spec.rb
grim-0.2.3 spec/lib/grim/pdf_spec.rb
grim-0.2.2 spec/lib/grim/pdf_spec.rb
grim-0.2.1 spec/lib/grim/pdf_spec.rb