dm-validations 0.10.2 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +36 -0
- data/Gemfile +143 -0
- data/README.rdoc +52 -102
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/dm-validations.gemspec +126 -14
- data/lib/dm-validations.rb +78 -18
- data/lib/dm-validations/auto_validate.rb +27 -23
- data/lib/dm-validations/contextual_validators.rb +3 -3
- data/lib/dm-validations/formats/email.rb +3 -3
- data/lib/dm-validations/formats/url.rb +3 -3
- data/lib/dm-validations/support/context.rb +1 -1
- data/lib/dm-validations/validation_errors.rb +5 -7
- data/lib/dm-validations/validators/absent_field_validator.rb +13 -9
- data/lib/dm-validations/validators/acceptance_validator.rb +10 -7
- data/lib/dm-validations/validators/block_validator.rb +3 -3
- data/lib/dm-validations/validators/confirmation_validator.rb +10 -7
- data/lib/dm-validations/validators/format_validator.rb +14 -10
- data/lib/dm-validations/validators/generic_validator.rb +3 -3
- data/lib/dm-validations/validators/length_validator.rb +10 -7
- data/lib/dm-validations/validators/method_validator.rb +3 -3
- data/lib/dm-validations/validators/numeric_validator.rb +25 -14
- data/lib/dm-validations/validators/primitive_validator.rb +12 -8
- data/lib/dm-validations/validators/required_field_validator.rb +12 -9
- data/lib/dm-validations/validators/uniqueness_validator.rb +9 -6
- data/lib/dm-validations/validators/within_validator.rb +3 -3
- data/spec/fixtures/barcode.rb +10 -2
- data/spec/fixtures/basketball_court.rb +7 -7
- data/spec/fixtures/basketball_player.rb +3 -3
- data/spec/fixtures/beta_tester_account.rb +4 -4
- data/spec/fixtures/bill_of_landing.rb +7 -7
- data/spec/fixtures/boat_dock.rb +2 -2
- data/spec/fixtures/city.rb +1 -1
- data/spec/fixtures/company.rb +7 -7
- data/spec/fixtures/corporate_world.rb +24 -26
- data/spec/fixtures/country.rb +1 -1
- data/spec/fixtures/currency.rb +4 -4
- data/spec/fixtures/ethernet_frame.rb +5 -5
- data/spec/fixtures/event.rb +2 -2
- data/spec/fixtures/g3_concert.rb +3 -3
- data/spec/fixtures/jabberwock.rb +2 -2
- data/spec/fixtures/kayak.rb +2 -2
- data/spec/fixtures/lernean_hydra.rb +3 -3
- data/spec/fixtures/mathematical_function.rb +2 -2
- data/spec/fixtures/memory_object.rb +3 -3
- data/spec/fixtures/mittelschnauzer.rb +3 -3
- data/spec/fixtures/motor_launch.rb +1 -1
- data/spec/fixtures/page.rb +3 -3
- data/spec/fixtures/phone_number.rb +2 -2
- data/spec/fixtures/pirogue.rb +2 -2
- data/spec/fixtures/programming_language.rb +3 -3
- data/spec/fixtures/reservation.rb +5 -5
- data/spec/fixtures/scm_operation.rb +42 -45
- data/spec/fixtures/sms_message.rb +1 -1
- data/spec/fixtures/udp_packet.rb +3 -3
- data/spec/integration/absent_field_validator/absent_field_validator_spec.rb +6 -6
- data/spec/integration/acceptance_validator/acceptance_validator_spec.rb +3 -3
- data/spec/integration/automatic_validation/inferred_length_validation_spec.rb +5 -5
- data/spec/integration/automatic_validation/spec_helper.rb +1 -1
- data/spec/integration/block_validator/block_validator_spec.rb +2 -2
- data/spec/integration/conditional_validation/if_condition_spec.rb +3 -3
- data/spec/integration/confirmation_validator/confirmation_validator_spec.rb +3 -3
- data/spec/integration/datamapper_models/association_validation_spec.rb +5 -5
- data/spec/integration/datamapper_models/inheritance_spec.rb +6 -6
- data/spec/integration/duplicated_validations/duplicated_validations_spec.rb +3 -3
- data/spec/integration/format_validator/email_format_validator_spec.rb +6 -6
- data/spec/integration/format_validator/format_validator_spec.rb +8 -8
- data/spec/integration/format_validator/regexp_validator_spec.rb +4 -4
- data/spec/integration/format_validator/url_format_validator_spec.rb +4 -4
- data/spec/integration/length_validator/default_value_spec.rb +3 -3
- data/spec/integration/length_validator/equality_spec.rb +4 -4
- data/spec/integration/length_validator/error_message_spec.rb +3 -3
- data/spec/integration/length_validator/maximum_spec.rb +3 -3
- data/spec/integration/length_validator/minimum_spec.rb +3 -3
- data/spec/integration/length_validator/range_spec.rb +3 -3
- data/spec/integration/method_validator/method_validator_spec.rb +8 -8
- data/spec/integration/numeric_validator/equality_with_float_type_spec.rb +7 -7
- data/spec/integration/numeric_validator/equality_with_integer_type_spec.rb +5 -5
- data/spec/integration/numeric_validator/float_type_spec.rb +3 -3
- data/spec/integration/numeric_validator/gt_with_float_type_spec.rb +3 -3
- data/spec/integration/numeric_validator/gte_with_float_type_spec.rb +3 -3
- data/spec/integration/numeric_validator/lt_with_float_type_spec.rb +3 -3
- data/spec/integration/numeric_validator/lte_with_float_type_spec.rb +3 -3
- data/spec/integration/primitive_validator/primitive_validator_spec.rb +4 -4
- data/spec/integration/pure_ruby_objects/plain_old_ruby_object_validation_spec.rb +4 -4
- data/spec/integration/required_field_validator/association_spec.rb +19 -51
- data/spec/integration/required_field_validator/boolean_type_value_spec.rb +4 -1
- data/spec/integration/required_field_validator/date_type_value_spec.rb +4 -2
- data/spec/integration/required_field_validator/datetime_type_value_spec.rb +4 -2
- data/spec/integration/required_field_validator/float_type_value_spec.rb +4 -2
- data/spec/integration/required_field_validator/integer_type_value_spec.rb +4 -2
- data/spec/integration/required_field_validator/plain_old_ruby_object_spec.rb +6 -4
- data/spec/integration/required_field_validator/string_type_value_spec.rb +3 -1
- data/spec/integration/required_field_validator/text_type_value_spec.rb +3 -1
- data/spec/integration/shared/valid_and_invalid_model.rb +8 -0
- data/spec/integration/uniqueness_validator/uniqueness_validator_spec.rb +29 -25
- data/spec/integration/within_validator/within_validator_spec.rb +6 -6
- data/spec/public/resource_spec.rb +47 -9
- data/spec/spec_helper.rb +13 -27
- data/spec/unit/contextual_validators/emptiness_spec.rb +4 -4
- data/spec/unit/contextual_validators/execution_spec.rb +6 -6
- data/spec/unit/contextual_validators/spec_helper.rb +3 -3
- data/spec/unit/generic_validator/equality_operator_spec.rb +7 -7
- data/spec/unit/validation_errors/adding_spec.rb +2 -2
- data/spec/unit/validation_errors/emptiness_spec.rb +2 -2
- data/spec/unit/validation_errors/enumerable_spec.rb +2 -2
- data/tasks/local_gemfile.rake +18 -0
- data/tasks/spec.rake +0 -3
- metadata +157 -25
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
module DataMapper
|
4
|
-
module
|
4
|
+
module Validations
|
5
5
|
module Fixtures
|
6
6
|
class MathematicalFunction
|
7
7
|
#
|
@@ -30,5 +30,5 @@ module DataMapper
|
|
30
30
|
validates_within :output, :set => (-n..0), :message => "Negative values or zero only, please"
|
31
31
|
end # MathematicalFunction
|
32
32
|
end # Fixtures
|
33
|
-
end #
|
33
|
+
end # Validations
|
34
34
|
end # DataMapper
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
module DataMapper
|
4
|
-
module
|
4
|
+
module Validations
|
5
5
|
module Fixtures
|
6
6
|
class MemoryObject
|
7
7
|
#
|
@@ -22,8 +22,8 @@ module DataMapper
|
|
22
22
|
# Validations
|
23
23
|
#
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
validates_primitive_type_of :marked
|
26
|
+
validates_primitive_type_of :color
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module DataMapper
|
2
|
-
module
|
2
|
+
module Validations
|
3
3
|
module Fixtures
|
4
4
|
class Mittelschnauzer
|
5
5
|
|
@@ -22,9 +22,9 @@ module DataMapper
|
|
22
22
|
# Validations
|
23
23
|
#
|
24
24
|
|
25
|
-
|
25
|
+
validates_length_of :name, :min => 2, :allow_nil => false
|
26
26
|
|
27
|
-
|
27
|
+
validates_numericality_of :height, :lt => 55.2
|
28
28
|
|
29
29
|
def self.valid_instance
|
30
30
|
new(:name => "Roudolf Wilde", :height => 50.4)
|
data/spec/fixtures/page.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
module DataMapper
|
4
|
-
module
|
4
|
+
module Validations
|
5
5
|
module Fixtures
|
6
6
|
|
7
7
|
# see http://datamapper.lighthouseapp.com/projects/20609/tickets/671
|
@@ -25,8 +25,8 @@ module DataMapper
|
|
25
25
|
|
26
26
|
# duplicates inferred validation for body (caused by
|
27
27
|
# :required => true)
|
28
|
-
|
28
|
+
validates_presence_of :body
|
29
29
|
end
|
30
30
|
end # Fixtures
|
31
|
-
end #
|
31
|
+
end # Validations
|
32
32
|
end # DataMapper
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
module DataMapper
|
4
|
-
module
|
4
|
+
module Validations
|
5
5
|
module Fixtures
|
6
6
|
class PhoneNumber
|
7
7
|
#
|
@@ -24,5 +24,5 @@ module DataMapper
|
|
24
24
|
validates_within :type_of_number, :set => %w(home work cell), :message => "Should be one of: home, cell or work"
|
25
25
|
end # PhoneNumber
|
26
26
|
end # Fixtures
|
27
|
-
end #
|
27
|
+
end # Validations
|
28
28
|
end # DataMapper
|
data/spec/fixtures/pirogue.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
module DataMapper
|
4
|
-
module
|
4
|
+
module Validations
|
5
5
|
module Fixtures
|
6
6
|
class Pirogue
|
7
7
|
#
|
@@ -21,7 +21,7 @@ module DataMapper
|
|
21
21
|
# Validations
|
22
22
|
#
|
23
23
|
|
24
|
-
|
24
|
+
validates_absence_of :salesman, :on => :sale
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
module DataMapper
|
4
|
-
module
|
4
|
+
module Validations
|
5
5
|
module Fixtures
|
6
6
|
# If you think that this particular fixture class
|
7
7
|
# and assumptions made below are full of bullshit
|
@@ -15,7 +15,7 @@ module DataMapper
|
|
15
15
|
# Behaviors
|
16
16
|
#
|
17
17
|
|
18
|
-
include ::DataMapper::
|
18
|
+
include ::DataMapper::Validations
|
19
19
|
|
20
20
|
#
|
21
21
|
# Attributes
|
@@ -79,5 +79,5 @@ module DataMapper
|
|
79
79
|
end
|
80
80
|
end # ProgrammingLanguage
|
81
81
|
end # Fixtures
|
82
|
-
end #
|
82
|
+
end # Validations
|
83
83
|
end # DataMapper
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
module DataMapper
|
4
|
-
module
|
4
|
+
module Validations
|
5
5
|
module Fixtures
|
6
6
|
class Reservation
|
7
7
|
#
|
@@ -28,11 +28,11 @@ module DataMapper
|
|
28
28
|
# Validations
|
29
29
|
#
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
'%s requires confirmation for %s' % [
|
31
|
+
validates_confirmation_of :person_name, :allow_nil => false, :allow_blank => false
|
32
|
+
validates_confirmation_of :number_of_seats, :confirm => :seats_confirmation, :message => Proc.new { |resource, property|
|
33
|
+
'%s requires confirmation for %s' % [ActiveSupport::Inflector.demodulize(resource.model.name), property.name]
|
34
34
|
}
|
35
35
|
end # Reservation
|
36
36
|
end # Fixtures
|
37
|
-
end #
|
37
|
+
end # Validations
|
38
38
|
end # DataMapper
|
@@ -1,59 +1,56 @@
|
|
1
|
-
|
1
|
+
#
|
2
|
+
# SCMs
|
3
|
+
#
|
4
|
+
# This example may look stupid (I am sure it is),
|
5
|
+
# but it is way better than foobars and easier to read/add cases
|
6
|
+
# compared to gardening examples because every software engineer has idea
|
7
|
+
# about SCMs and not every software engineer does gardening often.
|
8
|
+
#
|
9
|
+
|
10
|
+
class ScmOperation
|
11
|
+
include DataMapper::Resource
|
2
12
|
|
3
13
|
#
|
4
|
-
#
|
14
|
+
# Property
|
5
15
|
#
|
6
|
-
# This example may look stupid (I am sure it is),
|
7
|
-
# but it is way better than foobars and easier to read/add cases
|
8
|
-
# compared to gardening examples because every software engineer has idea
|
9
|
-
# about SCMs and not every software engineer does gardening often.
|
10
|
-
#
|
11
|
-
|
12
|
-
class ScmOperation
|
13
|
-
include DataMapper::Resource
|
14
|
-
|
15
|
-
#
|
16
|
-
# Property
|
17
|
-
#
|
18
16
|
|
19
|
-
|
17
|
+
property :id, Serial
|
20
18
|
|
21
|
-
|
22
|
-
|
19
|
+
# operation name
|
20
|
+
property :name, String, :auto_validation => false
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
property :committer_name, String, :auto_validation => false, :default => "Just another Ruby hacker"
|
23
|
+
property :author_name, String, :auto_validation => false, :default => "Just another Ruby hacker"
|
24
|
+
property :network_connection, Boolean, :auto_validation => false
|
25
|
+
property :message, Text, :auto_validation => false
|
26
|
+
property :clean_working_copy, Boolean, :auto_validation => false
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
#
|
29
|
+
# Validations
|
30
|
+
#
|
33
31
|
|
34
|
-
|
35
|
-
|
32
|
+
validates_presence_of :name
|
33
|
+
end
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
class SubversionOperation < ScmOperation
|
36
|
+
#
|
37
|
+
# Validations
|
38
|
+
#
|
41
39
|
|
42
|
-
|
43
|
-
|
40
|
+
validates_presence_of :network_connection, :when => [:committing, :log_viewing]
|
41
|
+
end
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
class GitOperation < ScmOperation
|
44
|
+
#
|
45
|
+
# Validations
|
46
|
+
#
|
49
47
|
|
50
|
-
|
48
|
+
validates_presence_of :author_name, :committer_name, :when => :committing
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
50
|
+
validates_presence_of :message, :when => :committing
|
51
|
+
validates_presence_of :network_connection, :when => [:pushing, :pulling], :message => {
|
52
|
+
:pushing => "though git is advanced, it cannot push without network connectivity",
|
53
|
+
:pulling => "you must have network connectivity to pull from others"
|
54
|
+
}
|
55
|
+
validates_presence_of :clean_working_copy, :when => :pulling
|
59
56
|
end
|
data/spec/fixtures/udp_packet.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
module DataMapper
|
4
|
-
module
|
4
|
+
module Validations
|
5
5
|
module Fixtures
|
6
6
|
|
7
7
|
class UDPPacket
|
@@ -41,9 +41,9 @@ module DataMapper
|
|
41
41
|
# Validations
|
42
42
|
#
|
43
43
|
|
44
|
-
|
44
|
+
validates_presence_of :checksum_algorithm, :checksum, :if => Proc.new { |packet| packet.underlying_ip_version == 6 }, :message => "Checksum is mandatory when used with IPv6"
|
45
45
|
end
|
46
46
|
|
47
47
|
end # Fixtures
|
48
|
-
end #
|
48
|
+
end # Validations
|
49
49
|
end # DataMapper
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'integration/absent_field_validator/spec_helper'
|
3
3
|
|
4
|
-
describe 'DataMapper::
|
4
|
+
describe 'DataMapper::Validations::Fixtures::Kayak' do
|
5
5
|
before :all do
|
6
|
-
DataMapper::
|
6
|
+
DataMapper::Validations::Fixtures::Kayak.auto_migrate!
|
7
7
|
|
8
|
-
@kayak = DataMapper::
|
8
|
+
@kayak = DataMapper::Validations::Fixtures::Kayak.new
|
9
9
|
@kayak.should be_valid_for_sale
|
10
10
|
end
|
11
11
|
|
@@ -70,11 +70,11 @@ describe 'DataMapper::Validate::Fixtures::Kayak' do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
|
73
|
-
describe 'DataMapper::
|
73
|
+
describe 'DataMapper::Validations::Fixtures::Pirogue' do
|
74
74
|
before :all do
|
75
|
-
DataMapper::
|
75
|
+
DataMapper::Validations::Fixtures::Pirogue.auto_migrate!
|
76
76
|
|
77
|
-
@kayak = DataMapper::
|
77
|
+
@kayak = DataMapper::Validations::Fixtures::Pirogue.new
|
78
78
|
@kayak.should_not be_valid_for_sale
|
79
79
|
end
|
80
80
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'integration/acceptance_validator/spec_helper'
|
3
3
|
|
4
|
-
describe 'DataMapper::
|
4
|
+
describe 'DataMapper::Validations::Fixtures::BetaTesterAccount' do
|
5
5
|
before :all do
|
6
|
-
DataMapper::
|
6
|
+
DataMapper::Validations::Fixtures::BetaTesterAccount.auto_migrate!
|
7
7
|
end
|
8
8
|
|
9
9
|
before do
|
10
|
-
@model = DataMapper::
|
10
|
+
@model = DataMapper::Validations::Fixtures::BetaTesterAccount.new(:user_agreement => true,
|
11
11
|
:newsletter_signup => nil,
|
12
12
|
:privacy_agreement => "accept")
|
13
13
|
@model.should be_valid
|
@@ -26,7 +26,7 @@ describe 'SailBoat' do
|
|
26
26
|
@model.description = 'ABCDEFGHIJK' #11
|
27
27
|
end
|
28
28
|
|
29
|
-
#
|
29
|
+
# validates_length_of is inferred from property's :length option
|
30
30
|
it "is invalid" do
|
31
31
|
@model.should_not be_valid_for_length_test_1
|
32
32
|
@model.errors.on(:description).should == [ 'Description must be at most 10 characters long' ]
|
@@ -39,7 +39,7 @@ describe 'SailBoat' do
|
|
39
39
|
@model.description = 'ABCDEFGHI' # 9
|
40
40
|
end
|
41
41
|
|
42
|
-
#
|
42
|
+
# validates_length_of is inferred from property's :length option
|
43
43
|
it_should_behave_like "valid model"
|
44
44
|
end
|
45
45
|
|
@@ -80,11 +80,11 @@ end
|
|
80
80
|
|
81
81
|
|
82
82
|
|
83
|
-
describe 'DataMapper::
|
83
|
+
describe 'DataMapper::Validations::Fixtures::SmsMessage' do
|
84
84
|
before :all do
|
85
|
-
DataMapper::
|
85
|
+
DataMapper::Validations::Fixtures::SmsMessage.auto_migrate!
|
86
86
|
|
87
|
-
@model = DataMapper::
|
87
|
+
@model = DataMapper::Validations::Fixtures::SmsMessage.new(:id => 10)
|
88
88
|
end
|
89
89
|
|
90
90
|
describe "with 2 character long note" do
|
@@ -35,7 +35,7 @@ class SailBoat
|
|
35
35
|
property :allow_nil, String, :length => 5..10, :required => false, :validates => :nil_test
|
36
36
|
property :build_date, Date, :validates => :primitive_test
|
37
37
|
property :float, Float, :precision => 2, :scale => 1
|
38
|
-
property :big_decimal,
|
38
|
+
property :big_decimal, Decimal, :precision => 2, :scale => 1
|
39
39
|
|
40
40
|
include TypecastBypassSetter
|
41
41
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'integration/block_validator/spec_helper'
|
3
3
|
|
4
|
-
describe 'DataMapper::
|
4
|
+
describe 'DataMapper::Validations::Fixtures::G3Concert' do
|
5
5
|
before :all do
|
6
|
-
@model = DataMapper::
|
6
|
+
@model = DataMapper::Validations::Fixtures::G3Concert.new(:year => 2004, :participants => "Joe Satriani, Steve Vai, Yngwie Malmsteen", :city => "Denver")
|
7
7
|
@model.should be_valid
|
8
8
|
end
|
9
9
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'integration/conditional_validation/spec_helper'
|
3
3
|
|
4
|
-
describe 'DataMapper::
|
4
|
+
describe 'DataMapper::Validations::Fixtures::UDPPacket' do
|
5
5
|
before :all do
|
6
|
-
DataMapper::
|
6
|
+
DataMapper::Validations::Fixtures::UDPPacket.auto_migrate!
|
7
7
|
|
8
|
-
@model = DataMapper::
|
8
|
+
@model = DataMapper::Validations::Fixtures::UDPPacket.new
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "that is transported encapsulated into IPv4 packet" do
|
@@ -15,11 +15,11 @@ describe "reservation with mismatched seats number", :shared => true do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
|
18
|
-
describe 'DataMapper::
|
18
|
+
describe 'DataMapper::Validations::Fixtures::Reservation' do
|
19
19
|
before :all do
|
20
|
-
DataMapper::
|
20
|
+
DataMapper::Validations::Fixtures::Reservation.auto_migrate!
|
21
21
|
|
22
|
-
@model = DataMapper::
|
22
|
+
@model = DataMapper::Validations::Fixtures::Reservation.new(:person_name => "Tyler Durden",
|
23
23
|
:person_name_confirmation => "Tyler Durden",
|
24
24
|
:number_of_seats => 2,
|
25
25
|
:seats_confirmation => 2)
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'DataMapper::
|
3
|
+
describe 'DataMapper::Validations::Fixtures::Product' do
|
4
4
|
before :all do
|
5
|
-
DataMapper::
|
6
|
-
DataMapper::
|
5
|
+
DataMapper::Validations::Fixtures::ProductCompany.auto_migrate!
|
6
|
+
DataMapper::Validations::Fixtures::Product.auto_migrate!
|
7
7
|
|
8
|
-
@parent = DataMapper::
|
8
|
+
@parent = DataMapper::Validations::Fixtures::ProductCompany.create(:title => "Apple", :flagship_product => "Macintosh")
|
9
9
|
@parent.should be_valid
|
10
10
|
|
11
|
-
@model = DataMapper::
|
11
|
+
@model = DataMapper::Validations::Fixtures::Product.new(:name => "MacBook Pro", :company => @parent)
|
12
12
|
@model.should be_valid
|
13
13
|
end
|
14
14
|
|