spec/cell_spec.rb in rspreadsheet-0.2.7 vs spec/cell_spec.rb in rspreadsheet-0.2.9

- old
+ new

@@ -139,11 +139,11 @@ @cellB.range.should == (7..8) @cellB.value.should == 7 @cell = @sheet2.cells(16,4) @cell.range.should == (1..7) - @cell.value.should == "" + @cell.value.should == nil @sheet2.rows(15).range.should == (14..18) @sheet2.rows(16).range.should == (14..18) @sheet2.rows(17).range.should == (14..18) @sheet2.insert_cell_before(16,3) @@ -153,15 +153,15 @@ @sheet2.rows(16).range.should == (16..16) @sheet2.rows(17).range.should == (17..18) @cellA = @sheet2.cells(16,1) @cellA.range.should == (1..2) - @cellA.value.should == "" + @cellA.value.should be_nil @cellB = @sheet2.cells(16,5) @cellB.range.should == (4..8) - @cellB.value.should == "" + @cellB.value.should be_nil end it 'inserted has correct class' do # based on real error @sheet2.insert_cell_before(1,1) @sheet2.rows(1).cells(1).should be_kind_of(Rspreadsheet::Cell) @@ -230,11 +230,11 @@ @cell.delete @cell.invalid_reference?.should be true expect { @cell.rowi }.to raise_error expect { @cell.address }.to raise_error - @sheet1.cells(2,2).type.should == :string + @sheet1.cells(2,2).type.should == :empty @sheet1.cells(3,2).type.should == :unassigned end it 'switches to invalid_reference cell when its row is deleted' do @cell = @sheet1.cells(6,2) @cell.value = 'data' @@ -268,9 +268,41 @@ @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 + it 'setting format in new file detaches the cell' do + @cell = @sheet1.cells(1,1) + # bold + @cell.format.bold.should be_falsey + @cell.format.bold = true + @cell.format.bold.should be_truthy + @cell.mode.should eq :regular + end + it 'remembers formula when set' do + @cell = @sheet1.cells(1,1) + # bold + @cell.formula.should be_nil + @cell.formula='=1+5' + @cell.formula.should eq '=1+5' + end + it 'unsets cell type when formula set - we can not guess it correctly', :focus do + @cell = @sheet1.cells(1,1) + @cell.value = 'ahoj' + @cell.type.should eq :string + @cell.formula='=1+5' + typ = @cell.xmlnode.nil? ? 'N/A' : @cell.xmlnode.attributes['value-type'] + @cell.type.should_not eq :string + @cell.type.should eq :empty + end + it 'wipes out formula after assiging value' do + @cell = @sheet1.cells(1,1) + @cell.formula='=1+5' + @cell.formula.should_not be_nil + @cell.value = 'baf' + @cell.type.should eq :string + @cell.formula.should be_nil end end