spec/akismet_spec.rb in mikehale-akismet-0.0.4 vs spec/akismet_spec.rb in mikehale-akismet-0.1.0
- old
+ new
@@ -42,11 +42,11 @@
@akismet.verify?.should == true
end
it "should not verify an invalid key" do
map Rack::URLMap.new("http://rest.akismet.com/" => lambda { |env| [200, {'x-akismet-debug-help' => 'sorry!'}, ["invalid"]]})
- lambda {@akismet.verify?}.should raise_error(Akismet::VerifyException)
+ lambda {@akismet.verify?}.should raise_error(Akismet::VerifyError)
response['x-akismet-debug-help'].should == 'sorry!'
end
it "should detect spam" do
@akismet.spam?(params.update(:comment_content => "viagra-test-123")).should == true
@@ -89,7 +89,22 @@
it "should submit ham" do
map Rack::URLMap.new("http://thekey.rest.akismet.com/1.1/submit-ham" => lambda { |env| [200, {}, "true"]})
@akismet.submit_ham(params.update(:comment_content => "this-is-ham"))
request.script_name.should == "/1.1/submit-ham"
+ end
+
+ describe "verify?" do
+ it "should handle a SocketError" do
+ map Rack::URLMap.new("http://rest.akismet.com/" => lambda { |env| raise SocketError })
+ mock.proxy(Net::HTTP).start(anything, numeric)
+ lambda {@akismet.verify?}.should raise_error(Akismet::VerifyError)
+ end
+ end
+
+ describe "call_akismet" do
+ it "should handle a SocketError" do
+ map Rack::URLMap.new("http://thekey.rest.akismet.com/1.1/comment-check" => lambda { |env| raise SocketError })
+ lambda { @akismet.ham?(params.update(:comment_content => "not spam"))}.should raise_error(Akismet::CheckError)
+ end
end
end