Sha256: 87b8228600fb4eb9ae046e33a8777370e5c58e707801d0347e3eb62340707bbe
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') class ValidatesFormatOfTest < Test::Unit::TestCase test "when attribute value does not match the given regex, then valid is false" do validation = Validatable::ValidatesFormatOf.new :name, :with => /book/ assert_equal false, validation.valid?(stub_everything) end test "when attribute value does match the given regex, then valid is true" do validation = Validatable::ValidatesFormatOf.new :name, :with => /book/ assert_equal true, validation.valid?(stub(:name=>"book")) end test "when attribute value is an integer it should be converted to a string before matching" do validation = Validatable::ValidatesFormatOf.new :age, :with => /14/ assert_equal true, validation.valid?(stub(:age=>14)) end test "when no with is given, then an error is raised during construction" do assert_raises ArgumentError do validation = Validatable::ValidatesFormatOf.new :age end end expect true do options = [:message, :if, :times, :level, :groups, :with] Validatable::ValidatesFormatOf.new(:test, options.to_blank_options_hash).must_understand(options.to_blank_options_hash) end expect true do options = [:with] Validatable::ValidatesFormatOf.new(:name, options.to_blank_options_hash).requires(options.to_blank_options_hash) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
validatable-1.3.0 | test/unit/validates_format_of_test.rb |
validatable-1.3.2 | test/unit/validates_format_of_test.rb |
validatable-1.3.4 | test/unit/validates_format_of_test.rb |