0
+require File.dirname(__FILE__) + "/../../../test_helper"
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 => "")
0
+ @comment = Comment.new
0
+ @defensio = stub("defensio client")
0
+ @site.stub!(:permalink_for).and_return("")
0
+ specify "should be #valid?" do
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
+context "A Mephisto::SpamDetectionEngines::DefensioEngine" do
0
+ @site = Site.new(:spam_detection_engine => "Mephisto::SpamDetectionEngines::DefensioEngine")
0
+ @site.spam_engine_options = {}
0
+ @engine = @site.spam_engine
0
+ specify "should not be #valid? when the defensio key is missing from the options" do
0
+ @site.spam_engine_options.delete(:defensio_key)
0
+ assert !@site.spam_engine.valid?
0
+ specify "should not be #valid? when the defensio url is missing from the options" do
0
+ @site.spam_engine_options.delete(:defensio_url)
0
+ assert !@site.spam_engine.valid?
0
+context "A Mephisto::SpamDetectionEngines::DefensioEngine instantiated from a Site with a missing :defensio_key" do
0
+ @site = Site.new(:spam_detection_engine => "Mephisto::SpamDetectionEngines::DefensioEngine")
0
+ @site.spam_engine_options = {:defensio_url => "http://my.blog.com/"}
0
+ @engine = @site.spam_engine
0
+ specify "should raise a NotConfigured exception when calling #ham?" do
0
+ assert_raise Mephisto::SpamDetectionEngine::NotConfigured do
0
+ @site.spam_engine.ham?(nil, nil)
0
+ specify "should raise a NotConfigured exception when calling #mark_as_spam" do
0
+ assert_raise Mephisto::SpamDetectionEngine::NotConfigured do
0
+ @site.spam_engine.mark_as_spam(nil, nil)
0
+ specify "should raise a NotConfigured exception when calling #mark_as_ham" do
0
+ assert_raise Mephisto::SpamDetectionEngine::NotConfigured do
0
+ @site.spam_engine.mark_as_ham(nil, nil)
Comments
No one has commented yet.