Sha256: c609d6891e12f786f9a4ddd575d87f25ad552b268f365c222ea5c9795e9a6563
Contents?: true
Size: 1.16 KB
Versions: 8
Compression:
Stored size: 1.16 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') class ValidatesTrueForTest < Test::Unit::TestCase test "when block returns false for attribute value, then valid is false" do validation = Validatable::ValidatesTrueFor.new stub, :name, :logic => lambda { false } assert_equal false, validation.valid?(stub_everything) end test "when block returns true for attribute value, then valid is false" do validation = Validatable::ValidatesTrueFor.new stub, :name, :logic => lambda { true } assert_equal true, validation.valid?(stub_everything) end test "when no logic is given, then an error is raised during construction" do assert_raises ArgumentError do validation = Validatable::ValidatesTrueFor.new stub, :age end end expect true do options = [:message, :if, :times, :level, :groups, :logic, :key] Validatable::ValidatesTrueFor.new(stub, :name, options.to_blank_options_hash).must_understand(options.to_blank_options_hash) end expect true do options = [:logic] Validatable::ValidatesTrueFor.new(stub, :name, options.to_blank_options_hash).requires(options.to_blank_options_hash) end end
Version data entries
8 entries across 8 versions & 1 rubygems