spec/nest_spec.rb in rubyvis-0.3.3 vs spec/nest_spec.rb in rubyvis-0.3.4

- old
+ new

@@ -4,17 +4,23 @@ @data=[ { :year=>2010, :city=>'London',:value=>1}, { :year=>2010, :city=>'France',:value=>2}, { :year=>2011, :city=>'London',:value=>5}, { :year=>2011, :city=>'France',:value=>6}, - ] end it "should generate correct map" do - nest = pv.nest(@data).key(lambda {|d| d[:year]}).key(lambda {|d| d[:city]}).map(); + nest = pv.nest(@data).key(lambda {|d| d[:year]}).key(lambda {|d| d[:city]}).map() + expected={2010=>{"London"=>[{:year=>2010, :city=>"London", :value=>1}], "France"=>[{:year=>2010, :city=>"France", :value=>2}]}, 2011=>{"London"=>[{:year=>2011, :city=>"London", :value=>5}], "France"=>[{:year=>2011, :city=>"France", :value=>6}]}} nest.should==expected + end + it "should generate correct rollup" do + nest = pv.nest(@data).key(lambda {|d| d[:year]}).key(lambda {|d| d[:city]}).rollup(lambda {|d| d.map{|dd| dd[:value]}}) + expected={2010=>{"London"=>[1], "France"=>[2]}, 2011=>{"London"=>[5], "France"=>[6]}} + nest.should==expected + end it "should generate correct entries" do nest = pv.nest(@data).key(lambda {|d| d[:year]}).key(lambda {|d| d[:city]}).entries(); expected=[ Rubyvis::NestedArray.new(:key=>2010, :values=> \ No newline at end of file