veneer 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/..gemspec +21 -0
- data/.gitignore +2 -5
- data/Gemfile +4 -0
- data/README.md +171 -0
- data/Rakefile +3 -36
- data/lib/..rb +3 -0
- data/lib/veneer/adapters/active_record.rb +1 -1
- data/lib/veneer/adapters/activerecord/class_wrapper.rb +11 -79
- data/lib/veneer/adapters/activerecord/instance_wrapper.rb +3 -11
- data/lib/veneer/adapters/activerecord/pre_3.0_class_wrapper.rb +24 -0
- data/lib/veneer/adapters/activerecord/pre_3.0_instance_wrapper.rb +15 -0
- data/lib/veneer/adapters/activerecord.rb +9 -2
- data/lib/veneer/adapters/data_mapper.rb +1 -1
- data/lib/veneer/adapters/datamapper/class_wrapper.rb +29 -50
- data/lib/veneer/adapters/datamapper/instance_wrapper.rb +3 -14
- data/lib/veneer/adapters/mongomapper/class_wrapper.rb +2 -56
- data/lib/veneer/adapters/mongomapper.rb +2 -2
- data/lib/veneer/base/class_wrapper.rb +46 -11
- data/lib/veneer/base/instance_wrapper.rb +12 -14
- data/lib/veneer/core_ext/kernel.rb +0 -1
- data/lib/veneer/errors.rb +0 -1
- data/lib/veneer/lint.rb +183 -0
- data/lib/veneer/version.rb +3 -0
- data/lib/veneer.rb +1 -4
- data/test/test_helper.rb +4 -3
- data/test/veneer/adapters/{active_record/active_record_setup.rb → test_active_record.rb} +23 -1
- data/test/veneer/adapters/test_datamapper.rb +56 -0
- data/test/veneer/adapters/test_mongomapper.rb +49 -0
- data/test/veneer/proxy_test.rb +20 -45
- data/veneer.gemspec +15 -108
- metadata +40 -60
- data/README.textile +0 -142
- data/VERSION +0 -1
- data/datamapper_setup.rb +0 -2
- data/lib/veneer/base/conditional.rb +0 -77
- data/test/macros/class_wrapper/create_macro.rb +0 -54
- data/test/macros/class_wrapper/delete_macro.rb +0 -31
- data/test/macros/class_wrapper/find_macro.rb +0 -119
- data/test/macros/class_wrapper/hooks.rb +0 -41
- data/test/macros/class_wrapper/validations.rb +0 -91
- data/test/macros/instance_wrapper/destroy_macro.rb +0 -36
- data/test/macros/instance_wrapper/new_record_macro.rb +0 -39
- data/test/macros/instance_wrapper/save_macro.rb +0 -55
- data/test/macros/veneer_constants_interface.rb +0 -26
- data/test/support/before_save_mixin.rb +0 -14
- data/test/support/valiations_method_method.rb +0 -0
- data/test/veneer/adapters/active_record/class_wrapper_test.rb +0 -23
- data/test/veneer/adapters/active_record/instance_wrapper_test.rb +0 -21
- data/test/veneer/adapters/datamapper/class_wrapper_test.rb +0 -24
- data/test/veneer/adapters/datamapper/datamapper_setup.rb +0 -34
- data/test/veneer/adapters/datamapper/instance_wrapper_test.rb +0 -21
- data/test/veneer/adapters/mongomapper/class_wrapper_test.rb +0 -24
- data/test/veneer/adapters/mongomapper/instance_wrapper_test.rb +0 -21
- data/test/veneer/adapters/mongomapper/mongomapper_setup.rb +0 -25
- data/test/veneer/base/conditonal_test.rb +0 -118
@@ -1,119 +0,0 @@
|
|
1
|
-
class Test::Unit::TestCase
|
2
|
-
def self.veneer_should_implement_find
|
3
|
-
context "implements find" do
|
4
|
-
setup do
|
5
|
-
Veneer(@klass).destroy_all
|
6
|
-
(0..5).each do |i|
|
7
|
-
Veneer(@klass).new(:order_field1 => i).save!
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
teardown{ Veneer(@klass).destroy_all }
|
12
|
-
|
13
|
-
should "impelement a find_all method" do
|
14
|
-
result = Veneer(@klass).find_many(Veneer::Conditional.from_hash({}))
|
15
|
-
assert_kind_of Array, result
|
16
|
-
end
|
17
|
-
|
18
|
-
should "implement a find_first method" do
|
19
|
-
result = Veneer(@klass).find_first(Veneer::Conditional.from_hash({}))
|
20
|
-
end
|
21
|
-
|
22
|
-
should "implement limit" do
|
23
|
-
total = Veneer(@klass).find_many(Veneer::Conditional.from_hash({}))
|
24
|
-
assert_not_equal 3, total.size
|
25
|
-
result = Veneer(@klass).find_many(Veneer::Conditional.from_hash(:limit => 3))
|
26
|
-
assert_equal 3, result.size
|
27
|
-
end
|
28
|
-
|
29
|
-
should "implement order" do
|
30
|
-
result = Veneer(@klass).find_many(Veneer::Conditional.from_hash(:order => "order_field1 asc"))
|
31
|
-
raw = result.map{|i| i.order_field1 }.compact
|
32
|
-
sorted = raw.sort
|
33
|
-
assert_equal raw, sorted
|
34
|
-
end
|
35
|
-
|
36
|
-
should "implement asc and desc order as opposites" do
|
37
|
-
result_asc = Veneer(@klass).find_many(Veneer::Conditional.from_hash(:order => "order_field1 asc")).map{|o| o.order_field1}
|
38
|
-
result_desc = Veneer(@klass).find_many(Veneer::Conditional.from_hash(:order => "order_field1 desc")).map{|o| o.order_field1}
|
39
|
-
|
40
|
-
assert_equal result_asc, result_desc.reverse
|
41
|
-
end
|
42
|
-
|
43
|
-
should "implement order decending" do
|
44
|
-
result = Veneer(@klass).find_many(Veneer::Conditional.from_hash(:order => "order_field1 desc"))
|
45
|
-
raw = result.map{|i| i.order_field1 }.compact
|
46
|
-
sorted = raw.sort.reverse
|
47
|
-
assert_equal raw, sorted
|
48
|
-
end
|
49
|
-
|
50
|
-
should "implement order ascending" do
|
51
|
-
result = Veneer(@klass).find_many(Veneer::Conditional.from_hash(:order => "order_field1 asc"))
|
52
|
-
raw = result.map{|i| i.order_field1}.compact
|
53
|
-
sorted = raw.sort
|
54
|
-
assert_equal raw, sorted
|
55
|
-
end
|
56
|
-
|
57
|
-
should "impelment offset" do
|
58
|
-
total = Veneer(@klass).find_many(Veneer::Conditional.from_hash({}))
|
59
|
-
result = Veneer(@klass).find_many(Veneer::Conditional.from_hash({:offset => 2, :limit => 2}))
|
60
|
-
|
61
|
-
assert_equal((total[2..3]), result)
|
62
|
-
end
|
63
|
-
|
64
|
-
context "conditions" do
|
65
|
-
setup do
|
66
|
-
Veneer(@klass).new(:name => "bar").save
|
67
|
-
Veneer(@klass).new(:name => "foo").save
|
68
|
-
Veneer(@klass).new(:name => "foobar").save
|
69
|
-
end
|
70
|
-
|
71
|
-
should "implement basic conditions" do
|
72
|
-
total = Veneer(@klass).find_many(Veneer::Conditional.from_hash({}))
|
73
|
-
result = Veneer(@klass).find_many(Veneer::Conditional.from_hash(:conditions => {:name => "foo"}))
|
74
|
-
assert_equal 1, result.size
|
75
|
-
end
|
76
|
-
|
77
|
-
should "implement :not conditions" do
|
78
|
-
Veneer(@klass).all(:conditions => {:name => nil}).map(&:destroy)
|
79
|
-
total = Veneer(@klass).find_many(Veneer::Conditional.from_hash({}))
|
80
|
-
result = Veneer(@klass).find_many(Veneer::Conditional.from_hash(:conditions => {"name not" => "bar"}))
|
81
|
-
assert_equal((total.size - 1), result.size)
|
82
|
-
end
|
83
|
-
|
84
|
-
should "implement gt conditions" do
|
85
|
-
total = Veneer(@klass).find_many(Veneer::Conditional.from_hash({}))
|
86
|
-
expected = total.select{|i| !i.order_field1.nil? && i.order_field1 > 3}
|
87
|
-
result = Veneer(@klass).find_many(Veneer::Conditional.from_hash(:conditions => {"order_field1 gt" => 3}))
|
88
|
-
assert_equal expected.size, result.size
|
89
|
-
end
|
90
|
-
|
91
|
-
should "implement gte conditions" do
|
92
|
-
total = Veneer(@klass).find_many(Veneer::Conditional.from_hash({}))
|
93
|
-
expected = total.select{|i| !i.order_field1.nil? && i.order_field1 >= 3}.map{|i| i.order_field1}
|
94
|
-
result = Veneer(@klass).find_many(Veneer::Conditional.from_hash(:conditions => {"order_field1 gte" => 3})).map{|o| o.order_field1}
|
95
|
-
assert_equal expected, result
|
96
|
-
end
|
97
|
-
|
98
|
-
should "implement :lt condition" do
|
99
|
-
result = Veneer(@klass).find_many(Veneer::Conditional.from_hash(:conditions => {"order_field1 lt" => 3}))
|
100
|
-
assert_equal 3, result.size
|
101
|
-
end
|
102
|
-
|
103
|
-
should "implement a lte condition" do
|
104
|
-
total = Veneer(@klass).find_many(Veneer::Conditional.from_hash({}))
|
105
|
-
expected = total.select{|i| !i.order_field1.nil? && i.order_field1 <= 3}
|
106
|
-
result = Veneer(@klass).find_many(Veneer::Conditional.from_hash(:conditions => {"order_field1 lte" => 3}))
|
107
|
-
assert_equal expected.size, result.size
|
108
|
-
end
|
109
|
-
|
110
|
-
should "implement an :in condition" do
|
111
|
-
total = Veneer(@klass).find_many(Veneer::Conditional.from_hash({}))
|
112
|
-
expected = total.select{|i| ["foo", "bar"].include?(i.name)}
|
113
|
-
result = Veneer(@klass).find_many(Veneer::Conditional.from_hash(:conditions => {"name in" => ["foo", "bar"]}))
|
114
|
-
assert_equal expected.size, result.size
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
class Test::Unit::TestCase
|
2
|
-
def self.veneer_should_implement_before_save_hooks
|
3
|
-
context "impelements before_save" do
|
4
|
-
should "setup the test correctly" do
|
5
|
-
assert_not_nil @klass
|
6
|
-
assert_kind_of Class, @klass
|
7
|
-
assert_not_nil @valid_attributes
|
8
|
-
assert_kind_of Hash, @valid_attributes
|
9
|
-
end
|
10
|
-
|
11
|
-
context "before_save" do
|
12
|
-
setup do
|
13
|
-
$captures = []
|
14
|
-
Veneer(@klass).before_save :check_before_save
|
15
|
-
@klass.class_eval do
|
16
|
-
include Veneer::Test::BeforeSaveSetup
|
17
|
-
end unless Veneer::Test::BeforeSaveSetup > @klass
|
18
|
-
end
|
19
|
-
|
20
|
-
teardown{ $captures = [] }
|
21
|
-
|
22
|
-
should "run the before save block" do
|
23
|
-
Veneer(@klass).new(@valid_attributes).save
|
24
|
-
assert_contains $captures, :check_before_save
|
25
|
-
end
|
26
|
-
|
27
|
-
should "allow me to raise inside the before save without propergating the issue further" do
|
28
|
-
assert_nothing_raised do
|
29
|
-
Veneer(@klass).new(@valid_attributes.merge(:name => "raise_on_before_save")).save
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
should "allow me to save! with an invalid before_save hook and do the right thing" do
|
34
|
-
assert_raise(::Veneer::Errors::NotSaved) do
|
35
|
-
Veneer(@klass).new(@valid_attributes.merge(:name => "raise_on_before_save")).save!
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
class Test::Unit::TestCase
|
2
|
-
def self.veneer_should_implement_validations
|
3
|
-
context "implements validations" do
|
4
|
-
setup do
|
5
|
-
Veneer(@klass).destroy_all
|
6
|
-
end
|
7
|
-
|
8
|
-
should "setup the test correctly" do
|
9
|
-
assert_not_nil @klass
|
10
|
-
assert_kind_of Class, @klass
|
11
|
-
assert_not_nil @valid_attributes
|
12
|
-
assert_kind_of Hash, @valid_attributes
|
13
|
-
assert_not_nil @valid_attributes[:name]
|
14
|
-
end
|
15
|
-
|
16
|
-
context "validates_presence_of" do
|
17
|
-
setup do
|
18
|
-
key = [@klass, :validates_presence_of, :name]
|
19
|
-
unless $validations.include?(key)
|
20
|
-
Veneer(@klass).validates_presence_of(:name)
|
21
|
-
$validations << key
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
should "allow addition of a validation for presence_of" do
|
26
|
-
attr = @valid_attributes.dup
|
27
|
-
attr.delete(:name)
|
28
|
-
k = Veneer(@klass).new(attr)
|
29
|
-
assert_false k.valid?
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context "validates_uniqueness_of" do
|
34
|
-
setup do
|
35
|
-
key = [@klass, :validates_uniqueness_of, :name]
|
36
|
-
unless $validations.include?(key)
|
37
|
-
Veneer(@klass).validates_uniqueness_of(:name)
|
38
|
-
$validations << key
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
should "not allow duplicate data" do
|
43
|
-
k = Veneer(@klass).new(@valid_attributes)
|
44
|
-
assert_true k.save
|
45
|
-
k2 = Veneer(@klass).new(@valid_attributes)
|
46
|
-
assert_false k2.valid?
|
47
|
-
end
|
48
|
-
|
49
|
-
# TODO: Get some introspection of validations happening
|
50
|
-
should "allow_non duplicate data" do
|
51
|
-
k = Veneer(@klass).new(@valid_attributes)
|
52
|
-
assert_true k.save
|
53
|
-
k2 = Veneer(@klass).new(@valid_attributes.merge(:name => "not a duplicate"))
|
54
|
-
assert_true k2.save
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context "validates_confirmation_of" do
|
59
|
-
setup do
|
60
|
-
key = [@klass, :validates_confirmation_of, :password]
|
61
|
-
unless $validations.include?(key)
|
62
|
-
Veneer(@klass).validates_confirmation_of(:password)
|
63
|
-
$validations << key
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
should "be invalid without confirmation" do
|
68
|
-
k = Veneer(@klass).new(@valid_attributes)
|
69
|
-
k.password_confirmation = "Not Confirmed"
|
70
|
-
assert_false k.valid?
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context "validates_with_method" do
|
75
|
-
setup do
|
76
|
-
key = [@klass, :validates_with_method, :v_with_m_test]
|
77
|
-
unless $validations.include?(key)
|
78
|
-
Veneer(@klass).validates_with_method(:v_with_m_test)
|
79
|
-
$validations << key
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
should "be invalid with an invalid through v_with_m_test" do
|
84
|
-
k = Veneer(@klass).new(@valid_attributes)
|
85
|
-
k.name = "v_with_m_test"
|
86
|
-
assert_false k.valid?
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
class Test::Unit::TestCase
|
2
|
-
def self.veneer_should_implement_destroy
|
3
|
-
context "on an instance" do
|
4
|
-
should "setup the test correctly" do
|
5
|
-
assert_not_nil @klass
|
6
|
-
assert_kind_of Class, @klass
|
7
|
-
assert_not_nil @valid_attributes
|
8
|
-
assert_kind_of Hash, @valid_attributes
|
9
|
-
end
|
10
|
-
|
11
|
-
setup do
|
12
|
-
Veneer(@klass).destroy_all
|
13
|
-
@valid = Veneer(@klass).new(@valid_attributes)
|
14
|
-
end
|
15
|
-
|
16
|
-
should "setup the spec" do
|
17
|
-
assert @valid.save
|
18
|
-
r = Veneer(@klass).first(:conditions => {:name => @valid.instance.name})
|
19
|
-
assert_equal @valid, r
|
20
|
-
end
|
21
|
-
|
22
|
-
should "destroy the object" do
|
23
|
-
@valid.save
|
24
|
-
v = @valid
|
25
|
-
assert_equal v, @valid.destroy
|
26
|
-
end
|
27
|
-
|
28
|
-
should "remove the object from the collection" do
|
29
|
-
@valid.save
|
30
|
-
assert_equal @valid, Veneer(@klass).first(:conditions => {:name => @valid.name})
|
31
|
-
@valid.destroy
|
32
|
-
assert_nil Veneer(@klass).first(:conditions => {:name => @valid.name})
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
class Test::Unit::TestCase
|
2
|
-
def self.veneer_should_implement_new_record?
|
3
|
-
context "on an instance" do
|
4
|
-
setup do
|
5
|
-
Veneer(@klass).destroy_all
|
6
|
-
end
|
7
|
-
|
8
|
-
should "setup the test correctly" do
|
9
|
-
assert_not_nil @klass
|
10
|
-
assert_kind_of Class, @klass
|
11
|
-
assert_not_nil @valid_attributes
|
12
|
-
assert_kind_of Hash, @valid_attributes
|
13
|
-
assert_kind_of Hash, @invalid_attributes
|
14
|
-
end
|
15
|
-
|
16
|
-
setup do
|
17
|
-
@instance = Veneer(@klass).new(@valid_attributes)
|
18
|
-
end
|
19
|
-
|
20
|
-
context "new_record" do
|
21
|
-
should "return true when the record is new" do
|
22
|
-
assert @instance.new_record?
|
23
|
-
end
|
24
|
-
|
25
|
-
should "return false when the record is successfully saved" do
|
26
|
-
assert @instance.save
|
27
|
-
assert !@instance.new_record?
|
28
|
-
end
|
29
|
-
|
30
|
-
should "return true if the record cannot be saved" do
|
31
|
-
v = Veneer(@klass).new(@invalid_attributes)
|
32
|
-
assert v.new_record?
|
33
|
-
assert !v.save
|
34
|
-
assert v.new_record?
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
class Test::Unit::TestCase
|
2
|
-
def self.veneer_should_implement_save
|
3
|
-
context "on an instance" do
|
4
|
-
should "setup the test correctly" do
|
5
|
-
assert_not_nil @klass
|
6
|
-
assert_kind_of Class, @klass
|
7
|
-
assert_not_nil @valid_attributes
|
8
|
-
assert_kind_of Hash, @valid_attributes
|
9
|
-
assert_kind_of Hash, @invalid_attributes
|
10
|
-
end
|
11
|
-
|
12
|
-
setup do
|
13
|
-
@invalid = Veneer(@klass).new(@invalid_attributes)
|
14
|
-
@valid = Veneer(@klass).new(@valid_attributes)
|
15
|
-
end
|
16
|
-
|
17
|
-
context "save" do
|
18
|
-
should "return true when it can save" do
|
19
|
-
assert @valid.save
|
20
|
-
end
|
21
|
-
|
22
|
-
should "return false when it can't save" do
|
23
|
-
assert !@invalid.save
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.veneer_should_implement_save!
|
30
|
-
context "save!" do
|
31
|
-
should "setup the test correctly" do
|
32
|
-
assert_not_nil @klass
|
33
|
-
assert_kind_of Class, @klass
|
34
|
-
assert_not_nil @valid_attributes
|
35
|
-
assert_kind_of Hash, @valid_attributes
|
36
|
-
assert_kind_of Hash, @invalid_attributes
|
37
|
-
end
|
38
|
-
|
39
|
-
setup do
|
40
|
-
@invalid = Veneer(@klass).new(@invalid_attributes)
|
41
|
-
@valid = Veneer(@klass).new(@valid_attributes)
|
42
|
-
end
|
43
|
-
|
44
|
-
should "return true when successful" do
|
45
|
-
assert @valid.save!
|
46
|
-
end
|
47
|
-
|
48
|
-
should "raise Veneer::Errors::NotSaved when fails to save!" do
|
49
|
-
assert_raises Veneer::Errors::NotSaved do
|
50
|
-
@invalid.save!
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
class Test::Unit::TestCase
|
2
|
-
def self.veneer_should_have_the_required_veneer_constants
|
3
|
-
context "required constants" do
|
4
|
-
|
5
|
-
should "have correctly setup the spec" do
|
6
|
-
assert_kind_of Class, @klass
|
7
|
-
end
|
8
|
-
|
9
|
-
should "have a VeneerInterface constant" do
|
10
|
-
assert_nothing_raised do
|
11
|
-
@klass::VeneerInterface
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
should "have a VeneerInterface::ClassWrapper" do
|
16
|
-
assert_nothing_raised do
|
17
|
-
@klass::VeneerInterface::ClassWrapper
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
should "inherit the class wrapper from the base class wrapper" do
|
22
|
-
assert_contains @klass::VeneerInterface::ClassWrapper.ancestors, ::Veneer::Base::ClassWrapper
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Veneer
|
2
|
-
module Test
|
3
|
-
module BeforeSaveSetup
|
4
|
-
def check_before_save
|
5
|
-
$captures << :check_before_save
|
6
|
-
if name == "raise_on_before_save"
|
7
|
-
raise Veneer::Errors::BeforeSaveError, [:name, "cannot be raise_on_before_save"]
|
8
|
-
else
|
9
|
-
true
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
File without changes
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "..", "..", "test_helper")
|
2
|
-
require File.join(File.dirname(__FILE__), "active_record_setup")
|
3
|
-
|
4
|
-
module Veneer
|
5
|
-
module Test
|
6
|
-
class ActiveRecordClassWrapper < ::Test::Unit::TestCase
|
7
|
-
context "Active Record Veneer Adapter" do
|
8
|
-
setup do
|
9
|
-
@klass = ::ActiveRecordFoo
|
10
|
-
@valid_attributes = {:name => "foo", :password => "pass", :password_confirmation => "pass"}
|
11
|
-
@invalid_attributes = @valid_attributes.dup.merge(:name => "invalid")
|
12
|
-
end
|
13
|
-
veneer_should_have_the_required_veneer_constants
|
14
|
-
veneer_should_implement_create_with_valid_attributes
|
15
|
-
veneer_should_impelement_destroy_all
|
16
|
-
veneer_should_implement_create_with_invalid_attributes
|
17
|
-
veneer_should_implement_find
|
18
|
-
veneer_should_implement_before_save_hooks
|
19
|
-
veneer_should_implement_validations
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "..", "..", "test_helper")
|
2
|
-
require File.join(File.dirname(__FILE__), "active_record_setup")
|
3
|
-
|
4
|
-
module Veneer
|
5
|
-
module Test
|
6
|
-
class ActiveRecordInstanceWrapper < ::Test::Unit::TestCase
|
7
|
-
context "Active Record Veneer Adapter" do
|
8
|
-
setup do
|
9
|
-
@klass = ::ActiveRecordFoo
|
10
|
-
@valid_attributes = {:name => "foo", :password => "pass", :password_confirmation => "pass"}
|
11
|
-
@invalid_attributes = @valid_attributes.dup.merge(:name => "invalid")
|
12
|
-
end
|
13
|
-
|
14
|
-
veneer_should_implement_new_record?
|
15
|
-
veneer_should_implement_save
|
16
|
-
veneer_should_implement_save!
|
17
|
-
veneer_should_implement_destroy
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "..", "..", "test_helper")
|
2
|
-
require File.join(File.dirname(__FILE__), "datamapper_setup")
|
3
|
-
|
4
|
-
module Veneer
|
5
|
-
module Test
|
6
|
-
class DataMapperClassWrapper < ::Test::Unit::TestCase
|
7
|
-
context "DataMapper Veneer Adapter" do
|
8
|
-
setup do
|
9
|
-
@klass = DMFoo
|
10
|
-
@valid_attributes = {:name => "foo", :password => "pass", :password_confirmation => "pass"}
|
11
|
-
@invalid_attributes = @valid_attributes.dup.merge(:name => "invalid")
|
12
|
-
end
|
13
|
-
|
14
|
-
veneer_should_have_the_required_veneer_constants
|
15
|
-
veneer_should_implement_create_with_valid_attributes
|
16
|
-
veneer_should_impelement_destroy_all
|
17
|
-
veneer_should_implement_create_with_invalid_attributes
|
18
|
-
veneer_should_implement_find
|
19
|
-
veneer_should_implement_before_save_hooks
|
20
|
-
veneer_should_implement_validations
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'dm-core'
|
2
|
-
require 'dm-validations'
|
3
|
-
require 'veneer/adapters/datamapper'
|
4
|
-
|
5
|
-
DataMapper.setup(:default, 'sqlite3::memory:')
|
6
|
-
|
7
|
-
class DMFoo
|
8
|
-
include DataMapper::Resource
|
9
|
-
attr_accessor :password, :password_confirmation
|
10
|
-
|
11
|
-
property :id, Serial
|
12
|
-
property :name, String
|
13
|
-
property :order_field1, Integer
|
14
|
-
|
15
|
-
validates_with_method :name, :method => :check_name
|
16
|
-
|
17
|
-
def check_name
|
18
|
-
if name == "invalid"
|
19
|
-
[false, "Invalid name"]
|
20
|
-
else
|
21
|
-
true
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def v_with_m_test
|
26
|
-
if name == "v_with_m_test"
|
27
|
-
[false, "name cannot be v_with_m_test"]
|
28
|
-
else
|
29
|
-
true
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
DataMapper.auto_migrate!
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "..", "..", "test_helper")
|
2
|
-
require File.join(File.dirname(__FILE__), "datamapper_setup")
|
3
|
-
|
4
|
-
module Veneer
|
5
|
-
module Test
|
6
|
-
class DataMapperInstanceWrapper < ::Test::Unit::TestCase
|
7
|
-
context "DataMapper Veneer Adapter" do
|
8
|
-
setup do
|
9
|
-
@klass = DMFoo
|
10
|
-
@valid_attributes = {:name => "foo", :password => "pass", :password_confirmation => "pass"}
|
11
|
-
@invalid_attributes = @valid_attributes.dup.merge(:name => "invalid")
|
12
|
-
end
|
13
|
-
|
14
|
-
veneer_should_implement_new_record?
|
15
|
-
veneer_should_implement_save
|
16
|
-
veneer_should_implement_save!
|
17
|
-
veneer_should_implement_destroy
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "..", "..", "test_helper")
|
2
|
-
require ~"./mongomapper_setup"
|
3
|
-
|
4
|
-
module Veneer
|
5
|
-
module Test
|
6
|
-
class MongoMapperClassWrapper < ::Test::Unit::TestCase
|
7
|
-
context "MongoMapper Veneer Adapter" do
|
8
|
-
setup do
|
9
|
-
@klass = MongoFoo
|
10
|
-
@valid_attributes = {:name => "foo", :password => "pass", :password_confirmation => "pass"}
|
11
|
-
@invalid_attributes = @valid_attributes.dup.merge(:name => "invalid")
|
12
|
-
end
|
13
|
-
|
14
|
-
veneer_should_have_the_required_veneer_constants
|
15
|
-
veneer_should_implement_create_with_valid_attributes
|
16
|
-
veneer_should_impelement_destroy_all
|
17
|
-
veneer_should_implement_create_with_invalid_attributes
|
18
|
-
veneer_should_implement_find
|
19
|
-
veneer_should_implement_before_save_hooks
|
20
|
-
veneer_should_implement_validations
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "..", "..", "test_helper")
|
2
|
-
require File.join(File.dirname(__FILE__), "mongomapper_setup")
|
3
|
-
|
4
|
-
module Veneer
|
5
|
-
module Test
|
6
|
-
class MongoMapperInstanceWrapper < ::Test::Unit::TestCase
|
7
|
-
context "MongoMapper Veneer Adapter" do
|
8
|
-
setup do
|
9
|
-
@klass = MongoFoo
|
10
|
-
@valid_attributes = {:name => "foo", :password => "pass", :password_confirmation => "pass"}
|
11
|
-
@invalid_attributes = @valid_attributes.dup.merge(:name => "invalid")
|
12
|
-
end
|
13
|
-
|
14
|
-
veneer_should_implement_new_record?
|
15
|
-
veneer_should_implement_save
|
16
|
-
veneer_should_implement_save!
|
17
|
-
veneer_should_implement_destroy
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'mongomapper'
|
2
|
-
|
3
|
-
require 'veneer/adapters/mongomapper'
|
4
|
-
|
5
|
-
MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017)
|
6
|
-
MongoMapper.database = 'veneer_test'
|
7
|
-
|
8
|
-
class MongoFoo
|
9
|
-
include MongoMapper::Document
|
10
|
-
attr_accessor :password, :password_confirmation
|
11
|
-
|
12
|
-
key :name, String
|
13
|
-
key :order_field1, Integer
|
14
|
-
|
15
|
-
validate_on_create :check_name
|
16
|
-
|
17
|
-
def check_name
|
18
|
-
errors.add(:name, "may not be invalid") if name == "invalid"
|
19
|
-
end
|
20
|
-
|
21
|
-
def v_with_m_test
|
22
|
-
errors.add(:name, "may not be v_with_m_test") if name == "v_with_m_test"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|