0
@@ -6,19 +6,55 @@ context "A properly configured Mephisto::SpamDetectionEngines::DefensioEngine" d
0
@engine = @site.spam_engine
0
- @request = stub("request", :host_with_port => "")
0
- @comment = Comment.new
0
+ @request = stub("request", :host_with_port => "my.host.com")
0
+ @article = Article.new(:published_at => 10.hours.ago)
0
+ @comment = Comment.new(:article => @article)
0
@defensio = stub("defensio client")
0
- @site.stub!(:permalink_for).and_return("
")
0
+ @site.stub!(:permalink_for).and_return("
/2008/2/17/this-is-my-permalink")
0
specify "should be #valid?" do
0
+context "A properly configured Mephisto::SpamDetectionEngines::DefensioEngine" do
0
+ @site = Site.new(:spam_detection_engine => "Mephisto::SpamDetectionEngines::DefensioEngine")
0
+ @site.spam_engine_options = {:defensio_url => "http://my.blog.com/", :defensio_key => "akey"}
0
+ @engine = @site.spam_engine
0
+ @request = stub("request", :host_with_port => "my.host.com")
0
+ @article = Article.new(:published_at => 10.hours.ago)
0
+ @comment = Comment.new(:article => @article)
0
+ @defensio = stub("defensio client")
0
+ @site.stub!(:permalink_for).and_return("/2008/2/17/this-is-my-permalink")
0
+ Defensio::Client.stub!(:new).and_return(@defensio)
0
+ specify "should call #validate_key on #valid_key?" do
0
+ @defensio.should_receive(:validate_key).and_return(stub("defensio response", :success? => true))
0
+ assert @engine.valid_key?
0
+ specify "should call #report_false_positives on #mark_as_ham" do
0
+ @comment.should_receive(:spam_engine_data).and_return(:signature => "the-signature")
0
+ @defensio.should_receive(:report_false_positives).with(:signatures => ["the-signature"]).and_return(stub("response"))
0
+ @engine.mark_as_ham(@request, @comment)
0
+ specify "should call #report_false_negatives on #mark_as_spam" do
0
+ @comment.should_receive(:spam_engine_data).and_return(:signature => "a-signature")
0
+ @defensio.should_receive(:report_false_negatives).with(:signatures => ["a-signature"]).and_return(stub("response"))
0
+ @engine.mark_as_spam(@request, @comment)
0
+ specify "should call #audit_comment on #ham?" do
0
+ @defensio.should_receive(:audit_comment).with(any_args).and_return(stub("defensio response", :signature => "a signature", :spaminess => "0.43", :spam => false))
0
- specify "should instantiate a Defensio when calling #ham?" do
0
- Defensio::Client.should_receive(:new).and_return(@defensio)
0
- @engine.ham?(@request, @comment)
0
+ @comment.should_receive(:update_attribute).with(:spam_engine_data, {:spaminess => 0.43, :signature => "a signature"}).and_return(true)
0
+ assert @engine.ham?(@request, @comment)
Comments
No one has commented yet.