spec/cell_spec.rb in rspreadsheet-0.4.2 vs spec/cell_spec.rb in rspreadsheet-0.4.3
- old
+ new
@@ -1,7 +1,7 @@
require 'spec_helper'
-
+
describe Rspreadsheet::Cell do
before do
book1 = Rspreadsheet.new
@sheet1 = book1.create_worksheet
book2 = Rspreadsheet.new($test_filename)
@@ -36,10 +36,12 @@
@cell.value.should == 'zactvrte s arrayem'
@sheet1.row(2)[2] = 'zapate'
@cell.value.should == 'zapate'
@sheet1.rows[1][2] = 'zaseste' ## tohle je divoka moznost
@cell.value.should == 'zaseste'
+
+ @sheet1.A11 = 'dalsi test'
end
it 'can include links' do
@sheet2.A12.should == '[http://example.org/]'
@sheet2.cell(12,2).valuexmlfindall('.//text:a').size.should eq 0
@sheet2.cell(12,1).valuexmlfindall('.//text:a').size.should eq 1
@@ -92,21 +94,21 @@
@sheet2.cell(13,3).should_not == 'cokoli'
@sheet2.cell(13,4).should_not == 'cokoli'
end
it 'returns correct type for the cell' do
@sheet2.cell(1,2).type.should eq :string
- @sheet2.cell(2,2).type.should eq :date
+ @sheet2.cell(2,2).type.should eq :datetime
@sheet2.cell(3,1).type.should eq :float
@sheet2.cell(3,2).type.should eq :percentage
@sheet2.cell(4,2).type.should eq :string
@sheet2.cell('B22').type.should eq :currency
@sheet2.cell('B23').type.should eq :currency
@sheet2.cell(200,200).type.should eq :unassigned
end
it 'returns value of correct type' do
@sheet2[1,2].should be_kind_of(String)
- @sheet2[2,2].should be_kind_of(Date)
+ @sheet2[2,2].should be_kind_of(DateTime) # maybe date
@sheet2[3,1].should be_kind_of(Float)
@sheet2[3,2].should be_kind_of(Float)
@sheet2.cell(3,2).type.should eq :percentage
@sheet2.cell(3,2).guess_cell_type.should eq :percentage
@sheet2.cell(3,2).guess_cell_type(1).should eq :percentage
@@ -274,18 +276,42 @@
@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
+ it 'parse_time_value converts correcty different time values' do
+ dyear = 1899; dmonth = 12; dday = 30
+ Rspreadsheet::Cell.parse_time_value('PT923451H33M00S').should == Time.new(2005,5,5,3,33,00,0)
+ Rspreadsheet::Cell.parse_time_value('PT1H33M00S').should == Time.new(dyear,dmonth,dday,1,33,00,0)
+ end
+ it 'handles time of day correctly on assignement' do
+ @sheet1.A11 = Rspreadsheet::Tools.new_time_value(2,13,27)
+ @sheet1.A12 = @sheet1.A11
+ @sheet1.A12.should == @sheet1.A11
+ @sheet1.cell('A12').type.should == :time
+ end
+ it 'can read various types of times' do
expect {@cell = @sheet2.cell('D22'); @cell.value }.not_to raise_error
+ @cell.value.hour.should == 2
+ @cell.value.min.should == 22
expect {@cell = @sheet2.cell('D23'); @cell.value }.not_to raise_error
-
- @cell.value.should == Time.new(2005,5,5,3,33,00)
+ @cell.value.should == Time.new(2005,5,5,3,33,0,0)
end
-
+ it 'handles dates and datetimes correctly on assignement' do
+ @sheet1.A11 = DateTime.new(2011,1,1,2,13,27,0)
+ @sheet1.A12 = @sheet1.A11
+ @sheet1.A12.should == @sheet1.A11
+ @sheet1.cell('A12').type.should == :datetime
+ @sheet1.A11 = Date.new(2012,2,2)
+ @sheet1.A12 = @sheet1.A11
+ @sheet1.A12.should == @sheet1.A11
+ @sheet1.cell('A12').type.should == :datetime
+ end
+ it 'can read various types of dates' do
+ expect {@cell = @sheet2.cell('F22'); @cell.value }.not_to raise_error
+ @cell.value.should == DateTime.new(2006,6,6,3,44,21,0)
+ 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'
@@ -405,7 +431,11 @@
@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
+
+ it 'automatically creates new style, if a style is automatic, some of its attributes changes and there are several cells pointing to it', :penting=>'' do
+
end
end