File: validates_confirmation_of_test.rb

package info (click to toggle)
ruby-validatable 1.6.7-11
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 284 kB
  • sloc: ruby: 1,636; makefile: 10
file content (64 lines) | stat: -rw-r--r-- 2,580 bytes parent folder | download | duplicates (6)
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