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

- old
+ new

@@ -2,13 +2,12 @@ describe Rspreadsheet::Cell do before do book1 = Rspreadsheet.new @sheet1 = book1.create_worksheet - @c = @sheet1.cells(1,1) book2 = Rspreadsheet.new($test_filename) - @sheet2 = book2.worksheets[1] + @sheet2 = book2.worksheets(1) end it 'contains good row and col coordinates' do @cell = @sheet1.cells(1,3) @cell.rowi.should == 1 @cell.coli.should == 3 @@ -184,12 +183,10 @@ # after fresh create @cell.xmlnode.attributes['style-name'].should_not be_nil end it 'can set formats of the cells' do - skip 'not implemented yet'; pending -=begin @cell = @sheet2.cells(1,1) # bold @cell.format.bold.should be_falsey @cell.format.bold = true @cell.format.bold.should be_truthy @@ -202,16 +199,16 @@ @cell.format.color = '#AABBCC' @cell.format.color.should eq '#AABBCC' # background_color @cell.format.background_color.should be_nil @cell.format.background_color = '#AABBCC' + @cell.format.style_name.should_not eq 'cell' @cell.format.background_color.should eq '#AABBCC' # font_size @cell.format.font_size.should be_nil @cell.format.font_size = '11pt' @cell.format.font_size.should eq '11pt' -=end end it 'method cells without arguments returns array of cells' do @a = @sheet2.rows(1).cells @a.should be_kind_of(Array) @a.each { |item| item.should be_kind_of(Rspreadsheet::Cell)} @@ -219,11 +216,11 @@ end it 'changes coordinates when row inserted above' do @sheet1.cells(2,2).detach @cell = @sheet1.cells(2,2) @cell.rowi.should == 2 - @sheet1.insert_row_above(1) + @sheet1.add_row_above(1) @cell.rowi.should == 3 end it 'switches to invalid_reference cell when deleted' do @sheet1[2,5] = 'nejaka data' @cell = @sheet1.cells(2,2) @@ -249,13 +246,30 @@ @cell = @sheet1.cells(6,2) @cell.value = 'abcde' expect(@cell.inspect).to include('abcde','::Cell','6','2','row') end it 'stores date correctly' do - @c.value= Date.parse('2014-01-02') - @c.value.year.should eq 2014 - @c.value.month.should eq 1 - @c.value.day.should eq 2 + @cell = @sheet1.cells(1,1) + @cell.value= Date.parse('2014-01-02') + @cell.value.year.should eq 2014 + @cell.value.month.should eq 1 + @cell.value.day.should eq 2 + end + it 'can be addressed by even more ways and all are identical' do + @cell = @sheet1.cells(2,2) + @sheet1.cells('B2').value = 'zaseste' + @sheet1.cells('B2').value.should == 'zaseste' + @cell.value.should == 'zaseste' + @sheet1.cells(2,'B').value.should == 'zaseste' + @sheet1.cells(2,'B').value = 'zasedme' + @cell.value.should == 'zasedme' + @sheet1['B2'].should == 'zasedme' + @sheet1['B2'] = 'zaosme' + @cell.value.should == 'zaosme' + + @sheet2.cells('F2').should be @sheet2.cells(2,6) + @sheet2.cells('BA177').should be @sheet2.cells(177,53) + @sheet2.cells('ADA2').should be @sheet2.cells(2,781) end end