veneer 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/..gemspec +21 -0
  2. data/.gitignore +2 -5
  3. data/Gemfile +4 -0
  4. data/README.md +171 -0
  5. data/Rakefile +3 -36
  6. data/lib/..rb +3 -0
  7. data/lib/veneer/adapters/active_record.rb +1 -1
  8. data/lib/veneer/adapters/activerecord/class_wrapper.rb +11 -79
  9. data/lib/veneer/adapters/activerecord/instance_wrapper.rb +3 -11
  10. data/lib/veneer/adapters/activerecord/pre_3.0_class_wrapper.rb +24 -0
  11. data/lib/veneer/adapters/activerecord/pre_3.0_instance_wrapper.rb +15 -0
  12. data/lib/veneer/adapters/activerecord.rb +9 -2
  13. data/lib/veneer/adapters/data_mapper.rb +1 -1
  14. data/lib/veneer/adapters/datamapper/class_wrapper.rb +29 -50
  15. data/lib/veneer/adapters/datamapper/instance_wrapper.rb +3 -14
  16. data/lib/veneer/adapters/mongomapper/class_wrapper.rb +2 -56
  17. data/lib/veneer/adapters/mongomapper.rb +2 -2
  18. data/lib/veneer/base/class_wrapper.rb +46 -11
  19. data/lib/veneer/base/instance_wrapper.rb +12 -14
  20. data/lib/veneer/core_ext/kernel.rb +0 -1
  21. data/lib/veneer/errors.rb +0 -1
  22. data/lib/veneer/lint.rb +183 -0
  23. data/lib/veneer/version.rb +3 -0
  24. data/lib/veneer.rb +1 -4
  25. data/test/test_helper.rb +4 -3
  26. data/test/veneer/adapters/{active_record/active_record_setup.rb → test_active_record.rb} +23 -1
  27. data/test/veneer/adapters/test_datamapper.rb +56 -0
  28. data/test/veneer/adapters/test_mongomapper.rb +49 -0
  29. data/test/veneer/proxy_test.rb +20 -45
  30. data/veneer.gemspec +15 -108
  31. metadata +40 -60
  32. data/README.textile +0 -142
  33. data/VERSION +0 -1
  34. data/datamapper_setup.rb +0 -2
  35. data/lib/veneer/base/conditional.rb +0 -77
  36. data/test/macros/class_wrapper/create_macro.rb +0 -54
  37. data/test/macros/class_wrapper/delete_macro.rb +0 -31
  38. data/test/macros/class_wrapper/find_macro.rb +0 -119
  39. data/test/macros/class_wrapper/hooks.rb +0 -41
  40. data/test/macros/class_wrapper/validations.rb +0 -91
  41. data/test/macros/instance_wrapper/destroy_macro.rb +0 -36
  42. data/test/macros/instance_wrapper/new_record_macro.rb +0 -39
  43. data/test/macros/instance_wrapper/save_macro.rb +0 -55
  44. data/test/macros/veneer_constants_interface.rb +0 -26
  45. data/test/support/before_save_mixin.rb +0 -14
  46. data/test/support/valiations_method_method.rb +0 -0
  47. data/test/veneer/adapters/active_record/class_wrapper_test.rb +0 -23
  48. data/test/veneer/adapters/active_record/instance_wrapper_test.rb +0 -21
  49. data/test/veneer/adapters/datamapper/class_wrapper_test.rb +0 -24
  50. data/test/veneer/adapters/datamapper/datamapper_setup.rb +0 -34
  51. data/test/veneer/adapters/datamapper/instance_wrapper_test.rb +0 -21
  52. data/test/veneer/adapters/mongomapper/class_wrapper_test.rb +0 -24
  53. data/test/veneer/adapters/mongomapper/instance_wrapper_test.rb +0 -21
  54. data/test/veneer/adapters/mongomapper/mongomapper_setup.rb +0 -25
  55. data/test/veneer/base/conditonal_test.rb +0 -118
@@ -1,118 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
2
-
3
- class VeneerBaseConditionalTest < Test::Unit::TestCase
4
- context "Conditional from hash" do
5
- should "create a conditonal object from a blank hash" do
6
- c = Veneer::Conditional.from_hash({})
7
- assert_instance_of Veneer::Conditional, c
8
- end
9
-
10
- should "create a conditional with a limit" do
11
- c = Veneer::Conditional.from_hash(:limit => 5)
12
- assert_equal c.limit, 5
13
- end
14
-
15
- should "have an offset specified" do
16
- c = Veneer::Conditional.from_hash(:offset => 5)
17
- assert_equal c.offset, 5
18
- end
19
-
20
- context "Veneer::Conditional::Order" do
21
- should "let me specify a field" do
22
- c = Veneer::Conditional::Order.new("foo")
23
- assert_equal c.field, :foo
24
- end
25
-
26
- should "be decending in order by default" do
27
- c = Veneer::Conditional::Order.new("foo")
28
- assert_equal :desc, c.direction
29
- end
30
-
31
- should "let me specify an ascending order" do
32
- c = Veneer::Conditional::Order.new("foo", "asc")
33
- assert_equal :asc, c.direction
34
- end
35
-
36
- should "let me specify a decending order" do
37
- ["desc", :desc].each do |dir|
38
- c = Veneer::Conditional::Order.new("foo", dir)
39
- assert_equal :desc, c.direction
40
- end
41
- end
42
- end
43
-
44
- should "have an order specified as an array" do
45
- c = Veneer::Conditional.from_hash(:order => ["foo", "bar"])
46
- conditionals = [:foo, :bar].map do |f|
47
- Veneer::Conditional::Order.new(f)
48
- end
49
- assert_equal c.order.first, conditionals.first
50
- assert_equal c.order.last, conditionals.last
51
- end
52
-
53
- should "let me specify the order with a direction" do
54
- c = Veneer::Conditional.from_hash(:order => ["foo asc", "bar", "baz desc"])
55
- conditionals = [[:foo, :asc], [:bar, :desc], [:baz, :desc]].map do |(f,d)|
56
- Veneer::Conditional::Order.new(f, d)
57
- end
58
-
59
- (0..2).each do |i|
60
- assert_equal c.order[i], conditionals[i]
61
- end
62
- end
63
-
64
- context "conditions" do
65
- context "condition object" do
66
- should "let me specify an equal condition" do
67
- c = Veneer::Conditional::Condition.new(:foo, "val", :eql)
68
- assert_equal :foo, c.field
69
- assert_equal :eql, c.operator
70
- assert_equal "val", c.value
71
- end
72
- end
73
-
74
- should "let me specify conditions" do
75
- c = Veneer::Conditional.from_hash(:conditions => {:foo => "bar"})
76
- condition = c.conditions.first
77
- assert_instance_of Veneer::Conditional::Condition, condition
78
- end
79
-
80
- should "let me specify conditions for different operators" do
81
- c = Veneer::Conditional.from_hash(:conditions => {
82
- "foo not" => "bar",
83
- "bar not" => 5,
84
- "baz gte" => 6
85
- })
86
- foo = c.conditions.detect{|x| x.field == :foo}
87
- assert_not_nil foo
88
- assert_equal "bar", foo.value
89
- assert_equal :not, foo.operator
90
-
91
- bar = c.conditions.detect{|x| x.field == :bar}
92
- assert_not_nil bar
93
- assert_equal 5, bar.value
94
- assert_equal :not, bar.operator
95
-
96
- baz = c.conditions.detect{|x| x.field == :baz}
97
- assert_not_nil baz
98
- assert_equal 6, baz.value
99
- assert_equal :gte, baz.operator
100
- end
101
-
102
- should "not error for valid operators" do
103
- [:eql, :gt, :gte, :lt, :lte, :in, :not].each do |op|
104
- assert_nothing_raised do
105
- Veneer::Conditional::Condition.new(:foo, "bar", op)
106
- end
107
- end
108
- end
109
-
110
- should "error if the operator isn't valid" do
111
- assert_raises Veneer::Errors::ConditionalOperatorNotSupported do
112
- Veneer::Conditional::Condition.new(:foo, "bar", :not_real)
113
- end
114
- end
115
- end
116
-
117
- end
118
- end