spec/cell_spec.rb in rspreadsheet-0.2.15 vs spec/cell_spec.rb in rspreadsheet-0.3

- old
+ new

@@ -267,10 +267,25 @@ @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 'stores time correctly' do + @cell = @sheet1.cell(1,1) + @cell.value= Time.parse('2:42 pm') + @cell.value.hour.should eq 14 + @cell.value.min.should eq 42 + @cell.value.sec.should eq 0 + end + it 'can read various types of times', :pending => 'see is' do + raise @sheet2.cell('D23').xml.inspect + expect {@cell = @sheet2.cell('D22'); @cell.value }.not_to raise_error + expect {@cell = @sheet2.cell('D23'); @cell.value }.not_to raise_error + + @cell.value.should == Time.new(2005,5,5,3,33,00) + end + it 'can be addressed by even more ways and all are identical' do @cell = @sheet1.cell(2,2) @sheet1.cell('B2').value = 'zaseste' @sheet1.cell('B2').value.should == 'zaseste' @cell.value.should == 'zaseste' @@ -290,14 +305,18 @@ # bold @cell.format.bold.should be_falsey @cell.format.bold = true @cell.format.bold.should be_truthy @cell.mode.should eq :regular + + @cell = @sheet1.cell(2,2) + @cell.format.background_color = '#ffeeaa' + @cell.format.background_color.should == '#ffeeaa' + @cell.mode.should eq :regular end it 'remembers formula when set' do @cell = @sheet1.cell(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 @@ -324,7 +343,69 @@ @usdcell.format.currency.should == 'USD' @czkcell = @sheet2.cell('B23') @czkcell.value.should == 344.to_d @czkcell.format.currency.should == 'CZK' + end + it 'is possible to manipulate borders of cells' do + @cell = @sheet1.cell(1,1) + + [@cell.format.top,@cell.format.left,@cell.format.right,@cell.format.bottom].each do |border| + border.style = 'dashed' + border.style.should == 'dashed' + border.width = 0.5 + border.width.should == 0.5 + border.color = '#005500' + border.color.should == '#005500' + end + end + it 'returns correct border parameters for the cell' do + @sheet2.cell('C8').format.top.style.should == 'solid' + @sheet2.cell('E8').format.left.color.should == '#ff3333' + @sheet2.cell('E8').format.left.style.should == 'solid' + @sheet2.cell('F8').format.top.color.should == '#009900' + @sheet2.cell('F8').format.top.style.should == 'dotted' + end + it 'modifies borders correctly' do + ## initially solid everywhere + @sheet2.cell('C8').format.top.style.should == 'solid' + @sheet2.cell('C8').format.bottom.style.should == 'solid' + @sheet2.cell('C8').format.left.style.should == 'solid' + @sheet2.cell('C8').format.right.style.should == 'solid' + ## change top and right to dotted and observe + @sheet2.cell('C8').format.top.style = 'dotted' + @sheet2.cell('C8').format.right.style = 'dotted' + @sheet2.cell('C8').format.bottom.style.should == 'solid' + @sheet2.cell('C8').format.left.style.should == 'solid' + @sheet2.cell('C8').format.top.style.should == 'dotted' + @sheet2.cell('C8').format.right.style.should == 'dotted' + end + it 'deletes borders correctly', :pending=> 'consider how to deal with deleted borders' do + @cell = @sheet1.cell(1,1) + + [@cell.format.top,@cell.format.left,@cell.format.right,@cell.format.bottom].each do |border| + border.style = 'dashed' + border.should_not be_nil + border.delete + border.should be_nil + end + + # delete right border in existing file and observe + @sheet2.cell('C8').format.right.delete + @sheet2.cell('C8').format.right.should == nil + end + + it 'can delete borders in many ways', :pending => 'consider what syntax to support' do + @cell=@sheet2.cell('C8') + @cell.border_right.should_not be_nil + @cell.border_right.delete + @cell.border_right.should be_nil + + @cell.border_left.should_not be_nil + @cell.border_left = nil + @cell.border_left.should be_nil + + @cell.format.top.should_not_be_nil + @cell.format.top.style = 'none' + @cell.border_top.should_not be_nil ## ????? end end