validatable 1.6.6 → 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ module Validatable
14
14
  return nil if errors[attribute.to_sym].nil?
15
15
  errors[attribute.to_sym].size == 1 ? errors[attribute.to_sym].first : errors[attribute.to_sym]
16
16
  end
17
-
17
+
18
18
  def add(attribute, message) #:nodoc:
19
19
  errors[attribute.to_sym] = [] if errors[attribute.to_sym].nil?
20
20
  errors[attribute.to_sym] << message
@@ -44,7 +44,7 @@ module Validatable
44
44
  end
45
45
 
46
46
  def count #:nodoc:
47
- size
47
+ errors.values.flatten.size
48
48
  end
49
49
 
50
50
  # call-seq: full_messages -> an_array_of_messages
@@ -29,7 +29,7 @@ Gem::manage_gems
29
29
  specification = Gem::Specification.new do |s|
30
30
  s.name = "validatable"
31
31
  s.summary = "Validatable is a library for adding validations."
32
- s.version = "1.6.6"
32
+ s.version = "1.6.7"
33
33
  s.author = 'Jay Fields'
34
34
  s.description = "Validatable is a library for adding validations."
35
35
  s.email = 'validatable-developer@rubyforge.org'
@@ -40,7 +40,6 @@ specification = Gem::Specification.new do |s|
40
40
  s.extra_rdoc_files = ['README']
41
41
  s.rdoc_options << '--title' << 'Validatable' << '--main' << 'README' << '--line-numbers'
42
42
 
43
- s.autorequire = 'validatable'
44
43
  s.files = FileList['{lib,test}/**/*.rb', '[A-Z]*$', 'rakefile.rb'].to_a
45
44
  s.test_file = "test/all_tests.rb"
46
45
  end
@@ -3,6 +3,7 @@ require 'rubygems'
3
3
  require 'mocha'
4
4
  require 'dust'
5
5
  require 'set'
6
+ require 'expectations'
6
7
 
7
8
  require File.dirname(__FILE__) + '/../lib/validatable'
8
9
 
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
- class ErrorsTest < Test::Unit::TestCase
3
+ Expectations do
4
4
  expect "message" do
5
5
  errors = Validatable::Errors.new
6
6
  errors.add(:attribute, "message")
@@ -37,8 +37,8 @@ class ErrorsTest < Test::Unit::TestCase
37
37
  errors.full_messages.sort
38
38
  end
39
39
 
40
- test "includes enumerable" do
41
- assert_equal true, Validatable::Errors.included_modules.include?(Enumerable)
40
+ expect true do
41
+ Validatable::Errors.included_modules.include?(Enumerable)
42
42
  end
43
43
 
44
44
  expect ["message1", "message2"] do
@@ -47,4 +47,18 @@ class ErrorsTest < Test::Unit::TestCase
47
47
  errors.add(:attribute, "message2")
48
48
  errors.on(:attribute)
49
49
  end
50
+
51
+ expect 2 do
52
+ errors = Validatable::Errors.new
53
+ errors.add(:attribute, "message1")
54
+ errors.add(:attribute, "message2")
55
+ errors.count
56
+ end
57
+
58
+ expect 2 do
59
+ errors = Validatable::Errors.new
60
+ errors.add(:attribute1, "message1")
61
+ errors.add(:attribute2, "message2")
62
+ errors.count
63
+ end
50
64
  end
@@ -1,12 +1,11 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
- class UnderstandableTest < Test::Unit::TestCase
4
- test "all understandings should collect understandings from all super classes" do
3
+ Expectations do
4
+ expect [:c, :b, :a] do
5
5
  a = Class.new do
6
6
  include Validatable::Understandable
7
7
  understands :a
8
8
  end
9
-
10
9
  b = Class.new(a) do
11
10
  include Validatable::Understandable
12
11
  understands :b
@@ -15,7 +14,6 @@ class UnderstandableTest < Test::Unit::TestCase
15
14
  include Validatable::Understandable
16
15
  understands :c
17
16
  end
18
-
19
- assert_array_equal [:a, :b, :c], c.all_understandings
17
+ c.all_understandings
20
18
  end
21
19
  end
@@ -1,40 +1,38 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
- module Unit
4
- class ValidatableTest < Test::Unit::TestCase
5
- expect false do
6
- validation = stub_everything(:should_validate? => true, :attribute => "attribute", :level => 1, :groups => [])
7
- klass = Class.new do
8
- include Validatable
9
- validations << validation
10
- end
11
- klass.new.valid?
3
+ Expectations do
4
+ expect false do
5
+ validation = stub_everything(:should_validate? => true, :attribute => "attribute", :level => 1, :groups => [])
6
+ klass = Class.new do
7
+ include Validatable
8
+ validations << validation
12
9
  end
13
-
14
- expect true do
15
- klass = Class.new do
16
- include Validatable
17
- end
18
- instance = klass.new
19
- instance.errors.add(:attribute, "message")
20
- instance.valid?
21
- instance.errors.empty?
10
+ klass.new.valid?
11
+ end
12
+
13
+ expect true do
14
+ klass = Class.new do
15
+ include Validatable
22
16
  end
23
-
24
- expect false do
25
- klass = Class.new do
26
- include Validatable
27
- end
28
- klass.validation_keys_include?("anything")
17
+ instance = klass.new
18
+ instance.errors.add(:attribute, "message")
19
+ instance.valid?
20
+ instance.errors.empty?
21
+ end
22
+
23
+ expect false do
24
+ klass = Class.new do
25
+ include Validatable
29
26
  end
30
-
31
- expect true do
32
- validation = stub_everything(:key => "key")
33
- klass = Class.new do
34
- include Validatable
35
- validations << validation
36
- end
37
- klass.validation_keys_include?("key")
27
+ klass.validation_keys_include?("anything")
28
+ end
29
+
30
+ expect true do
31
+ validation = stub_everything(:key => "key")
32
+ klass = Class.new do
33
+ include Validatable
34
+ validations << validation
38
35
  end
36
+ klass.validation_keys_include?("key")
39
37
  end
40
- end
38
+ end
@@ -1,16 +1,16 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
- class ValidatesAcceptanceOfTest < Test::Unit::TestCase
4
- test "valid acceptance" do
3
+ Expectations do
4
+ expect true do
5
5
  validation = Validatable::ValidatesAcceptanceOf.new stub_everything, :acceptance
6
6
  instance = stub(:acceptance=>'true')
7
- assert_equal true, validation.valid?(instance)
7
+ validation.valid?(instance)
8
8
  end
9
9
 
10
- test "invalid acceptance" do
10
+ expect false do
11
11
  validation = Validatable::ValidatesAcceptanceOf.new stub_everything, :acceptance
12
12
  instance = stub(:acceptance=>'false')
13
- assert_equal false, validation.valid?(instance)
13
+ validation.valid?(instance)
14
14
  end
15
15
 
16
16
  expect true do
@@ -1,58 +1,59 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
- class ValidatesConfirmationOfTest < Test::Unit::TestCase
4
- test "valid confirmation" do
3
+ Expectations do
4
+
5
+ expect true do
5
6
  validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username
6
7
  instance = stub(:username=>"username", :username_confirmation=>"username")
7
- assert_equal true, validation.valid?(instance)
8
+ validation.valid?(instance)
8
9
  end
9
10
 
10
- test "invalid confirmation" do
11
+ expect false do
11
12
  validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username
12
13
  instance = stub(:username=>"username", :username_confirmation=>"usessrname")
13
- assert_equal false, validation.valid?(instance)
14
+ validation.valid?(instance)
14
15
  end
15
16
 
16
- test "valid confirmation with case insensitive" do
17
+ expect true do
17
18
  validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false
18
19
  instance = stub(:username=>"username", :username_confirmation=>"USERNAME")
19
- assert_equal true, validation.valid?(instance)
20
+ validation.valid?(instance)
20
21
  end
21
22
 
22
- test "invalid confirmation with case sensitive" do
23
+ expect false do
23
24
  validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true
24
25
  instance = stub(:username=>"username", :username_confirmation=>"USERNAME")
25
- assert_equal false, validation.valid?(instance)
26
+ validation.valid?(instance)
26
27
  end
27
28
 
28
- test "invalid confirmation if value is nil and confirmation is not with case sensitive true" do
29
+ expect false do
29
30
  validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true
30
- assert_equal false, validation.valid?(stub(:username => nil, :username_confirmation => 'something'))
31
+ validation.valid?(stub(:username => nil, :username_confirmation => 'something'))
31
32
  end
32
33
 
33
- test "invalid confirmation if confirmation is nil and value is not with case sensitive true" do
34
+ expect false do
34
35
  validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true
35
- assert_equal false, validation.valid?(stub(:username => 'something', :username_confirmation => nil))
36
+ validation.valid?(stub(:username => 'something', :username_confirmation => nil))
36
37
  end
37
38
 
38
- test "valid confirmation if value and confirmation are nil with case sensitive true" do
39
+ expect true do
39
40
  validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true
40
- assert_equal true, validation.valid?(stub(:username => nil, :username_confirmation => nil))
41
+ validation.valid?(stub(:username => nil, :username_confirmation => nil))
41
42
  end
42
43
 
43
- test "invalid confirmation if value is nil and confirmation is not with case sensitive false" do
44
+ expect false do
44
45
  validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false
45
- assert_equal false, validation.valid?(stub(:username => nil, :username_confirmation => 'something'))
46
+ validation.valid?(stub(:username => nil, :username_confirmation => 'something'))
46
47
  end
47
48
 
48
- test "invalid confirmation if confirmation is nil and value is not with case sensitive false" do
49
+ expect false do
49
50
  validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false
50
- assert_equal false, validation.valid?(stub(:username => 'something', :username_confirmation => nil))
51
+ validation.valid?(stub(:username => 'something', :username_confirmation => nil))
51
52
  end
52
53
 
53
- test "valid confirmation if value and confirmation are nil with case sensitive false" do
54
+ expect true do
54
55
  validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false
55
- assert_equal true, validation.valid?(stub(:username => nil, :username_confirmation => nil))
56
+ validation.valid?(stub(:username => nil, :username_confirmation => nil))
56
57
  end
57
58
 
58
59
  expect true do
@@ -1,25 +1,24 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
- class ValidatesFormatOfTest < Test::Unit::TestCase
4
- test "when attribute value does not match the given regex, then valid is false" do
3
+ Expectations do
4
+
5
+ expect false do
5
6
  validation = Validatable::ValidatesFormatOf.new stub_everything, :name, :with => /book/
6
- assert_equal false, validation.valid?(stub_everything)
7
+ validation.valid?(stub_everything)
7
8
  end
8
9
 
9
- test "when attribute value does match the given regex, then valid is true" do
10
+ expect true do
10
11
  validation = Validatable::ValidatesFormatOf.new stub_everything, :name, :with => /book/
11
- assert_equal true, validation.valid?(stub(:name=>"book"))
12
+ validation.valid?(stub(:name=>"book"))
12
13
  end
13
14
 
14
- test "when attribute value is an integer it should be converted to a string before matching" do
15
+ expect true do
15
16
  validation = Validatable::ValidatesFormatOf.new stub_everything, :age, :with => /14/
16
- assert_equal true, validation.valid?(stub(:age=>14))
17
+ validation.valid?(stub(:age=>14))
17
18
  end
18
19
 
19
- test "when no with is given, then an error is raised during construction" do
20
- assert_raises ArgumentError do
21
- validation = Validatable::ValidatesFormatOf.new stub_everything, :age
22
- end
20
+ expect ArgumentError do
21
+ validation = Validatable::ValidatesFormatOf.new stub_everything, :age
23
22
  end
24
23
 
25
24
  expect true do
@@ -1,77 +1,75 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
- module Unit
4
- class ValidatesLengthOfTest < Test::Unit::TestCase
5
- expect false do
6
- validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :maximum => 8
7
- validation.valid?(stub(:username=>"usernamefdfd"))
8
- end
9
-
10
- test "min length" do
11
- validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :minimum => 2
12
- instance = stub(:username=>"u")
13
- assert_equal false, validation.valid?(instance)
14
- end
3
+ Expectations do
4
+ expect false do
5
+ validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :maximum => 8
6
+ validation.valid?(stub(:username=>"usernamefdfd"))
7
+ end
15
8
 
16
- test "valid length" do
17
- validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :minimum => 2, :maximum => 8
18
- instance = stub(:username=>"udfgdf")
19
- assert_equal true, validation.valid?(instance)
20
- end
21
-
22
- test "is length is false" do
23
- validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :is => 2
24
- instance = stub(:username=>"u")
25
- assert_equal false, validation.valid?(instance)
26
- end
27
-
28
- test "is length is true" do
29
- validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :is => 2
30
- instance = stub(:username=>"uu")
31
- assert_equal true, validation.valid?(instance)
32
- end
33
-
34
- test "within lower bound is true" do
35
- validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
36
- instance = stub(:username => "aa")
37
- assert_equal true, validation.valid?(instance)
38
- end
9
+ expect false do
10
+ validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :minimum => 2
11
+ instance = stub(:username=>"u")
12
+ validation.valid?(instance)
13
+ end
39
14
 
40
- test "within outside lower bound is false" do
41
- validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
42
- instance = stub(:username => "a")
43
- assert_equal false, validation.valid?(instance)
44
- end
15
+ expect true do
16
+ validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :minimum => 2, :maximum => 8
17
+ instance = stub(:username=>"udfgdf")
18
+ validation.valid?(instance)
19
+ end
20
+
21
+ expect false do
22
+ validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :is => 2
23
+ instance = stub(:username=>"u")
24
+ validation.valid?(instance)
25
+ end
26
+
27
+ expect true do
28
+ validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :is => 2
29
+ instance = stub(:username=>"uu")
30
+ validation.valid?(instance)
31
+ end
32
+
33
+ expect true do
34
+ validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
35
+ instance = stub(:username => "aa")
36
+ validation.valid?(instance)
37
+ end
45
38
 
46
- test "within upper bound is true" do
47
- validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
48
- instance = stub(:username => "aaaa")
49
- assert_equal true, validation.valid?(instance)
50
- end
39
+ expect false do
40
+ validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
41
+ instance = stub(:username => "a")
42
+ validation.valid?(instance)
43
+ end
44
+
45
+ expect true do
46
+ validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
47
+ instance = stub(:username => "aaaa")
48
+ validation.valid?(instance)
49
+ end
51
50
 
52
- test "within outside upper bound is false" do
53
- validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
54
- instance = stub(:username => "aaaaa")
55
- assert_equal false, validation.valid?(instance)
56
- end
51
+ expect false do
52
+ validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
53
+ instance = stub(:username => "aaaaa")
54
+ validation.valid?(instance)
55
+ end
57
56
 
58
- test "given nil value, should not be valid" do
59
- validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
60
- instance = stub(:username => nil)
61
- assert_equal false, validation.valid?(instance)
62
- end
57
+ expect false do
58
+ validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
59
+ instance = stub(:username => nil)
60
+ validation.valid?(instance)
61
+ end
63
62
 
64
63
 
65
- test "given allow_nil is true, nil value should be valid" do
66
- validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4, :allow_nil => true
67
- instance = stub(:username => nil)
68
- assert_equal true, validation.valid?(instance)
69
- end
70
-
71
- expect true do
72
- options = [:message, :if, :times, :level, :groups, :maximum, :minimum, :is, :within, :allow_nil]
73
- Validatable::ValidatesLengthOf.new(stub_everything, :test).must_understand(options.to_blank_options_hash)
74
- end
75
-
64
+ expect true do
65
+ validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4, :allow_nil => true
66
+ instance = stub(:username => nil)
67
+ validation.valid?(instance)
68
+ end
69
+
70
+ expect true do
71
+ options = [:message, :if, :times, :level, :groups, :maximum, :minimum, :is, :within, :allow_nil]
72
+ Validatable::ValidatesLengthOf.new(stub_everything, :test).must_understand(options.to_blank_options_hash)
76
73
  end
74
+
77
75
  end
@@ -1,54 +1,52 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
- module Unit
4
- class ValidatesNumericalityOfTest < Test::Unit::TestCase
3
+ Expectations do
5
4
 
6
- test "when the value is nil then valid is false" do
7
- validation = Validatable::ValidatesNumericalityOf.new stub_everything, :nothing
8
- instance = stub(:nothing => nil)
9
- assert_equal false, validation.valid?(instance)
10
- end
5
+ expect false do
6
+ validation = Validatable::ValidatesNumericalityOf.new stub_everything, :nothing
7
+ instance = stub(:nothing => nil)
8
+ validation.valid?(instance)
9
+ end
10
+
11
+ expect true do
12
+ validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_int
13
+ instance = stub(:some_int => 50)
14
+ validation.valid?(instance)
15
+ end
16
+
17
+ expect true do
18
+ validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_decimal
19
+ instance = stub(:some_decimal => 1.23)
20
+ validation.valid?(instance)
21
+ end
22
+
23
+ expect false do
24
+ validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_decimal, :only_integer => true
25
+ instance = stub(:some_decimal => 1.23)
26
+ validation.valid?(instance)
27
+ end
11
28
 
12
- test "when value is an integer then valid is true" do
13
- validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_int
14
- instance = stub(:some_int => 50)
15
- assert_equal true, validation.valid?(instance)
16
- end
17
-
18
- test "when value is an decimal then valid is true" do
19
- validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_decimal
20
- instance = stub(:some_decimal => 1.23)
21
- assert_equal true, validation.valid?(instance)
22
- end
29
+ expect true do
30
+ validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_negative_number, :only_integer => true
31
+ instance = stub(:some_negative_number => "-1")
32
+ validation.valid?(instance)
33
+ end
23
34
 
24
- test "when value is a decimal but only_integer is true, then valid is false" do
25
- validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_decimal, :only_integer => true
26
- instance = stub(:some_decimal => 1.23)
27
- assert_equal false, validation.valid?(instance)
28
- end
29
-
30
- test "when value is an integer string and only_integer is true, then valid is true" do
31
- validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_negative_number, :only_integer => true
32
- instance = stub(:some_negative_number => "-1")
33
- assert_equal true, validation.valid?(instance)
34
- end
35
-
36
- test "when value has non numeric characters then valid is false" do
37
- validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_non_numeric
38
- instance = stub(:some_non_numeric => "50F")
39
- assert_equal false, validation.valid?(instance)
40
- end
35
+ expect false do
36
+ validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_non_numeric
37
+ instance = stub(:some_non_numeric => "50F")
38
+ validation.valid?(instance)
39
+ end
40
+
41
+ expect false do
42
+ validation = Validatable::ValidatesNumericalityOf.new stub_everything, :multiple_dots
43
+ instance = stub(:multiple_dots => "50.0.0")
44
+ validation.valid?(instance)
45
+ end
41
46
 
42
- test "when value is a string with multiple dots then valid is false" do
43
- validation = Validatable::ValidatesNumericalityOf.new stub_everything, :multiple_dots
44
- instance = stub(:multiple_dots => "50.0.0")
45
- assert_equal false, validation.valid?(instance)
46
- end
47
-
48
- expect true do
49
- options = [:message, :if, :times, :level, :groups, :only_integer]
50
- Validatable::ValidatesNumericalityOf.new(stub_everything, :test).must_understand(options.to_blank_options_hash)
51
- end
52
-
47
+ expect true do
48
+ options = [:message, :if, :times, :level, :groups, :only_integer]
49
+ Validatable::ValidatesNumericalityOf.new(stub_everything, :test).must_understand(options.to_blank_options_hash)
53
50
  end
51
+
54
52
  end
@@ -1,19 +1,20 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
- class ValidatesPresenceOfTest < Test::Unit::TestCase
4
- test "when attribute value does not match the given regex, then valid is false" do
3
+ Expectations do
4
+
5
+ expect false do
5
6
  validation = Validatable::ValidatesPresenceOf.new stub_everything, :name
6
- assert_equal false, validation.valid?(stub_everything)
7
+ validation.valid?(stub_everything)
7
8
  end
8
9
 
9
- test "when attribute value does match the given regex, then valid is true" do
10
+ expect true do
10
11
  validation = Validatable::ValidatesPresenceOf.new stub_everything, :name
11
- assert_equal true, validation.valid?(stub(:name=>"book"))
12
+ validation.valid?(stub(:name=>"book"))
12
13
  end
13
14
 
14
- test "when given a true value which is not a String, then valid is true" do
15
+ expect true do
15
16
  validation = Validatable::ValidatesPresenceOf.new stub_everything, :employee
16
- assert_equal true, validation.valid?(stub(:employee => stub(:nil? => false)))
17
+ validation.valid?(stub(:employee => stub(:nil? => false)))
17
18
  end
18
19
 
19
20
  expect true do
@@ -1,20 +1,19 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
- class ValidatesTrueForTest < Test::Unit::TestCase
4
- test "when block returns false for attribute value, then valid is false" do
3
+ Expectations do
4
+
5
+ expect false do
5
6
  validation = Validatable::ValidatesTrueFor.new stub_everything, :name, :logic => lambda { false }
6
- assert_equal false, validation.valid?(stub_everything)
7
+ validation.valid?(stub_everything)
7
8
  end
8
9
 
9
- test "when block returns true for attribute value, then valid is false" do
10
+ expect true do
10
11
  validation = Validatable::ValidatesTrueFor.new stub_everything, :name, :logic => lambda { true }
11
- assert_equal true, validation.valid?(stub_everything)
12
+ validation.valid?(stub_everything)
12
13
  end
13
14
 
14
- test "when no logic is given, then an error is raised during construction" do
15
- assert_raises ArgumentError do
16
- validation = Validatable::ValidatesTrueFor.new stub_everything, :age
17
- end
15
+ expect ArgumentError do
16
+ validation = Validatable::ValidatesTrueFor.new stub_everything, :age
18
17
  end
19
18
 
20
19
  expect true do
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
- class ValidationBaseTest < Test::Unit::TestCase
3
+ Expectations do
4
4
  expect true do
5
5
  validation = Validatable::ValidationBase.new stub_everything, :base
6
6
  validation.should_validate? Object.new
metadata CHANGED
@@ -1,33 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
3
- specification_version: 1
4
2
  name: validatable
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.6.6
7
- date: 2007-11-04 00:00:00 -04:00
8
- summary: Validatable is a library for adding validations.
9
- require_paths:
10
- - lib
11
- email: validatable-developer@rubyforge.org
12
- homepage: http://validatable.rubyforge.org
13
- rubyforge_project: validatable
14
- description: Validatable is a library for adding validations.
15
- autorequire: validatable
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 1.6.7
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Jay Fields
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-03-20 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Validatable is a library for adding validations.
17
+ email: validatable-developer@rubyforge.org
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
31
24
  files:
32
25
  - lib/child_validation.rb
33
26
  - lib/errors.rb
@@ -72,21 +65,35 @@ files:
72
65
  - test/unit/validation_base_test.rb
73
66
  - rakefile.rb
74
67
  - README
75
- test_files:
76
- - test/all_tests.rb
68
+ has_rdoc: true
69
+ homepage: http://validatable.rubyforge.org
70
+ post_install_message:
77
71
  rdoc_options:
78
72
  - --title
79
73
  - Validatable
80
74
  - --main
81
75
  - README
82
76
  - --line-numbers
83
- extra_rdoc_files:
84
- - README
85
- executables: []
86
-
87
- extensions: []
88
-
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ version:
89
91
  requirements: []
90
92
 
91
- dependencies: []
92
-
93
+ rubyforge_project: validatable
94
+ rubygems_version: 1.0.1
95
+ signing_key:
96
+ specification_version: 2
97
+ summary: Validatable is a library for adding validations.
98
+ test_files:
99
+ - test/all_tests.rb