Sha256: cca4e465d19913cfff4e7da344611bb8046ea4c90656586e1b2418dba4594700

Contents?: true

Size: 997 Bytes

Versions: 8

Compression:

Stored size: 997 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../test_helper')

class ValidatesPresenceOfTest < Test::Unit::TestCase
  test "when attribute value does not match the given regex, then valid is false" do
    validation = Validatable::ValidatesPresenceOf.new stub, :name
    assert_equal false, validation.valid?(stub_everything)
  end
  
  test "when attribute value does match the given regex, then valid is true" do
    validation = Validatable::ValidatesPresenceOf.new stub, :name
    assert_equal true, validation.valid?(stub(:name=>"book"))
  end
  
  test "when given a true value which is not a String, then valid is true" do 
    validation = Validatable::ValidatesPresenceOf.new stub, :employee
    assert_equal true, validation.valid?(stub(:employee => stub(:nil? => false)))
  end
  
  expect true do
    options = {:message => nil, :if => nil, :times => nil, :level => nil, :groups => nil}
    Validatable::ValidatesPresenceOf.new(stub, :test).must_understand(options)
  end
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
validatable-1.6.4 test/unit/validates_presence_of_test.rb
validatable-1.5.2 test/unit/validates_presence_of_test.rb
validatable-1.6.0 test/unit/validates_presence_of_test.rb
validatable-1.5.0 test/unit/validates_presence_of_test.rb
validatable-1.6.3 test/unit/validates_presence_of_test.rb
validatable-1.4.0 test/unit/validates_presence_of_test.rb
validatable-1.6.1 test/unit/validates_presence_of_test.rb
validatable-1.6.2 test/unit/validates_presence_of_test.rb