Sha256: 108463c3e7974d423bf6abae39cb983b6de7e59ac1238957d17987af2c4481ec

Contents?: true

Size: 1.3 KB

Versions: 10

Compression:

Stored size: 1.3 KB

Contents

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

class ValidationAssertionCollectorTest < Test::Unit::TestCase
  expect 1 do
    assertions = ValidationAssertionCollector.gather(Class.new) do
      presence_of :name
    end
    assertions.size
  end
  
  expect "save this message" do
    assertions = ValidationAssertionCollector.gather(Class.new) do
      presence_of(:name).message("ignore this message").message("save this message")
    end
    assertions.first.options[:message]
  end
  
  expect :class_being_validated do
    assertions = ValidationAssertionCollector.gather(:class_being_validated) do
      presence_of(:name)
    end
    assertions.first.klass
  end
  
  expect NoMethodError do
    assertions = ValidationAssertionCollector.gather(Class.new) do
      presence_of(:name).invalid_option
    end
  end
    
  expect NoMethodError do
    assertions = ValidationAssertionCollector.gather(Class.new) do
      true_for(:name)
    end
  end
  
  expect NoMethodError do
    assertions = ValidationAssertionCollector.gather(Class.new) do
      presence_of(:name).if lambda { true }
    end
  end
  
  expect Validatable::ValidatesPresenceOf do
    assertions = ValidationAssertionCollector.gather(Class.new) do
      presence_of(:name)
    end
    assertions.first.validation_type
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
validatable-1.5.0 test/functional/validation_assertion_collector_test.rb
validatable-1.6.1 test/functional/validation_assertion_collector_test.rb
validatable-1.6.3 test/functional/validation_assertion_collector_test.rb
validatable-1.3.4 test/functional/validation_assertion_collector_test.rb
validatable-1.5.2 test/functional/validation_assertion_collector_test.rb
validatable-1.3.2 test/functional/validation_assertion_collector_test.rb
validatable-1.4.0 test/functional/validation_assertion_collector_test.rb
validatable-1.6.0 test/functional/validation_assertion_collector_test.rb
validatable-1.6.2 test/functional/validation_assertion_collector_test.rb
validatable-1.6.4 test/functional/validation_assertion_collector_test.rb