Sha256: ab0e277d486a25cc0e542c7dbf6f5410b90c3e178f91ffc94bfa8bb3b2dcfa0d

Contents?: true

Size: 736 Bytes

Versions: 2

Compression:

Stored size: 736 Bytes

Contents

require "spec_helper"

describe StupidSpamProtection do
  it "should add robot attribute" do
    class Stuff < ActiveRecord::Base
      include ActiveRecordNoTable
    end

    item = Stuff.new
    item.should_not respond_to :robot
    item.should_not respond_to :robot=

    Stuff.send(:extend, StupidSpamProtection)

    item = Stuff.new
    item.should respond_to :robot
    item.should respond_to :robot=
  end

  it "should validate empty of robot attribute" do
    class Item < ActiveRecord::Base
      include ActiveRecordNoTable

      extend StupidSpamProtection
    end

    item = Item.new
    item.should be_valid
    item.robot = "whatever"
    item.should_not be_valid
    item.errors[:robot].should have(1).item
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stupid_spam_protection-0.0.2 spec/stupid_spam_protection_spec.rb
stupid_spam_protection-0.0.1 spec/stupid_spam_protection_spec.rb