Test safe? method and search engine type

master
Guillaume DOTT 2013-01-14 10:07:55 +01:00
parent e0b488868a
commit 2f87b63c18
1 changed files with 22 additions and 3 deletions

View File

@ -2,12 +2,25 @@ require "spec_helper"
describe ProjectHoneypot::Url do describe ProjectHoneypot::Url do
describe "with honeypot response" do describe "with honeypot response" do
before(:each) do before(:each) do
@url = ProjectHoneypot::Url.new("teachmetocode.com", "127.1.63.3") @url = ProjectHoneypot::Url.new("127.0.0.1", "127.1.63.3")
end end
it "is safe" do it "is safe" do
@url.should_not be_safe @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 end
it "has the correct latest activity" do it "has the correct latest activity" do
@ -28,8 +41,14 @@ describe ProjectHoneypot::Url do
end end
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 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 } it { should be_safe }
end end
end end