spec/workbook_spec.rb in rspreadsheet-0.2.3 vs spec/workbook_spec.rb in rspreadsheet-0.2.4

- old
+ new

@@ -1,15 +1,15 @@ require 'spec_helper' -describe Rspreadsheet::Workbook, :focus=>true do +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 + 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 @@ -26,12 +26,25 @@ book.worksheets_count.should == 3 end it 'nonemptycells behave correctly' do book = Rspreadsheet::Workbook.new() book.create_worksheet - @sheet = book.worksheets[1] + @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