rakismet 1.5.1 → 1.5.2

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzYyMjAxMmVhYThlM2IyNjg3YzhmN2IyNjI3NzFiNDQ4YzkzNzE0Mg==
4
+ NzdlODJkNzk5YjAxYTgyNjkxZmMzYjc1NjMxZGQ3ZGY4OTFlZTMwMQ==
5
5
  data.tar.gz: !binary |-
6
- MjI1YzE2YWQwMzUxNTk3NzY3Y2IzYjFhYzE5YzE5YTBjMjdmMzIyYg==
6
+ Y2FhOTZjNzg5NDEyMWFmOGM2MTYwYzQ0NWJmM2ViNWM5OGVlZTA0YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzI0MWU0YzBhZjYxN2FhNGIyZGI1M2QzNjFmMzVlMmFmNWVmYTNmZDVhOThl
10
- NTc2OTA2Mjg1ZGE5YmE3ZjhiZDQwYzIwNzRkOGRkNzQ1MmYzMzA4NDE2ZDE2
11
- NmIyNTMyZmU5ZjI4MWRkYjZmYThhZDFlZDM0NWU5ZWVmMzFhYjM=
9
+ MzY2YWU3N2E2NmNjNzU1MTBkNmYxNDAwNDdiM2ZhZmE4ODU2Y2ZkZTliNmFl
10
+ MGNjOWIwYmRhYWRhZGNmMDk5ZDdmYjQ0OTE3YjI3YWRjZTQzY2VhYzU2NTFl
11
+ N2EwNTFmNDRlZTY5ODE0ZDY2MTQ3M2JlNjA5MDQ0MGQyNTM1MDE=
12
12
  data.tar.gz: !binary |-
13
- ZWJjNTAwZDMxNzU2ZWU3OTI2NGU2ZmQ5NjBhMzRmZWU2M2JiOGIyMWYwOTNm
14
- NjViNjM0MjIyZGY5ZjBlM2M0MDZmNjczODIxMjY4YTJmY2I5OWMwOTMzOWFh
15
- YWRjZTU2YjYxNTQxOWYwZjMzNWZhNjdhOGE0NGUwMThiZjdlNTM=
13
+ N2U0MmUzNTM0NTZmNjE3YjhjMDFjYmZmNmVhMmY2NjY4MjJiMmZhY2RlYmFi
14
+ ZjNmYzJlYzc5MzE2MDg1ZTgwMWE4NDg2NWNlOTBhY2Y1OTYzNjEwMGFhZmI5
15
+ NmE5ZDViZGMzZWFlMTBhZjhkY2NlYWVmMWY5YWQ0OWExM2Y2ZjE=
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ = 1.5.2
2
+ * Don't try to send Rails.version unless it's actually defined [Brett Bender]
1
3
  = 1.5.1
2
4
  * Send user_role attribute to Akismet without comment prefix [Hugo Bauer]
3
5
  = 1.5.0
@@ -42,7 +42,11 @@ module Rakismet
42
42
  def headers
43
43
  @headers ||= begin
44
44
  user_agent = "Rakismet/#{Rakismet::VERSION}"
45
- user_agent = "Rails/#{Rails.version} | " + user_agent if defined?(Rails)
45
+
46
+ if defined?(Rails) && Rails.respond_to?(:version)
47
+ user_agent = "Rails/#{Rails.version} | " + user_agent
48
+ end
49
+
46
50
  { 'User-Agent' => user_agent, 'Content-Type' => 'application/x-www-form-urlencoded' }
47
51
  end
48
52
  end
@@ -1,3 +1,3 @@
1
1
  module Rakismet
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.2"
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "http://github.com/joshfrench/rakismet"
11
11
  s.summary = "Akismet and TypePad AntiSpam integration for Rails."
12
12
  s.description = "Rakismet is the easiest way to integrate Akismet or TypePad's AntiSpam into your Rails app."
13
- s.date = "2013-09-22"
13
+ s.date = "2016-02-26"
14
14
 
15
15
  s.rubyforge_project = "rakismet"
16
16
  s.add_development_dependency "rake"
@@ -11,7 +11,7 @@ describe BlockAkismetModel do
11
11
 
12
12
  before do
13
13
  @block = BlockAkismetModel.new
14
- comment_attrs.each_pair { |k,v| @block.stub!(k).and_return(v) }
14
+ comment_attrs.each_pair { |k,v| @block.stub(k).and_return(v) }
15
15
  end
16
16
 
17
17
  it "should accept a block" do
@@ -4,7 +4,7 @@ describe AkismetModel do
4
4
 
5
5
  before do
6
6
  @model = AkismetModel.new
7
- comment_attrs.each_pair { |k,v| @model.stub!(k).and_return(v) }
7
+ comment_attrs.each_pair { |k,v| @model.stub(k).and_return(v) }
8
8
  end
9
9
 
10
10
  it "should have default mappings" do
@@ -31,7 +31,7 @@ describe AkismetModel do
31
31
  [:user_ip, :user_agent, :referrer].each do |field|
32
32
  @model.should_not respond_to(:field)
33
33
  end
34
- Rakismet.stub!(:request).and_return(request)
34
+ Rakismet.stub(:request).and_return(request)
35
35
  Rakismet.should_receive(:akismet_call).
36
36
  with('comment-check', akismet_attrs.merge(:user_ip => '127.0.0.1',
37
37
  :user_agent => 'RSpec',
@@ -40,7 +40,7 @@ describe AkismetModel do
40
40
  end
41
41
 
42
42
  it "should send http_headers from Rakismet.request if present" do
43
- Rakismet.stub!(:request).and_return(request_with_headers)
43
+ Rakismet.stub(:request).and_return(request_with_headers)
44
44
  Rakismet.should_receive(:akismet_call).
45
45
  with('comment-check', akismet_attrs.merge(:user_ip => '127.0.0.1',
46
46
  :user_agent => 'RSpec',
@@ -57,24 +57,25 @@ describe AkismetModel do
57
57
  end
58
58
 
59
59
  it "should be true if comment is spam" do
60
- Rakismet.stub!(:akismet_call).and_return('true')
60
+ Rakismet.stub(:akismet_call).and_return('true')
61
61
  @model.should be_spam
62
62
  end
63
63
 
64
64
  it "should be false if comment is not spam" do
65
- Rakismet.stub!(:akismet_call).and_return('false')
65
+ Rakismet.stub(:akismet_call).and_return('false')
66
66
  @model.should_not be_spam
67
67
  end
68
68
 
69
69
  it "should set akismet_response" do
70
- Rakismet.stub!(:akismet_call).and_return('response')
70
+ Rakismet.stub(:akismet_call).and_return('response')
71
71
  @model.spam?
72
72
  @model.akismet_response.should eql('response')
73
73
  end
74
74
 
75
75
  it "should not throw an error if request vars are missing" do
76
- Rakismet.stub!(:request).and_return(empty_request)
77
- lambda { @model.spam? }.should_not raise_error(NoMethodError)
76
+ Rakismet.stub(:request).and_return(empty_request)
77
+ Rakismet.stub(:akismet_call).and_return('false')
78
+ lambda { @model.spam? }.should_not raise_error
78
79
  end
79
80
  end
80
81
 
@@ -86,7 +87,7 @@ describe AkismetModel do
86
87
  end
87
88
 
88
89
  it "should mutate #spam?" do
89
- Rakismet.stub!(:akismet_call)
90
+ Rakismet.stub(:akismet_call)
90
91
  @model.instance_variable_set(:@_spam, false)
91
92
  @model.spam!
92
93
  @model.should be_spam
@@ -100,7 +101,7 @@ describe AkismetModel do
100
101
  end
101
102
 
102
103
  it "should mutate #spam?" do
103
- Rakismet.stub!(:akismet_call)
104
+ Rakismet.stub(:akismet_call)
104
105
  @model.instance_variable_set(:@_spam, true)
105
106
  @model.ham!
106
107
  @model.should_not be_spam
@@ -9,7 +9,7 @@ describe RequestParams do
9
9
  before do
10
10
  @model = RequestParams.new
11
11
  attrs = comment_attrs(:user_ip => '192.168.0.1', :user_agent => 'Rakismet', :referrer => 'http://localhost/referrer')
12
- attrs.each_pair { |k,v| @model.stub!(k).and_return(v) }
12
+ attrs.each_pair { |k,v| @model.stub(k).and_return(v) }
13
13
  end
14
14
 
15
15
  it "should use local values even if Rakismet.request is populated" do
@@ -35,44 +35,44 @@ describe Rakismet do
35
35
  describe ".validate_config" do
36
36
  it "should raise an error if key is not found" do
37
37
  Rakismet.key = ''
38
- lambda { Rakismet.send(:validate_config) }.should raise_error(Rakismet::Undefined)
38
+ lambda { Rakismet.send(:validate_config) }.should raise_error
39
39
  end
40
40
 
41
41
  it "should raise an error if url is not found" do
42
42
  Rakismet.url = ''
43
- lambda { Rakismet.send(:validate_config) }.should raise_error(Rakismet::Undefined)
43
+ lambda { Rakismet.send(:validate_config) }.should raise_error
44
44
  end
45
45
 
46
46
  it "should raise an error if host is not found" do
47
47
  Rakismet.host = ''
48
- lambda { Rakismet.send(:validate_config) }.should raise_error(Rakismet::Undefined)
48
+ lambda { Rakismet.send(:validate_config) }.should raise_error
49
49
  end
50
50
  end
51
51
 
52
52
  describe ".validate_key" do
53
53
  before (:each) do
54
- @proxy = mock(Net::HTTP)
55
- Net::HTTP.stub!(:Proxy).and_return(@proxy)
54
+ @proxy = double(Net::HTTP)
55
+ Net::HTTP.stub(:Proxy).and_return(@proxy)
56
56
  end
57
57
 
58
58
  it "should use proxy host and port" do
59
59
  Rakismet.proxy_host = 'proxy_host'
60
60
  Rakismet.proxy_port = 'proxy_port'
61
- @proxy.stub!(:start).and_return(mock_response('valid'))
61
+ @proxy.stub(:start).and_return(mock_response('valid'))
62
62
  Net::HTTP.should_receive(:Proxy).with('proxy_host', 'proxy_port').and_return(@proxy)
63
63
  Rakismet.validate_key
64
64
  end
65
65
 
66
66
  it "should set @@valid_key = true if key is valid" do
67
- @proxy.stub!(:start).and_return(mock_response('valid'))
67
+ @proxy.stub(:start).and_return(mock_response('valid'))
68
68
  Rakismet.validate_key
69
- Rakismet.valid_key?.should be_true
69
+ Rakismet.valid_key?.should be_truthy
70
70
  end
71
71
 
72
72
  it "should set @@valid_key = false if key is invalid" do
73
- @proxy.stub!(:start).and_return(mock_response('invalid'))
73
+ @proxy.stub(:start).and_return(mock_response('invalid'))
74
74
  Rakismet.validate_key
75
- Rakismet.valid_key?.should be_false
75
+ Rakismet.valid_key?.should be_falsey
76
76
  end
77
77
 
78
78
  it "should build url with host" do
@@ -82,7 +82,7 @@ describe Rakismet do
82
82
  Rakismet.validate_key
83
83
  end
84
84
  end
85
-
85
+
86
86
  describe '.excluded_headers' do
87
87
  it "should default to ['HTTP_COOKIE']" do
88
88
  Rakismet.excluded_headers.should eq ['HTTP_COOKIE']
@@ -91,15 +91,15 @@ describe Rakismet do
91
91
 
92
92
  describe ".akismet_call" do
93
93
  before do
94
- @proxy = mock(Net::HTTP)
95
- Net::HTTP.stub!(:Proxy).and_return(@proxy)
94
+ @proxy = double(Net::HTTP)
95
+ Net::HTTP.stub(:Proxy).and_return(@proxy)
96
96
  @proxy.stub(:start).and_yield(http)
97
97
  end
98
98
 
99
99
  it "should use proxy host and port" do
100
100
  Rakismet.proxy_host = 'proxy_host'
101
101
  Rakismet.proxy_port = 'proxy_port'
102
- @proxy.stub!(:start).and_return(mock_response('valid'))
102
+ @proxy.stub(:start).and_return(mock_response('valid'))
103
103
  Net::HTTP.should_receive(:Proxy).with('proxy_host', 'proxy_port').and_return(@proxy)
104
104
  Rakismet.send(:akismet_call, 'bogus-function')
105
105
  end
@@ -134,7 +134,7 @@ describe Rakismet do
134
134
  it "should build query string when params are nil" do
135
135
  lambda {
136
136
  Rakismet.send(:akismet_call, 'bogus-function', { :nil_param => nil })
137
- }.should_not raise_error(NoMethodError)
137
+ }.should_not raise_error
138
138
  end
139
139
  end
140
140
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rakismet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh French
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-22 00:00:00.000000000 Z
11
+ date: 2016-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake