test/test_analysis.rb in statsample-1.5.0 vs test/test_analysis.rb in statsample-2.0.0

- old
+ new

@@ -37,11 +37,11 @@ Statsample::Analysis.add_to_reportbuilder(rb, :first, :second) end should 'to_text returns the same as a normal ReportBuilder object' do rb = ReportBuilder.new(name: :test) section = ReportBuilder::Section.new(name: 'first') - a = [1, 2, 3].to_numeric + a = Daru::Vector.new([1, 2, 3]) section.add('first') section.add(a) rb.add(section) exp = rb.to_text an = ss_analysis(:first) { @@ -96,51 +96,51 @@ obj = stub('summarizable', summary: 'summary') assert_equal(obj.summary, an.summary(obj)) end should 'attach() allows to call objects on objects which respond to fields' do an = Statsample::Analysis::Suite.new(:summary) - ds = { 'x' => stub(mean: 10), 'y' => stub(mean: 12) } - ds.expects(:fields).returns(%w(x y)).at_least_once + ds = { :x => stub(mean: 10), :y => stub(mean: 12) } + ds.expects(:vectors).returns([:x, :y]).at_least_once an.attach(ds) assert_equal(10, an.x.mean) assert_equal(12, an.y.mean) assert_raise(RuntimeError) { an.z } end should 'attached objects should be called LIFO' do an = Statsample::Analysis::Suite.new(:summary) - ds1 = { 'x' => stub(mean: 100), 'y' => stub(mean: 120), 'z' => stub(mean: 13) } - ds1.expects(:fields).returns(%w(x y z)).at_least_once - ds2 = { 'x' => stub(mean: 10), 'y' => stub(mean: 12) } - ds2.expects(:fields).returns(%w(x y)).at_least_once + ds1 = { :x => stub(mean: 100), :y => stub(mean: 120), :z => stub(mean: 13) } + ds1.expects(:vectors).returns([:x, :y, :z]).at_least_once + ds2 = { :x => stub(mean: 10), :y => stub(mean: 12) } + ds2.expects(:vectors).returns([:x, :y]).at_least_once an.attach(ds1) an.attach(ds2) assert_equal(10, an.x.mean) assert_equal(12, an.y.mean) assert_equal(13, an.z.mean) end should 'detach() without arguments drop latest object' do an = Statsample::Analysis::Suite.new(:summary) - ds1 = { 'x' => stub(mean: 100), 'y' => stub(mean: 120), 'z' => stub(mean: 13) } - ds1.expects(:fields).returns(%w(x y z)).at_least_once - ds2 = { 'x' => stub(mean: 10), 'y' => stub(mean: 12) } - ds2.expects(:fields).returns(%w(x y)).at_least_once + ds1 = { :x => stub(mean: 100), :y => stub(mean: 120), :z => stub(mean: 13) } + ds1.expects(:vectors).returns([:x, :y, :z]).at_least_once + ds2 = { :x => stub(mean: 10), :y => stub(mean: 12) } + ds2.expects(:vectors).returns([:x, :y]).at_least_once an.attach(ds1) an.attach(ds2) assert_equal(10, an.x.mean) an.detach assert_equal(100, an.x.mean) end should 'detach() with argument drop select object' do an = Statsample::Analysis::Suite.new(:summary) - ds1 = { 'x' => 1 } - ds1.expects(:fields).returns(%w(x)).at_least_once - ds2 = { 'x' => 2, 'y' => 3 } - ds2.expects(:fields).returns(%w(x y)).at_least_once - ds3 = { 'y' => 4 } - ds3.expects(:fields).returns(%w(y)).at_least_once + ds1 = { :x => 1 } + ds1.expects(:vectors).returns([:x]).at_least_once + ds2 = { :x => 2, :y => 3 } + ds2.expects(:vectors).returns([:x, :y]).at_least_once + ds3 = { :y => 4 } + ds3.expects(:vectors).returns([:y]).at_least_once an.attach(ds3) an.attach(ds2) an.attach(ds1) assert_equal(1, an.x)