File: validates_true_for_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 (29 lines) | stat: -rw-r--r-- 951 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
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')

Expectations do
  
  expect false do
    validation = Validatable::ValidatesTrueFor.new stub_everything, :name, :logic => lambda { false }
    validation.valid?(stub_everything)
  end
  
  expect true do
    validation = Validatable::ValidatesTrueFor.new stub_everything, :name, :logic => lambda { true }
    validation.valid?(stub_everything)
  end
  
  expect ArgumentError do
    validation = Validatable::ValidatesTrueFor.new stub_everything, :age
  end
  
  expect true do
    options = [:message, :if, :times, :level, :groups, :logic, :key]
    Validatable::ValidatesTrueFor.new(stub_everything, :name, options.to_blank_options_hash).must_understand(options.to_blank_options_hash)
  end
  
  expect true do
    options = [:logic]
    Validatable::ValidatesTrueFor.new(stub_everything, :name, options.to_blank_options_hash).requires(options.to_blank_options_hash)
  end
  
end