Sha256: 4060d0af60e853d9cded9c1b77ecc92057519a82822782c694c8505aa75adf50
Contents?: true
Size: 1.88 KB
Versions: 6
Compression:
Stored size: 1.88 KB
Contents
require './lib/akismet' describe 'Akismet' do def check(opts = {}) comment = { :user_ip => "#{rand(255)}.#{rand(255)}.#{rand(255)}.#{rand(255)}", :referrer => 'http://www.google.com', :user_agent => user_agent, :permalink => link, :blog => "http://#{domain}", :comment_type => 'comment', :comment_content => opts['content'], :comment_author => opts['author_name'], :comment_author_url => opts['author_url'], :comment_author_email => opts['author_email'] }.merge(opts) client.check_comment(comment) end def client Akismet.new(:api_key => key, :blog => "http://#{domain}") end let(:domain) { 'test.com' } let(:user_agent) { 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36' } let(:link) { "http://#{domain}/blog/#{Time.now.year}/#{Time.now.month}/welcome-back.html" } describe 'with valid key' do let(:key) { 'e4c6b40ac9e0' } # test key describe 'with spammy comment' do it 'says its spam' do resp = check({ :content => 'Buy viagra', :author_name => 'Viagra guy', :author_url => 'http://viagra.com/buy', :author_email => 'viagra@viagra.com' }) resp[:spam].should eql(true) resp[:message].should eql("true") end end describe 'with not spammy comment' do it 'says its not spam' do resp = check({ :content => "Hey man, it's me for the #{rand(1000)}th time.", :author_name => 'jk2000', :author_url => nil, :author_email => 'jk2000@gmial.com' }) # puts resp.inspect resp[:spam].should eql(false) resp[:message].should eql("false") end end end end
Version data entries
6 entries across 6 versions & 1 rubygems