Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v0.1.2
Fetching contributors…

Cannot retrieve contributors at this time

file 42 lines (36 sloc) 1.469 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
require File.expand_path('../test_config.rb', __FILE__)

describe "Spreadsheet" do
  setup do
    @sheet_stub = stub(:sheet)
    @session_stub = stub(:session)
    @session_stub.expects(:spreadsheet_by_key).with('foo').returns(@sheet_stub)
    ::GoogleSpreadsheet.expects(:login).with('login', 'pass').returns(@session_stub)
  end

  context "for initialize" do
    setup do
      @sheet = SheetMapper::Spreadsheet.new(:mapper => Object, :key => 'foo', :login => 'login', :password => 'pass')
    end

    should "return spreadsheet class" do
      assert_kind_of SheetMapper::Spreadsheet, @sheet
    end

    should "have access to readers" do
      assert_equal Object, @sheet.mapper
      assert_equal @session_stub, @sheet.session
      assert_equal @sheet_stub, @sheet.spreadsheet
    end
  end # initialize

  context "for find_collection_by_title method" do
    setup do
      @sheet = SheetMapper::Spreadsheet.new(:mapper => Object, :key => 'foo', :login => 'login', :password => 'pass')
      @work_stub = stub(:worksheet)
      @work_stub.expects(:title).returns("FOO")
      @work_stub.expects(:rows).returns([])
      @sheet_stub.expects(:worksheets).returns([@work_stub])
      @collection = @sheet.find_collection_by_title("foo")
    end

    should "return the expected collection" do
      assert_kind_of SheetMapper::Collection, @collection
      assert_equal @work_stub, @collection.worksheet
    end
  end # find_collection_by_title
end # Spreadsheet
Something went wrong with that request. Please try again.