spec/config_spec.rb in chatterbot-0.7.0 vs spec/config_spec.rb in chatterbot-0.7.1
- old
+ new
@@ -123,17 +123,50 @@
@bot.config[:debug_mode] = true
@bot.debug_mode?.should == true
end
end
+ describe "since_id_reply=" do
+ it "works" do
+
+ @bot.since_id_reply = 123
+ @bot.config[:tmp_since_id_reply].should == 123
+ end
+ end
+
+ describe "update_since_id_reply" do
+ it "works with tweets" do
+ @bot.config[:tmp_since_id_reply] = 100
+
+ data = fake_tweet(1000, 1000, true)
+ @bot.update_since_id_reply(data)
+ @bot.config[:tmp_since_id_reply].should == 1000
+ end
+
+ it "doesn't work with searches" do
+ data = fake_search(1000, 1).search
+
+ @bot.config[:tmp_since_id_reply] = 100
+ @bot.update_since_id_reply(data)
+ @bot.config[:tmp_since_id_reply].should == 100
+ end
+
+ it "never rolls back" do
+ @bot.config[:tmp_since_id_reply] = 100
+ data = fake_tweet(50, 50, true)
+ @bot.update_since_id(data)
+ @bot.config[:tmp_since_id_reply].should == 100
+ end
+ end
+
describe "since_id=" do
it "works" do
@bot.since_id = 123
@bot.config[:tmp_since_id].should == 123
end
end
-
+
describe "update_since_id" do
it "works with searches" do
data = fake_search(1000, 1).search
@bot.config[:tmp_since_id] = 100
@@ -177,31 +210,36 @@
@bot.should_not_receive(:has_db?)
@bot.update_config
end
it "doesn't update keys from the global config" do
- @bot.stub!(:global_config).and_return({:foo => :bar, :a => :b})
- @bot.stub!(:bot_config).and_return({:foo => :bar, :custom => :value})
+ @bot.stub(:global_config).and_return({:foo => :bar, :a => :b})
+ @bot.stub(:bot_config).and_return({:foo => :bar, :custom => :value})
@bot.config = nil
@bot.config_to_save.should == { :custom => :value }
end
it "does update keys from the global config if they've been customized" do
- @bot.stub!(:global_config).and_return({:foo => :bar, :a => :b})
- @bot.stub!(:bot_config).and_return({:foo => :baz, :custom => :value})
+ @bot.stub(:global_config).and_return({:foo => :bar, :a => :b})
+ @bot.stub(:bot_config).and_return({:foo => :baz, :custom => :value})
@bot.config = nil
@bot.config_to_save.should == { :foo => :baz, :custom => :value }
end
it "updates since_id" do
@bot.config[:tmp_since_id] = 100
@bot.config_to_save[:since_id].should == 100
end
+
+ it "updates since_id_reply" do
+ @bot.config[:tmp_since_id_reply] = 100
+ @bot.config_to_save[:since_id_reply].should == 100
+ end
end
describe "global config files" do
it "has an array of global_config_files" do
@@ -281,11 +319,11 @@
before(:each) do
tmp = {:x => 123, :foo => :bar}
@src = Tempfile.new("config")
- @bot.stub!(:config_file).and_return(@src.path)
- @bot.stub!(:config_to_save).and_return(tmp)
+ @bot.stub(:config_file).and_return(@src.path)
+ @bot.stub(:config_to_save).and_return(tmp)
end
it "should work" do
@bot.store_local_config
@bot.slurp_file(@src.path).should == { :x => 123, :foo => :bar }