Sha256: 43d76552fc7a5bf6f3ddbceddacdc8fa180ba0182a4cecf014cf9dc95d98fd36

Contents?: true

Size: 837 Bytes

Versions: 17

Compression:

Stored size: 837 Bytes

Contents

require 'teststrap'

context "validates presence" do
  
  should "add a validation macro" do
    WhyValidationsSuckIn96::ValidationBuilder.instance_methods
  end.includes('validates_presence_of')
  
  context "validating an object" do
    validatable = OpenStruct.new(:message => "foo")
    
    setup do
      WhyValidationsSuckIn96::ValidatesPresence.new(validatable, :attribute => :message)
    end
    
    should "have a message accessor with a default message" do
      topic.message
    end.equals("is not present")
    
    should "fail if the attribute is blank" do
      validatable.message = ""
      topic.validates?
    end.equals(false)
    
    should "pass if the attribute is non blank" do
      validatable.message = "blah"
      topic.validates?
    end
    
  end   # validating an object
end     # validates presence

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
whyvalidationssuckin96-1.6.1 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.6.0 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.5.5 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.5.4 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.5.3 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.5.2 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.5.1 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.5.0 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.4.0 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.3.1 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.3.0 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.2.3 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.2.2 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.2.1 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.2.0 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.1.0 test/macros/validates_presence_test.rb
whyvalidationssuckin96-1.0.0 test/macros/validates_presence_test.rb