Sha256: 37df7e8e78c94f0fd49c719144048320fe6bd71795b7f05836df3bc0a3d2e01c
Contents?: true
Size: 1.56 KB
Versions: 9
Compression:
Stored size: 1.56 KB
Contents
require_relative 'spec_helper' describe SingleCellArrayFormulaCell do before do @cell = SingleCellArrayFormulaCell.new( mock(:worksheet,:class_name => 'Sheet1', :to_s => 'sheet1',:name => 'sheet1'), Nokogiri::XML("<c r=\"C3\"><f t=\"array\" ref=\"C3\">SUM(F$437:F$449/$M$150:$M$162*($B454=$F$149:$N$149)*($F$150:$N$162))</f><v>3</v></c>").root ) end it "should use the FormulaPeg to create ruby code for a formula and turn that into a method" do @cell.to_ruby.should == "def c3; @c3 ||= sum(m(a('f437','f449'),a('m150','m162'),(m(b454,a('f149','n149')) { |r1,r2| r1==r2 }),(a('f150','n162'))) { |r1,r2,r3,r4| r1/r2*r3*r4 }); end\n" end it "should create a test for the ruby code" do @cell.to_test.should == %Q{it 'cell c3 should equal 3.0' do\n sheet1.c3.should be_within(0.30000000000000004).of(3.0)\nend\n\n} end it "in can list the cells upon which it depends" do @cell.work_out_dependencies dependencies = @cell.dependencies dependencies.include?('sheet1.g151').should be_true end end describe SingleCellArrayFormulaCell, " where an array is returned by the formula" do before do @cell = SingleCellArrayFormulaCell.new( mock(:worksheet,:class_name => 'Sheet1', :to_s => 'sheet1',:name => 'sheet1'), Nokogiri::XML("<c r=\"C3\"><f t=\"array\" ref=\"C3\">5*$F$150:$N$162</f><v>3</v></c>").root ) end it "should use the top left response of the array formula" do @cell.to_ruby.should == "def c3; @c3 ||= (m(5.0,a('f150','n162')) { |r1,r2| r1*r2 }).array_formula_offset(0,0); end\n" end end
Version data entries
9 entries across 9 versions & 1 rubygems