project_honeypot/spec/base_spec.rb

24 lines
680 B
Ruby
Raw Normal View History

2010-10-21 07:07:24 +02:00
require "spec_helper"
describe ProjectHoneypot::Base do
describe "with honeypot response" do
2013-01-14 14:30:07 +01:00
let(:base) { ProjectHoneypot::Base.new("abcdefghijklmnop") }
2010-10-21 07:07:24 +02:00
before(:each) do
flexmock(Net::DNS::Resolver, :start => flexmock("answer", :answer => ["somedomain.httpbl.org A Name 127.1.63.5"]))
end
it "returns a Url object" do
2013-01-14 14:30:07 +01:00
url = base.lookup("127.10.10.5")
expect(url).to be_a(ProjectHoneypot::Url)
expect(url.last_activity).to eq(1)
expect(url.score).to eq(63)
2010-10-21 07:07:24 +02:00
end
it "looks up non-ip addresses" do
2013-01-14 14:30:07 +01:00
url = base.lookup("iamspam.com")
2010-10-21 07:07:24 +02:00
Net::DNS::Resolver.should_receive(:start).with("iamspam.com")
end
end
end