spec/mongo_spec.rb in barnyard_harvester-0.0.5 vs spec/mongo_spec.rb in barnyard_harvester-0.0.7

- old
+ new

@@ -27,22 +27,28 @@ :user => "honeybadger", :password => "0joQuk35vJM05Hj", :collection => "test_collection" } -$mongo_settings = MONGODB_REPLICA_SET_SETTINGS +$mongo_settings = MONGODB_SETTINGS describe BarnyardHarvester do def load_and_process_file(file, backend) data = YAML::load_file file my_logger = Logger.new(STDOUT) my_logger.level = Logger::INFO - h = BarnyardHarvester::Sync.new(:backend => backend, :debug => false, :mongodb_settings => $mongo_settings, :crop_number => CROP_NUMBER, :redis_settings => REDIS_SETTINGS, :logger => my_logger) + h = BarnyardHarvester::Sync.new(:backend => backend, + :queueing => :resque, + :debug => false, + :mongodb_settings => $mongo_settings, + :crop_number => CROP_NUMBER, + :redis_settings => REDIS_SETTINGS, + :logger => my_logger) h.run do data.each do |primary_key, value| h.process primary_key, value end @@ -117,10 +123,12 @@ h.delete_count.should eq(0) h.change_count.should eq(0) h.source_count.should eq(data.count) h.cache_count.should eq(data.count) + h.my_barn.log_run("#{file}-#{Random.rand(100)}", @crop_number, Time.now, Time.now, h.source_count, h.change_count, h.add_count, h.delete_count) + end it "test change one record" do file = "spec/fixtures/data-change.yml" @@ -133,27 +141,30 @@ h.delete_count.should eq(0) h.change_count.should eq(1) h.source_count.should eq(data.count) h.cache_count.should eq(data.count) + h.my_barn.log_run("#{file}-#{Random.rand(100)}", @crop_number, Time.now, Time.now, h.source_count, h.change_count, h.add_count, h.delete_count) + end it "test delete one record" do file = "spec/fixtures/data-delete.yml" data = YAML::load_file file h = load_and_process_file(file, :mongodb) - h.add_count.should eq(0) h.delete_count.should eq(1) h.change_count.should eq(0) h.source_count.should eq(data.count) h.cache_count.should eq(data.count + 1) + h.my_barn.log_run("#{file}-#{Random.rand(100)}", @crop_number, Time.now, Time.now, h.source_count, h.change_count, h.add_count, h.delete_count) + end it "test delete all records and add one" do init_file = "spec/fixtures/data-init.yml" @@ -167,9 +178,11 @@ h.add_count.should eq(1) h.delete_count.should eq(5) h.change_count.should eq(0) h.source_count.should eq(1) h.cache_count.should eq(init_data.count + 1) + + h.my_barn.log_run("#{file}-#{Random.rand(100)}", @crop_number, Time.now, Time.now, h.source_count, h.change_count, h.add_count, h.delete_count) end after(:each) do \ No newline at end of file