Sha256: ca0523e6ffe5531f6148097a740b15dc4d6dac2e29ea3f6364cd3b14271216f7

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

require_relative 'spec_helper'

describe SingleCellArrayFormulaCell do
  
  before do
    @cell = SingleCellArrayFormulaCell.new(
      mock(:worksheet,:class_name => 'Sheet1', :to_s => '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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubyfromexcel-0.0.10 spec/single_cell_array_formula_cell_spec.rb
rubyfromexcel-0.0.9 spec/single_cell_array_formula_cell_spec.rb
rubyfromexcel-0.0.7 spec/single_cell_array_formula_cell_spec.rb
rubyfromexcel-0.0.6 spec/single_cell_array_formula_cell_spec.rb
rubyfromexcel-0.0.5 spec/single_cell_array_formula_cell_spec.rb