spec/utils_spec.rb in ricardochimal-taps-0.2.16 vs spec/utils_spec.rb in ricardochimal-taps-0.2.18

- old
+ new

@@ -14,11 +14,13 @@ it "generates a checksum using crc32" do Taps::Utils.checksum("hello world").should == Zlib.crc32("hello world") end it "formats a data hash into one hash that contains an array of headers and an array of array of data" do - Taps::Utils.format_data([ { :x => 1, :y => 1 }, { :x => 2, :y => 2 } ], []).should == { :header => [ :x, :y ], :data => [ [1, 1], [2, 2] ] } + first_row = { :x => 1, :y => 1 } + first_row.stubs(:keys).returns([:x, :y]) + Taps::Utils.format_data([ first_row, { :x => 2, :y => 2 } ], []).should == { :header => [ :x, :y ], :data => [ [1, 1], [2, 2] ] } end it "scales chunksize down slowly when the time delta of the block is just over a second" do Time.stubs(:now).returns(10.0).returns(11.5) Taps::Utils.calculate_chunksize(1000) { }.should == 900 @@ -47,11 +49,10 @@ end it "returns a list of columns that are text fields if the database is mysql" do @db = mock("db") @db.class.stubs(:to_s).returns("Sequel::MySQL::Database") - @db.stubs(:schema).returns(mock("schema")) - @db.schema.stubs(:[]).with(:mytable).returns([ + @db.stubs(:schema).with(:mytable).returns([ [:id, { :db_type => "int" }], [:mytext, { :db_type => "text" }] ]) Taps::Utils.incorrect_blobs(@db, :mytable).should == [:mytext] end