Sha256: b6d181560637ab5c248500bf8932bb6cecc8a63c53605ae0a2c4329dd735c93d
Contents?: true
Size: 1.49 KB
Versions: 12
Compression:
Stored size: 1.49 KB
Contents
require 'teststrap' context "validates exclusion" do should "add a validation macro" do WhyValidationsSuckIn96::ValidationBuilder.instance_methods end.includes('validates_exclusion_of') should "raise if an :in option is not given" do WhyValidationsSuckIn96::ValidatesExclusion.new(Object.new, :attribute => :colour) end.raises(ArgumentError, "Collection to check for exclusion against should be specified with :in") context "with some default options" do setup do WhyValidationsSuckIn96::ValidatesExclusion.new(Object.new, :attribute => :colour, :in => %w[1 2 3]) end should "have a message accessor with a default message" do topic.message end.equals("is in the excluded collection") end # with some default options context "validating an object" do should "fail if the attribute is in the excluded set" do validation = WhyValidationsSuckIn96::ValidatesExclusion.new(OpenStruct.new(:colour => "red"), :attribute => :colour, :in => %w[red blue]) validation.validates? end.equals(false) should "pass if the attribute is out of the excluded set" do validation = WhyValidationsSuckIn96::ValidatesExclusion.new(OpenStruct.new(:colour => "red"), :attribute => :colour, :in => %w[green blue]) validation.validates? end end # validating an object end # validates exclusion
Version data entries
12 entries across 12 versions & 1 rubygems