Sha256: 65b6995075624e9b65ae6b87a2a10c3dd53ecdf700bb3e0621d91acd455eff5b

Contents?: true

Size: 1.85 KB

Versions: 5

Compression:

Stored size: 1.85 KB

Contents

require 'spec_helper'

describe Rspreadsheet::Workbook do
  it 'has correct number of sheets' do
    book = Rspreadsheet::Workbook.new($test_filename)
    book.worksheets_count.should == 1
    book.worksheets(0).should be_nil
    book.worksheets(1).should be_kind_of(Rspreadsheet::Worksheet)
    book.worksheets(2).should be_nil
    book.worksheets(nil).should be_nil
  end
  it 'freshly created has correctly namespaced xmlnode' do
    @xmlnode = Rspreadsheet::Workbook.new.xmlnode
    @xmlnode.namespaces.to_a.size.should >5
    @xmlnode.namespaces.find_by_prefix('office').should_not be_nil
    @xmlnode.namespaces.find_by_prefix('table').should_not be_nil
    @xmlnode.namespaces.namespace.prefix.should == 'office'
  end
  it 'can create worksheets, and count them' do
    book = Rspreadsheet::Workbook.new()
    book.worksheets_count.should == 0
    book.create_worksheet
    book.worksheets_count.should == 1
    book.create_worksheet
    book.create_worksheet
    book.worksheets_count.should == 3
  end
  it 'nonemptycells behave correctly' do
    book = Rspreadsheet::Workbook.new()
    book.create_worksheet
    @sheet = book.worksheets(1)
    @sheet.cells(3,3).value = 'data'
    @sheet.cells(5,7).value = 'data'
    @sheet.nonemptycells.collect{|c| c.coordinates}.should =~  [[3,3],[5,7]]
  end
  it 'can create named sheets and they are the same as "numbered" ones' do
    book = Rspreadsheet::Workbook.new
    book.create_worksheet('test')
    book.worksheets('test').should eq book.worksheets(1)
    book.create_worksheet('another')
    book.worksheets('another').should eq book.worksheets(2)    
  end
  it 'can access sheets with brief syntax' do
    book = Rspreadsheet::Workbook.new
    book.create_worksheet('test')
    book.worksheets('test').should be book.worksheets(1)
    book['test'].should be book.worksheets(1)
    book[1].should be book.worksheets(1)
  end
end 

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rspreadsheet-0.2.10 spec/workbook_spec.rb
rspreadsheet-0.2.9 spec/workbook_spec.rb
rspreadsheet-0.2.7 spec/workbook_spec.rb
rspreadsheet-0.2.5 spec/workbook_spec.rb
rspreadsheet-0.2.4 spec/workbook_spec.rb