dm-validations 0.9.11 → 0.10.0

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.
Files changed (159) hide show
  1. data/{History.txt → History.rdoc} +10 -3
  2. data/LICENSE +1 -0
  3. data/Manifest.txt +103 -33
  4. data/README.rdoc +172 -0
  5. data/Rakefile +4 -5
  6. data/lib/dm-validations.rb +73 -75
  7. data/lib/dm-validations/auto_validate.rb +98 -56
  8. data/lib/dm-validations/contextual_validators.rb +37 -14
  9. data/lib/dm-validations/exceptions.rb +3 -0
  10. data/lib/dm-validations/formats/url.rb +3 -1
  11. data/lib/dm-validations/support/context.rb +54 -0
  12. data/lib/dm-validations/validation_errors.rb +51 -27
  13. data/lib/dm-validations/{absent_field_validator.rb → validators/absent_field_validator.rb} +2 -8
  14. data/lib/dm-validations/{acceptance_validator.rb → validators/acceptance_validator.rb} +7 -7
  15. data/lib/dm-validations/{block_validator.rb → validators/block_validator.rb} +0 -0
  16. data/lib/dm-validations/{confirmation_validator.rb → validators/confirmation_validator.rb} +7 -7
  17. data/lib/dm-validations/{format_validator.rb → validators/format_validator.rb} +10 -16
  18. data/lib/dm-validations/{generic_validator.rb → validators/generic_validator.rb} +28 -6
  19. data/lib/dm-validations/validators/length_validator.rb +214 -0
  20. data/lib/dm-validations/validators/method_validator.rb +68 -0
  21. data/lib/dm-validations/validators/numeric_validator.rb +171 -0
  22. data/lib/dm-validations/{primitive_validator.rb → validators/primitive_validator.rb} +2 -7
  23. data/lib/dm-validations/{required_field_validator.rb → validators/required_field_validator.rb} +0 -6
  24. data/lib/dm-validations/{uniqueness_validator.rb → validators/uniqueness_validator.rb} +9 -20
  25. data/lib/dm-validations/{within_validator.rb → validators/within_validator.rb} +4 -4
  26. data/lib/dm-validations/version.rb +1 -1
  27. data/spec/fixtures/barcode.rb +32 -0
  28. data/spec/fixtures/basketball_court.rb +58 -0
  29. data/spec/fixtures/basketball_player.rb +37 -0
  30. data/spec/fixtures/beta_tester_account.rb +33 -0
  31. data/spec/fixtures/bill_of_landing.rb +42 -0
  32. data/spec/fixtures/boat_dock.rb +26 -0
  33. data/spec/fixtures/city.rb +25 -0
  34. data/spec/fixtures/company.rb +95 -0
  35. data/spec/fixtures/corporate_world.rb +47 -0
  36. data/spec/fixtures/country.rb +25 -0
  37. data/spec/fixtures/currency.rb +42 -0
  38. data/spec/fixtures/ethernet_frame.rb +56 -0
  39. data/spec/fixtures/event.rb +44 -0
  40. data/spec/fixtures/g3_concert.rb +57 -0
  41. data/spec/fixtures/jabberwock.rb +27 -0
  42. data/spec/fixtures/kayak.rb +28 -0
  43. data/spec/fixtures/lernean_hydra.rb +39 -0
  44. data/spec/fixtures/mathematical_function.rb +34 -0
  45. data/spec/fixtures/memory_object.rb +30 -0
  46. data/spec/fixtures/mittelschnauzer.rb +35 -0
  47. data/spec/fixtures/motor_launch.rb +21 -0
  48. data/spec/fixtures/page.rb +32 -0
  49. data/spec/fixtures/phone_number.rb +28 -0
  50. data/spec/fixtures/pirogue.rb +28 -0
  51. data/spec/fixtures/programming_language.rb +83 -0
  52. data/spec/fixtures/reservation.rb +38 -0
  53. data/spec/fixtures/scm_operation.rb +67 -0
  54. data/spec/fixtures/sms_message.rb +22 -0
  55. data/spec/fixtures/udp_packet.rb +49 -0
  56. data/spec/integration/absent_field_validator/absent_field_validator_spec.rb +86 -0
  57. data/spec/integration/absent_field_validator/spec_helper.rb +7 -0
  58. data/spec/integration/acceptance_validator/acceptance_validator_spec.rb +196 -0
  59. data/spec/integration/acceptance_validator/spec_helper.rb +7 -0
  60. data/spec/integration/automatic_validation/custom_messages_for_inferred_validation_spec.rb +47 -0
  61. data/spec/integration/automatic_validation/disabling_inferred_validation_spec.rb +41 -0
  62. data/spec/integration/automatic_validation/inferred_boolean_properties_validation_spec.rb +104 -0
  63. data/spec/integration/automatic_validation/inferred_float_property_validation_spec.rb +35 -0
  64. data/spec/integration/automatic_validation/inferred_format_validation_spec.rb +33 -0
  65. data/spec/integration/automatic_validation/inferred_integer_properties_validation_spec.rb +73 -0
  66. data/spec/integration/automatic_validation/inferred_length_validation_spec.rb +121 -0
  67. data/spec/integration/automatic_validation/inferred_presence_validation_spec.rb +41 -0
  68. data/spec/integration/automatic_validation/inferred_primitive_validation_spec.rb +20 -0
  69. data/spec/integration/automatic_validation/inferred_within_validation_spec.rb +33 -0
  70. data/spec/integration/automatic_validation/spec_helper.rb +74 -0
  71. data/spec/integration/block_validator/block_validator_spec.rb +32 -0
  72. data/spec/integration/block_validator/spec_helper.rb +5 -0
  73. data/spec/integration/conditional_validation/if_condition_spec.rb +61 -0
  74. data/spec/integration/conditional_validation/spec_helper.rb +5 -0
  75. data/spec/integration/confirmation_validator/confirmation_validator_spec.rb +74 -0
  76. data/spec/integration/confirmation_validator/spec_helper.rb +5 -0
  77. data/spec/integration/datamapper_models/association_validation_spec.rb +23 -0
  78. data/spec/integration/datamapper_models/inheritance_spec.rb +78 -0
  79. data/spec/integration/duplicated_validations/duplicated_validations_spec.rb +22 -0
  80. data/spec/integration/duplicated_validations/spec_helper.rb +5 -0
  81. data/spec/integration/format_validator/email_format_validator_spec.rb +113 -0
  82. data/spec/integration/format_validator/format_validator_spec.rb +60 -0
  83. data/spec/integration/format_validator/regexp_validator_spec.rb +29 -0
  84. data/spec/integration/format_validator/spec_helper.rb +5 -0
  85. data/spec/integration/format_validator/url_format_validator_spec.rb +63 -0
  86. data/spec/integration/length_validator/default_value_spec.rb +12 -0
  87. data/spec/integration/length_validator/equality_spec.rb +79 -0
  88. data/spec/integration/length_validator/error_message_spec.rb +15 -18
  89. data/spec/integration/length_validator/maximum_spec.rb +40 -24
  90. data/spec/integration/length_validator/minimum_spec.rb +32 -21
  91. data/spec/integration/length_validator/range_spec.rb +50 -60
  92. data/spec/integration/length_validator/spec_helper.rb +7 -12
  93. data/spec/integration/method_validator/method_validator_spec.rb +239 -0
  94. data/spec/integration/method_validator/spec_helper.rb +5 -0
  95. data/spec/integration/numeric_validator/equality_with_float_type_spec.rb +61 -0
  96. data/spec/integration/numeric_validator/equality_with_integer_type_spec.rb +37 -0
  97. data/spec/integration/numeric_validator/float_type_spec.rb +42 -56
  98. data/spec/integration/numeric_validator/gt_with_float_type_spec.rb +35 -0
  99. data/spec/integration/numeric_validator/gte_with_float_type_spec.rb +35 -0
  100. data/spec/integration/numeric_validator/integer_only_true_spec.rb +3 -6
  101. data/spec/integration/numeric_validator/integer_type_spec.rb +8 -24
  102. data/spec/integration/numeric_validator/lt_with_float_type_spec.rb +35 -0
  103. data/spec/integration/numeric_validator/lte_with_float_type_spec.rb +35 -0
  104. data/spec/integration/numeric_validator/spec_helper.rb +5 -77
  105. data/spec/integration/primitive_validator/primitive_validator_spec.rb +90 -0
  106. data/spec/integration/primitive_validator/spec_helper.rb +5 -0
  107. data/spec/integration/pure_ruby_objects/plain_old_ruby_object_validation_spec.rb +118 -0
  108. data/spec/integration/required_field_validator/association_spec.rb +5 -8
  109. data/spec/integration/required_field_validator/boolean_type_value_spec.rb +4 -7
  110. data/spec/integration/required_field_validator/date_type_value_spec.rb +3 -6
  111. data/spec/integration/required_field_validator/datetime_type_value_spec.rb +3 -6
  112. data/spec/integration/required_field_validator/float_type_value_spec.rb +3 -6
  113. data/spec/integration/required_field_validator/integer_type_value_spec.rb +2 -5
  114. data/spec/integration/required_field_validator/plain_old_ruby_object_spec.rb +5 -8
  115. data/spec/integration/required_field_validator/shared_examples.rb +1 -1
  116. data/spec/integration/required_field_validator/spec_helper.rb +6 -67
  117. data/spec/integration/required_field_validator/string_type_value_spec.rb +2 -5
  118. data/spec/integration/required_field_validator/text_type_value_spec.rb +2 -5
  119. data/spec/integration/shared/default_validation_context.rb +13 -0
  120. data/spec/integration/shared/valid_and_invalid_model.rb +27 -0
  121. data/spec/integration/uniqueness_validator/spec_helper.rb +5 -0
  122. data/spec/integration/uniqueness_validator/uniqueness_validator_spec.rb +114 -0
  123. data/spec/integration/within_validator/spec_helper.rb +5 -0
  124. data/spec/integration/within_validator/within_validator_spec.rb +164 -0
  125. data/spec/public/resource_spec.rb +68 -0
  126. data/spec/spec.opts +1 -0
  127. data/spec/spec_helper.rb +12 -4
  128. data/spec/unit/contextual_validators/emptiness_spec.rb +50 -0
  129. data/spec/unit/contextual_validators/execution_spec.rb +55 -0
  130. data/spec/unit/contextual_validators/spec_helper.rb +37 -0
  131. data/spec/unit/generic_validator/equality_operator_spec.rb +26 -0
  132. data/spec/unit/validation_errors/adding_spec.rb +54 -0
  133. data/spec/unit/validation_errors/emptiness_spec.rb +38 -0
  134. data/spec/unit/validation_errors/enumerable_spec.rb +32 -0
  135. data/tasks/install.rb +1 -1
  136. data/tasks/spec.rb +4 -4
  137. metadata +118 -55
  138. data/README.txt +0 -72
  139. data/lib/dm-validations/custom_validator.rb +0 -72
  140. data/lib/dm-validations/length_validator.rb +0 -113
  141. data/lib/dm-validations/method_validator.rb +0 -68
  142. data/lib/dm-validations/numeric_validator.rb +0 -83
  143. data/spec/integration/absent_field_validator_spec.rb +0 -36
  144. data/spec/integration/acceptance_validator_spec.rb +0 -87
  145. data/spec/integration/auto_validate_spec.rb +0 -342
  146. data/spec/integration/block_validator_spec.rb +0 -30
  147. data/spec/integration/confirmation_validator_spec.rb +0 -105
  148. data/spec/integration/contextual_validators_spec.rb +0 -27
  149. data/spec/integration/custom_validator_spec.rb +0 -9
  150. data/spec/integration/format_validator_spec.rb +0 -193
  151. data/spec/integration/generic_validator_spec.rb +0 -17
  152. data/spec/integration/length_validator/valid_objects_spec.rb +0 -13
  153. data/spec/integration/method_validator_spec.rb +0 -58
  154. data/spec/integration/numeric_validator_spec.rb +0 -253
  155. data/spec/integration/primitive_validator_spec.rb +0 -30
  156. data/spec/integration/uniqueness_validator_spec.rb +0 -97
  157. data/spec/integration/validation_errors_spec.rb +0 -18
  158. data/spec/integration/validation_spec.rb +0 -404
  159. data/spec/integration/within_validator_spec.rb +0 -79
@@ -0,0 +1,22 @@
1
+ module DataMapper
2
+ module Validate
3
+ module Fixtures
4
+
5
+ class SmsMessage
6
+ #
7
+ # Behaviors
8
+ #
9
+
10
+ include DataMapper::Resource
11
+
12
+ #
13
+ # Properties
14
+ #
15
+
16
+ property :id, Serial
17
+ property :body, Text, :length => (1..500)
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,49 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module DataMapper
4
+ module Validate
5
+ module Fixtures
6
+
7
+ class UDPPacket
8
+ #
9
+ # Behaviors
10
+ #
11
+
12
+ include DataMapper::Resource
13
+
14
+ #
15
+ # Properties
16
+ #
17
+
18
+ property :id, Serial
19
+
20
+ property :source_port, Integer, :auto_validation => false
21
+ property :destination_port, Integer, :auto_validation => false
22
+
23
+ property :length, Integer, :auto_validation => false
24
+ property :checksum, String, :auto_validation => false
25
+ # consider that there are multiple algorithms
26
+ # available to the app, and it is allowed
27
+ # to be chosed
28
+ #
29
+ # yes, to some degree, this is a made up
30
+ # property ;)
31
+ property :checksum_algorithm, String, :auto_validation => false
32
+ property :data, Text, :auto_validation => false
33
+
34
+ #
35
+ # Volatile attributes
36
+ #
37
+
38
+ attr_accessor :underlying_ip_version
39
+
40
+ #
41
+ # Validations
42
+ #
43
+
44
+ validates_present :checksum_algorithm, :checksum, :if => Proc.new { |packet| packet.underlying_ip_version == 6 }, :message => "Checksum is mandatory when used with IPv6"
45
+ end
46
+
47
+ end # Fixtures
48
+ end # Validate
49
+ end # DataMapper
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+ require 'integration/absent_field_validator/spec_helper'
3
+
4
+ describe DataMapper::Validate::Fixtures::Kayak do
5
+ before :all do
6
+ @kayak = DataMapper::Validate::Fixtures::Kayak.new
7
+ @kayak.should be_valid_for_sale
8
+ end
9
+
10
+ describe "with salesman being non blank" do
11
+ before :all do
12
+ @kayak.salesman = 'Joe'
13
+ end
14
+
15
+ it "is invalid" do
16
+ @kayak.should_not be_valid_for_sale
17
+ end
18
+
19
+ it "has meaningful error message" do
20
+ @kayak.errors.on(:salesman).should == [ 'Salesman must be absent' ]
21
+ end
22
+ end
23
+
24
+
25
+ describe "with salesman being nil" do
26
+ before :all do
27
+ @kayak.salesman = nil
28
+ end
29
+
30
+ it "is valid" do
31
+ @kayak.should be_valid_for_sale
32
+ end
33
+
34
+ it "has no error messages" do
35
+ @kayak.errors.on(:salesman).should be_blank
36
+ end
37
+ end
38
+
39
+
40
+ describe "with salesman being an empty string" do
41
+ before :all do
42
+ @kayak.salesman = ''
43
+ end
44
+
45
+ it "is valid" do
46
+ @kayak.should be_valid_for_sale
47
+ end
48
+
49
+ it "has no error messages" do
50
+ @kayak.errors.on(:salesman).should be_blank
51
+ end
52
+ end
53
+
54
+
55
+ describe "with salesman being a string of white spaces" do
56
+ before :all do
57
+ @kayak.salesman = ' '
58
+ end
59
+
60
+ it "is valid" do
61
+ @kayak.should be_valid_for_sale
62
+ end
63
+
64
+ it "has no error messages" do
65
+ @kayak.errors.on(:salesman).should be_blank
66
+ end
67
+ end
68
+ end
69
+
70
+
71
+ describe DataMapper::Validate::Fixtures::Pirogue do
72
+ before :all do
73
+ @kayak = DataMapper::Validate::Fixtures::Pirogue.new
74
+ @kayak.should_not be_valid_for_sale
75
+ end
76
+
77
+ describe "by default" do
78
+ it "is invalid" do
79
+ @kayak.should_not be_valid_for_sale
80
+ end
81
+
82
+ it "has meaningful error message" do
83
+ @kayak.errors.on(:salesman).should == [ 'Salesman must be absent' ]
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,7 @@
1
+ # put validator specific fixture models and helpers here
2
+ #
3
+ # make sure you check out spec/fixtures to see fixture models
4
+ # already written
5
+ #
6
+ # DataMapper developers feels strongly against foobars in the spec
7
+ # suite
@@ -0,0 +1,196 @@
1
+ require 'spec_helper'
2
+ require 'integration/acceptance_validator/spec_helper'
3
+
4
+ describe DataMapper::Validate::Fixtures::BetaTesterAccount do
5
+ before :each do
6
+ @model = DataMapper::Validate::Fixtures::BetaTesterAccount.new(:user_agreement => true,
7
+ :newsletter_signup => "",
8
+ :privacy_agreement => "accept")
9
+ @model.should be_valid
10
+ end
11
+
12
+ describe "with a missing newsletter signup field" do
13
+ before :each do
14
+ @model.newsletter_signup = nil
15
+ end
16
+
17
+ it "is perfectly valid" do
18
+ @model.should be_valid
19
+ end
20
+ end
21
+
22
+ describe "with a blank newsletter signup field" do
23
+ before :each do
24
+ @model.newsletter_signup = ""
25
+ end
26
+
27
+ it "is perfectly valid" do
28
+ @model.should be_valid
29
+ end
30
+ end
31
+
32
+
33
+ describe "with a blank user agreement field" do
34
+ before :each do
35
+ @model.user_agreement = ""
36
+ end
37
+
38
+ it "is NOT valid" do
39
+ @model.should_not be_valid
40
+ end
41
+ end
42
+
43
+
44
+ describe "with a nil user agreement field" do
45
+ before :each do
46
+ @model.user_agreement = nil
47
+ end
48
+
49
+ it "is NOT valid" do
50
+ @model.should_not be_valid
51
+ end
52
+ end
53
+
54
+
55
+ describe "with user agreement field having value of 1 (as integer)" do
56
+ before :each do
57
+ @model.user_agreement = 1
58
+ end
59
+
60
+ it "is valid" do
61
+ @model.should be_valid
62
+ end
63
+ end
64
+
65
+
66
+ describe "with user agreement field having value of 1 (as a string)" do
67
+ before :each do
68
+ @model.user_agreement = "1"
69
+ end
70
+
71
+ it "is valid" do
72
+ @model.should be_valid
73
+ end
74
+ end
75
+
76
+
77
+ describe "with user agreement field having value of 'true' (as a string)" do
78
+ before :each do
79
+ @model.user_agreement = 'true'
80
+ end
81
+
82
+ it "is valid" do
83
+ @model.should be_valid
84
+ end
85
+ end
86
+
87
+
88
+ describe "with user agreement field having value of true (TrueClass instance)" do
89
+ before :each do
90
+ @model.user_agreement = true
91
+ end
92
+
93
+ it "is valid" do
94
+ @model.should be_valid
95
+ end
96
+ end
97
+
98
+
99
+ describe "with user agreement field having value of 't' (The Lisp Way)" do
100
+ before :each do
101
+ @model.user_agreement = 't'
102
+ end
103
+
104
+ it "is valid" do
105
+ @model.should be_valid
106
+ end
107
+ end
108
+
109
+
110
+ describe "with user agreement field having value of 'f'" do
111
+ before :each do
112
+ @model.user_agreement = 'f'
113
+ end
114
+
115
+ it "is NOT valid" do
116
+ @model.should_not be_valid
117
+ end
118
+ end
119
+
120
+
121
+ describe "with privacy agreement field having value of 1" do
122
+ before :each do
123
+ @model.privacy_agreement = 1
124
+ end
125
+
126
+ it "is NOT valid" do
127
+ @model.should_not be_valid
128
+ end
129
+ end
130
+
131
+ describe "with privacy agreement field having value of true" do
132
+ before :each do
133
+ @model.privacy_agreement = true
134
+ end
135
+
136
+ it "is NOT valid" do
137
+ @model.should_not be_valid
138
+ end
139
+ end
140
+
141
+
142
+ describe "with privacy agreement field having value of '1'" do
143
+ before :each do
144
+ @model.privacy_agreement = '1'
145
+ end
146
+
147
+ it "is NOT valid" do
148
+ @model.should_not be_valid
149
+ end
150
+ end
151
+
152
+
153
+ describe "with privacy agreement field having value of 't'" do
154
+ before :each do
155
+ @model.privacy_agreement = 't'
156
+ end
157
+
158
+ it "is NOT valid" do
159
+ @model.should_not be_valid
160
+ end
161
+ end
162
+
163
+
164
+ describe "with privacy agreement field having value of 'accept'" do
165
+ before :each do
166
+ @model.privacy_agreement = 'accept'
167
+ end
168
+
169
+ it "is valid" do
170
+ @model.should be_valid
171
+ end
172
+ end
173
+
174
+
175
+ describe "with privacy agreement field having value of 'agreed'" do
176
+ before :each do
177
+ @model.privacy_agreement = 'agreed'
178
+ end
179
+
180
+ it "is valid" do
181
+ @model.should be_valid
182
+ end
183
+ end
184
+
185
+
186
+ describe "with privacy agreement field having value of 'ah, greed'" do
187
+ before :each do
188
+ @model.privacy_agreement = 'ah, greed'
189
+ end
190
+
191
+ it "is NOT valid" do
192
+ # greed is invalid? can't be
193
+ @model.should_not be_valid
194
+ end
195
+ end
196
+ end # describe DataMapper::Validate::Fixtures::BetaTesterAccount do
@@ -0,0 +1,7 @@
1
+ # put validator specific fixture models and helpers here
2
+ #
3
+ # make sure you check out spec/fixtures to see fixture models
4
+ # already written
5
+ #
6
+ # DataMapper developers feels strongly against foobars in the spec
7
+ # suite
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require 'integration/automatic_validation/spec_helper'
3
+
4
+ describe 'Inferred validations' do
5
+ it "allow overriding a single error message" do
6
+ custom_boat = Class.new do
7
+ include DataMapper::Resource
8
+ property :id, DataMapper::Types::Serial
9
+ property :name, String, :nullable => false, :message => "This boat must have name"
10
+ end
11
+ boat = custom_boat.new
12
+ boat.should_not be_valid
13
+ boat.errors.on(:name).should == [ 'This boat must have name' ]
14
+ end
15
+
16
+ it "should have correct error messages" do
17
+ custom_boat = Class.new do
18
+ include DataMapper::Resource
19
+ property :id, DataMapper::Types::Serial
20
+ property :name, String, :nullable => false, :length => 5..20, :format => /^[a-z]+$/,
21
+ :messages => {
22
+ :presence => "This boat must have name",
23
+ :length => "Name must have at least 4 and at most 20 chars",
24
+ :format => "Please use only small letters"
25
+ }
26
+ end
27
+
28
+ boat = custom_boat.new
29
+ boat.should_not be_valid
30
+ boat.errors.on(:name).should == [ 'This boat must have name' ]
31
+
32
+ boat.name = "%%"
33
+ boat.should_not be_valid
34
+ boat.errors.on(:name).should == [
35
+ 'Name must have at least 4 and at most 20 chars',
36
+ 'Please use only small letters',
37
+ ]
38
+
39
+ boat.name = "%%asd"
40
+ boat.should_not be_valid
41
+ boat.errors.on(:name).should == [ 'Please use only small letters' ]
42
+
43
+ boat.name = "superboat"
44
+ boat.should be_valid
45
+ boat.errors.on(:name).should be_nil
46
+ end
47
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+ require 'integration/automatic_validation/spec_helper'
3
+
4
+ describe "A class with inferred validations disabled for all properties with an option" do
5
+ before :all do
6
+ @klass = Class.new do
7
+ include DataMapper::Resource
8
+
9
+ property :id, DataMapper::Types::Serial, :auto_validation => false
10
+ property :name, String, :nullable => false, :auto_validation => false
11
+ property :bool, DataMapper::Types::Boolean, :nullable => false, :auto_validation => false
12
+ end
13
+
14
+ @model = @klass.new
15
+ end
16
+
17
+ describe "when instantiated w/o any attributes" do
18
+ it_should_behave_like "valid model"
19
+ end
20
+ end
21
+
22
+
23
+ describe "A class with inferred validations disabled for all properties with a block" do
24
+ before :all do
25
+ @klass = Class.new do
26
+ include DataMapper::Resource
27
+
28
+ without_auto_validations do
29
+ property :id, DataMapper::Types::Serial
30
+ property :name, String, :nullable => false
31
+ property :bool, DataMapper::Types::Boolean, :nullable => false
32
+ end
33
+ end
34
+
35
+ @model = @klass.new
36
+ end
37
+
38
+ describe "when instantiated w/o any attributes" do
39
+ it_should_behave_like "valid model"
40
+ end
41
+ end