Test safe? method and search engine type
parent
e0b488868a
commit
2f87b63c18
|
@ -2,12 +2,25 @@ require "spec_helper"
|
|||
|
||||
describe ProjectHoneypot::Url do
|
||||
describe "with honeypot response" do
|
||||
before(:each) do
|
||||
@url = ProjectHoneypot::Url.new("teachmetocode.com", "127.1.63.3")
|
||||
before(:each) do
|
||||
@url = ProjectHoneypot::Url.new("127.0.0.1", "127.1.63.3")
|
||||
end
|
||||
|
||||
it "is safe" do
|
||||
@url.should_not be_safe
|
||||
|
||||
@url.safe?(score: 63).should be_false
|
||||
@url.safe?(score: 64).should be_true
|
||||
|
||||
@url.safe?(last_activity: 1).should be_false
|
||||
@url.safe?(last_activity: 2).should be_true
|
||||
|
||||
@url.safe?(last_activity: 2, score: 64).should be_true
|
||||
@url.safe?(last_activity: 1, score: 64).should be_false
|
||||
@url.safe?(last_activity: 2, score: 63).should be_false
|
||||
|
||||
@url.safe?(offenses: [:comment_spammer]).should be_true
|
||||
@url.safe?(offenses: [:suspicious, :comment_spammer]).should be_false
|
||||
end
|
||||
|
||||
it "has the correct latest activity" do
|
||||
|
@ -28,8 +41,14 @@ describe ProjectHoneypot::Url do
|
|||
end
|
||||
end
|
||||
|
||||
describe "with search engine honeypot response" do
|
||||
subject { @url = ProjectHoneypot::Url.new("127.0.0.1", "127.0.9.0") }
|
||||
it { should be_safe }
|
||||
it { should be_search_engine }
|
||||
end
|
||||
|
||||
describe "with nil honeypot response" do
|
||||
subject { @url = ProjectHoneypot::Url.new("teachmetocode.com", nil) }
|
||||
subject { @url = ProjectHoneypot::Url.new("127.0.0.1", nil) }
|
||||
it { should be_safe }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue