mikehale-akismet 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +2 -2
- data/lib/akismet.rb +7 -2
- data/spec/akismet_spec.rb +16 -1
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/akismet.rb
CHANGED
@@ -23,10 +23,12 @@ class Akismet
|
|
23
23
|
|
24
24
|
case response.body
|
25
25
|
when "invalid"
|
26
|
-
raise Akismet::
|
26
|
+
raise Akismet::VerifyError, response.to_hash["x-akismet-debug-help"], caller
|
27
27
|
when "valid"
|
28
28
|
true
|
29
29
|
end
|
30
|
+
rescue SocketError => e
|
31
|
+
raise Akismet::VerifyError, e, caller
|
30
32
|
end
|
31
33
|
|
32
34
|
def submit_spam(args)
|
@@ -58,6 +60,8 @@ class Akismet
|
|
58
60
|
when "false"
|
59
61
|
false
|
60
62
|
end
|
63
|
+
rescue SocketError => e
|
64
|
+
raise Akismet::CheckError, e, caller
|
61
65
|
end
|
62
66
|
|
63
67
|
def post_data(hash)
|
@@ -68,5 +72,6 @@ class Akismet
|
|
68
72
|
end.join('&')
|
69
73
|
end
|
70
74
|
|
71
|
-
class
|
75
|
+
class VerifyError < StandardError; end
|
76
|
+
class CheckError < StandardError; end
|
72
77
|
end
|
data/spec/akismet_spec.rb
CHANGED
@@ -44,7 +44,7 @@ describe "Akismet" do
|
|
44
44
|
|
45
45
|
it "should not verify an invalid key" do
|
46
46
|
map Rack::URLMap.new("http://rest.akismet.com/" => lambda { |env| [200, {'x-akismet-debug-help' => 'sorry!'}, ["invalid"]]})
|
47
|
-
lambda {@akismet.verify?}.should raise_error(Akismet::
|
47
|
+
lambda {@akismet.verify?}.should raise_error(Akismet::VerifyError)
|
48
48
|
response['x-akismet-debug-help'].should == 'sorry!'
|
49
49
|
end
|
50
50
|
|
@@ -92,4 +92,19 @@ describe "Akismet" do
|
|
92
92
|
@akismet.submit_ham(params.update(:comment_content => "this-is-ham"))
|
93
93
|
request.script_name.should == "/1.1/submit-ham"
|
94
94
|
end
|
95
|
+
|
96
|
+
describe "verify?" do
|
97
|
+
it "should handle a SocketError" do
|
98
|
+
map Rack::URLMap.new("http://rest.akismet.com/" => lambda { |env| raise SocketError })
|
99
|
+
mock.proxy(Net::HTTP).start(anything, numeric)
|
100
|
+
lambda {@akismet.verify?}.should raise_error(Akismet::VerifyError)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "call_akismet" do
|
105
|
+
it "should handle a SocketError" do
|
106
|
+
map Rack::URLMap.new("http://thekey.rest.akismet.com/1.1/comment-check" => lambda { |env| raise SocketError })
|
107
|
+
lambda { @akismet.ham?(params.update(:comment_content => "not spam"))}.should raise_error(Akismet::CheckError)
|
108
|
+
end
|
109
|
+
end
|
95
110
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mikehale-akismet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Hale
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05
|
12
|
+
date: 2009-06-05 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|