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

- old
+ new

@@ -1,11 +1,11 @@ require 'spec_helper' describe Rspreadsheet do it 'can open ods testfile and reads its content correctly' do book = Rspreadsheet.new($test_filename) - s = book.worksheets[1] + s = book.worksheets(1) (1..10).each do |i| s[i,1].should === i end s[1,2].should === 'text' s[2,2].should === Date.new(2014,1,1) @@ -16,12 +16,12 @@ book = Rspreadsheet.new($test_filename) # than open test file book.save(tmp_filename) # and save it as temp file book1 = Rspreadsheet.new($test_filename) # now open both again book2 = Rspreadsheet.new(tmp_filename) - @sheet1 = book1.worksheets[1] - @sheet2 = book2.worksheets[1] + @sheet1 = book1.worksheets(1) + @sheet2 = book2.worksheets(1) @sheet1.nonemptycells.each do |cell| # and test identity @sheet2[cell.rowi,cell.coli].should == cell.value end end @@ -46,13 +46,13 @@ end it 'when open and save file modified, than the file is different' do tmp_filename = '/tmp/testfile1.ods' # first delete temp file File.delete(tmp_filename) if File.exists?(tmp_filename) book = Rspreadsheet.new($test_filename) # than open test file - book.worksheets[1].rows(1).cells(1).value.should_not == 'xyzxyz' - book.worksheets[1].rows(1).cells(1).value ='xyzxyz' - book.worksheets[1].rows(1).cells(1).value.should == 'xyzxyz' + book.worksheets(1).rows(1).cells(1).value.should_not == 'xyzxyz' + book.worksheets(1).rows(1).cells(1).value ='xyzxyz' + book.worksheets(1).rows(1).cells(1).value.should == 'xyzxyz' book.save(tmp_filename) # and save it as temp file # now compare them @content_doc1 = Zip::File.open($test_filename) do |zip| @@ -69,15 +69,12 @@ it 'can create new worksheet' do book = Rspreadsheet.new book.create_worksheet end it 'examples from README file are working' do - skip 'not implemented yet'; pending -=begin - book = Rspreadsheet.open($test_filename) - sheet = book.worksheets[1] + sheet = book.worksheets(1) sheet.B5 = 'cell value' sheet.B5.should eq 'cell value' sheet[5,2].should eq 'cell value' sheet.rows(5).cells(2).value.should eq 'cell value' @@ -89,19 +86,18 @@ sheet.cells(5,2).format.bold = true sheet.cells(5,2).format.background_color = '#FF0000' }.not_to raise_error - sheet.rows(4).cellvalues.sum.should eq 4+7*4 - sheet.rows(5).cells.sum{ |cell| cell.value }.should eq 4+7*4 + sheet.rows(4).cellvalues.sum{|val| val.to_f}.should eq 4+7*4 + sheet.rows(4).cells.sum{ |cell| cell.value.to_f }.should eq 4+7*4 total = 0 sheet.rows.each do |row| - expect {"Sponsor #{row[1]} with email #{row(2)} has donated #{row(3)} USD." }.not_to raise_error - total += row[1] + expect {"Sponsor #{row[1]} with email #{row[2]} has donated #{row[3]} USD." }.not_to raise_error + total += row[1].to_f end - total.should eq 99 -=end + total.should eq 55 end end