1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
Expectations do
expect true do
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username
instance = stub(:username=>"username", :username_confirmation=>"username")
validation.valid?(instance)
end
expect false do
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username
instance = stub(:username=>"username", :username_confirmation=>"usessrname")
validation.valid?(instance)
end
expect true do
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false
instance = stub(:username=>"username", :username_confirmation=>"USERNAME")
validation.valid?(instance)
end
expect false do
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true
instance = stub(:username=>"username", :username_confirmation=>"USERNAME")
validation.valid?(instance)
end
expect false do
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true
validation.valid?(stub(:username => nil, :username_confirmation => 'something'))
end
expect false do
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true
validation.valid?(stub(:username => 'something', :username_confirmation => nil))
end
expect true do
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true
validation.valid?(stub(:username => nil, :username_confirmation => nil))
end
expect false do
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false
validation.valid?(stub(:username => nil, :username_confirmation => 'something'))
end
expect false do
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false
validation.valid?(stub(:username => 'something', :username_confirmation => nil))
end
expect true do
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false
validation.valid?(stub(:username => nil, :username_confirmation => nil))
end
expect true do
options = { :message => nil, :if => nil, :times => nil, :level => nil, :groups => nil, :case_sensitive => nil }
Validatable::ValidatesConfirmationOf.new(stub_everything, :test).must_understand(options)
end
end
|