ambition 0.3.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/Manifest +41 -48
  2. data/README +6 -203
  3. data/ambition.gemspec +111 -0
  4. data/app_generators/ambition_adapter/USAGE +1 -0
  5. data/app_generators/ambition_adapter/ambition_adapter_generator.rb +66 -0
  6. data/app_generators/ambition_adapter/templates/LICENSE +18 -0
  7. data/app_generators/ambition_adapter/templates/README +6 -0
  8. data/app_generators/ambition_adapter/templates/Rakefile +31 -0
  9. data/app_generators/ambition_adapter/templates/lib/base.rb.erb +12 -0
  10. data/app_generators/ambition_adapter/templates/lib/init.rb.erb +22 -0
  11. data/app_generators/ambition_adapter/templates/lib/query.rb.erb +52 -0
  12. data/app_generators/ambition_adapter/templates/lib/select.rb.erb +100 -0
  13. data/app_generators/ambition_adapter/templates/lib/slice.rb.erb +19 -0
  14. data/app_generators/ambition_adapter/templates/lib/sort.rb.erb +43 -0
  15. data/app_generators/ambition_adapter/templates/test/helper.rb.erb +9 -0
  16. data/app_generators/ambition_adapter/templates/test/select_test.rb.erb +157 -0
  17. data/app_generators/ambition_adapter/templates/test/slice_test.rb.erb +36 -0
  18. data/app_generators/ambition_adapter/templates/test/sort_test.rb.erb +53 -0
  19. data/bin/ambition_adapter +13 -0
  20. data/lib/ambition.rb +8 -13
  21. data/lib/ambition/api.rb +42 -35
  22. data/lib/ambition/context.rb +62 -0
  23. data/lib/ambition/{proc_to_ruby.rb → core_ext.rb} +13 -0
  24. data/lib/ambition/enumerable.rb +6 -0
  25. data/lib/ambition/processors/base.rb +126 -0
  26. data/lib/ambition/processors/ruby.rb +24 -0
  27. data/lib/ambition/processors/select.rb +105 -0
  28. data/lib/ambition/processors/slice.rb +15 -0
  29. data/lib/ambition/processors/sort.rb +51 -0
  30. data/test/adapters/exemplar/association_test.rb +34 -0
  31. data/test/adapters/exemplar/count_test.rb +0 -0
  32. data/test/adapters/exemplar/detect_test.rb +9 -0
  33. data/test/adapters/exemplar/enumerable_test.rb +0 -0
  34. data/test/adapters/exemplar/helper.rb +3 -0
  35. data/test/adapters/exemplar/index_operator.rb +6 -0
  36. data/test/adapters/exemplar/reject_test.rb +0 -0
  37. data/test/adapters/exemplar/select_test.rb +151 -0
  38. data/test/adapters/exemplar/slice_test.rb +0 -0
  39. data/test/adapters/exemplar/sort_test.rb +0 -0
  40. data/test/debug +9 -0
  41. data/test/helper.rb +2 -52
  42. metadata +56 -71
  43. data/Rakefile +0 -64
  44. data/init.rb +0 -1
  45. data/lib/ambition/database_statements.rb +0 -31
  46. data/lib/ambition/processor.rb +0 -123
  47. data/lib/ambition/query.rb +0 -91
  48. data/lib/ambition/ruby_processor.rb +0 -22
  49. data/lib/ambition/select_processor.rb +0 -149
  50. data/lib/ambition/simple_processor.rb +0 -10
  51. data/lib/ambition/sort_processor.rb +0 -47
  52. data/lib/ambition/source.rb +0 -53
  53. data/test/benchmark.rb +0 -68
  54. data/test/chaining_test.rb +0 -34
  55. data/test/console +0 -9
  56. data/test/count_test.rb +0 -17
  57. data/test/databases/boot.rb +0 -3
  58. data/test/databases/database.yml +0 -17
  59. data/test/databases/fixtures/admin.rb +0 -3
  60. data/test/databases/fixtures/companies.yml +0 -24
  61. data/test/databases/fixtures/company.rb +0 -23
  62. data/test/databases/fixtures/developer.rb +0 -11
  63. data/test/databases/fixtures/developers_projects.yml +0 -13
  64. data/test/databases/fixtures/project.rb +0 -4
  65. data/test/databases/fixtures/projects.yml +0 -7
  66. data/test/databases/fixtures/replies.yml +0 -20
  67. data/test/databases/fixtures/reply.rb +0 -5
  68. data/test/databases/fixtures/topic.rb +0 -19
  69. data/test/databases/fixtures/topics.yml +0 -32
  70. data/test/databases/fixtures/user.rb +0 -2
  71. data/test/databases/fixtures/users.yml +0 -35
  72. data/test/databases/lib/activerecord_test_connector.rb +0 -65
  73. data/test/databases/lib/load_fixtures.rb +0 -13
  74. data/test/databases/lib/schema.rb +0 -41
  75. data/test/enumerable_test.rb +0 -95
  76. data/test/join_test.rb +0 -61
  77. data/test/limit_test.rb +0 -41
  78. data/test/order_test.rb +0 -52
  79. data/test/profiler.rb +0 -34
  80. data/test/ruby_test.rb +0 -9
  81. data/test/source_test.rb +0 -43
  82. data/test/types_test.rb +0 -59
  83. data/test/where_test.rb +0 -245
data/test/limit_test.rb DELETED
@@ -1,41 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- context "Limit" do
4
- setup do
5
- @sql = User.select { |m| m.name == 'jon' }
6
- end
7
-
8
- specify "first" do
9
- conditions = { :conditions => "users.name = 'jon'", :limit => 1 }
10
- User.expects(:find).with(:first, conditions)
11
- @sql.first
12
- end
13
-
14
- specify "first with argument" do
15
- conditions = { :conditions => "users.name = 'jon'", :limit => 5 }
16
- User.expects(:find).with(:all, conditions)
17
- @sql.first(5).entries
18
- end
19
-
20
- specify "[] with two elements" do
21
- conditions = { :conditions => "users.name = 'jon'", :limit => 20, :offset => 10 }
22
- User.expects(:find).with(:all, conditions)
23
- @sql[10, 20].entries
24
-
25
- conditions = { :conditions => "users.name = 'jon'", :limit => 20, :offset => 20 }
26
- User.expects(:find).with(:all, conditions)
27
- @sql[20, 20].entries
28
- end
29
-
30
- specify "slice is an alias of []" do
31
- conditions = { :conditions => "users.name = 'jon'", :limit => 20, :offset => 10 }
32
- User.expects(:find).with(:all, conditions)
33
- @sql.slice(10, 20).entries
34
- end
35
-
36
- specify "[] with range" do
37
- conditions = { :conditions => "users.name = 'jon'", :limit => 10, :offset => 10 }
38
- User.expects(:find).with(:all, conditions)
39
- @sql[10..20].entries
40
- end
41
- end
data/test/order_test.rb DELETED
@@ -1,52 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- context "Order" do
4
- setup do
5
- @sql = User.select { |m| m.name == 'jon' }
6
- end
7
-
8
- specify "simple order" do
9
- string = @sql.sort_by { |m| m.name }.to_sql
10
- string.should == "SELECT * FROM users WHERE users.name = 'jon' ORDER BY users.name"
11
- end
12
-
13
- specify "simple combined order" do
14
- string = @sql.sort_by { |m| [ m.name, m.age ] }.to_sql
15
- string.should == "SELECT * FROM users WHERE users.name = 'jon' ORDER BY users.name, users.age"
16
- end
17
-
18
- specify "simple combined order with single reverse" do
19
- string = @sql.sort_by { |m| [ m.name, -m.age ] }.to_sql
20
- string.should == "SELECT * FROM users WHERE users.name = 'jon' ORDER BY users.name, users.age DESC"
21
- end
22
-
23
- specify "simple combined order with two reverses" do
24
- string = @sql.sort_by { |m| [ -m.name, -m.age ] }.to_sql
25
- string.should == "SELECT * FROM users WHERE users.name = 'jon' ORDER BY users.name DESC, users.age DESC"
26
- end
27
-
28
- specify "reverse order with -" do
29
- string = @sql.sort_by { |m| -m.age }.to_sql
30
- string.should == "SELECT * FROM users WHERE users.name = 'jon' ORDER BY users.age DESC"
31
- end
32
-
33
- xspecify "reverse order with #reverse" do
34
- # TODO: not implemented
35
- string = @sql.sort_by { |m| m.age }.reverse.to_sql
36
- string.should == "SELECT * FROM users WHERE users.name = 'jon' ORDER BY users.age DESC"
37
- end
38
-
39
- specify "random order" do
40
- string = @sql.sort_by { rand }.to_sql
41
- string.should == "SELECT * FROM users WHERE users.name = 'jon' ORDER BY RAND()"
42
- end
43
-
44
- specify "non-existent method to sort by" do
45
- should.raise { @sql.sort_by { foo }.to_sql }
46
- end
47
-
48
- specify "Symbol#to_proc" do
49
- string = User.sort_by(&:name).to_sql
50
- string.should == "SELECT * FROM users ORDER BY users.name"
51
- end
52
- end
data/test/profiler.rb DELETED
@@ -1,34 +0,0 @@
1
- $:.unshift File.dirname(__FILE__) + '/../lib'
2
- require 'ambition'
3
- require 'ruby-prof'
4
-
5
- class User < ActiveRecord::Base
6
- def self.reflections
7
- return @reflections if @reflections
8
- @reflections = {}
9
- @reflections[:ideas] = Reflection.new(:has_many, 'user_id', :ideas, 'ideas')
10
- @reflections[:invites] = Reflection.new(:has_many, 'referrer_id', :invites, 'invites')
11
- @reflections[:profile] = Reflection.new(:has_one, 'user_id', :profile, 'profiles')
12
- @reflections[:account] = Reflection.new(:belongs_to, 'account_id', :account, 'accounts')
13
- @reflections
14
- end
15
-
16
- def self.table_name
17
- 'users'
18
- end
19
- end
20
-
21
- class Reflection < Struct.new(:macro, :primary_key_name, :name, :table_name)
22
- end
23
-
24
- result = RubyProf.profile do
25
- 1000.times do
26
- User.select { |u| (u.id == 20 && u.age > 20) || u.profile.name == 'Jon' }.sort_by { |u| [u.id, -u.name] }.first(20).to_hash
27
- end
28
- end
29
-
30
- printer = RubyProf::FlatPrinter.new(result)
31
- #printer = RubyProf::GraphPrinter.new(result)
32
- printer.print(STDOUT, 0)
33
-
34
- puts User.select { |u| (u.id == 20 && u.age > 20) || u.profile.name == 'Jon' }.sort_by { |u| [u.id, -u.name] }.first(20).to_hash.inspect
data/test/ruby_test.rb DELETED
@@ -1,9 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- context "Inline Ruby" do
4
- xspecify "should know what to return" do
5
- name = 'David'
6
- sql = User.select { |u| name.nil? || u.name == name }.to_s
7
- sql.should == "SELECT * FROM users WHERE (users.name = 'David')"
8
- end
9
- end
data/test/source_test.rb DELETED
@@ -1,43 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
- require 'ostruct'
3
-
4
- context "Setting the ambition_source" do
5
- setup do
6
- @users = [
7
- OpenStruct.new(:name => 'Chris', :age => 22),
8
- OpenStruct.new(:name => 'PJ', :age => 24),
9
- OpenStruct.new(:name => 'Kevin', :age => 23),
10
- OpenStruct.new(:name => '_why', :age => 65)
11
- ]
12
- User.ambition_source = @users
13
- end
14
-
15
- teardown do
16
- User.ambition_source = nil
17
- end
18
-
19
- specify "should run all selects / detects against that collection" do
20
- User.detect { |u| u.name == 'Chris' }.should == @users.first
21
- end
22
-
23
- specify "should run all sorts against that collection" do
24
- User.sort_by { |u| -u.age }.entries.should == @users.sort_by { |u| -u.age }
25
- end
26
-
27
- specify "should chain successfully" do
28
- User.select { |u| u.age > 22 }.sort_by { |u| -u.age }.entries.should == [ @users[3], @users[1], @users[2] ]
29
- end
30
-
31
- specify "should be able to revert to normal" do
32
- block = proc { User.select { |m| m.name == 'PJ' }.first }
33
-
34
- User.expects(:find).never
35
- block.call.should == @users[1]
36
-
37
- conditions = { :conditions => "users.name = 'PJ'", :limit => 1 }
38
- User.expects(:find).with(:first, conditions)
39
-
40
- User.ambition_source = nil
41
- block.call
42
- end
43
- end
data/test/types_test.rb DELETED
@@ -1,59 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- ##
4
- # Once dynamically, once hardcoded
5
- context "Different types" do
6
- types_hash = {
7
- 'string' => "'string'",
8
- :symbol => "'--- :symbol\n'",
9
- 1 => '1',
10
- 1.2 => '1.2',
11
- true => '1',
12
- false => '0',
13
- Time.now => "'#{Time.now.to_s(:db)}'",
14
- DateTime.now => "'#{DateTime.now.to_s(:db)}'",
15
- Date.today => "'#{Date.today.to_s(:db)}'"
16
- }
17
-
18
- types_hash.each do |type, translation|
19
- specify "simple using #{type}" do
20
- sql = User.select { |m| m.name == type }.to_sql
21
- sql.should == "SELECT * FROM users WHERE users.name = #{translation}"
22
- end
23
- end
24
-
25
- specify "float" do
26
- sql = User.select { |m| m.name == 1.2 }.to_sql
27
- sql.should == "SELECT * FROM users WHERE users.name = 1.2"
28
- end
29
-
30
- specify "integer" do
31
- sql = User.select { |m| m.name == 1 }.to_sql
32
- sql.should == "SELECT * FROM users WHERE users.name = 1"
33
- end
34
-
35
- specify "true" do
36
- sql = User.select { |m| m.name == true }.to_sql
37
- sql.should == "SELECT * FROM users WHERE users.name = 1"
38
- end
39
-
40
- specify "false" do
41
- sql = User.select { |m| m.name == false }.to_sql
42
- sql.should == "SELECT * FROM users WHERE users.name = 0"
43
- end
44
-
45
- specify "nil" do
46
- sql = User.select { |m| m.name == nil }.to_sql
47
- sql.should == "SELECT * FROM users WHERE users.name IS NULL"
48
- end
49
-
50
- specify "not nil" do
51
- sql = User.select { |m| m.name != nil }.to_sql
52
- sql.should == "SELECT * FROM users WHERE users.name IS NOT NULL"
53
- end
54
-
55
- specify "Time" do
56
- sql = User.select { |m| m.name == Time.now }.to_sql
57
- sql.should == "SELECT * FROM users WHERE users.name = '#{Time.now.to_s(:db)}'"
58
- end
59
- end
data/test/where_test.rb DELETED
@@ -1,245 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- context "Where (using select)" do
4
- specify "simple ==" do
5
- sql = User.select { |m| m.name == 'jon' }.to_sql
6
- sql.should == "SELECT * FROM users WHERE users.name = 'jon'"
7
- end
8
-
9
- specify "simple !=" do
10
- sql = User.select { |m| m.name != 'jon' }.to_sql
11
- sql.should == "SELECT * FROM users WHERE users.name <> 'jon'"
12
- end
13
-
14
- specify "simple == && ==" do
15
- sql = User.select { |m| m.name == 'jon' && m.age == 21 }.to_sql
16
- sql.should == "SELECT * FROM users WHERE (users.name = 'jon' AND users.age = 21)"
17
- end
18
-
19
- specify "simple == || ==" do
20
- sql = User.select { |m| m.name == 'jon' || m.age == 21 }.to_sql
21
- sql.should == "SELECT * FROM users WHERE (users.name = 'jon' OR users.age = 21)"
22
- end
23
-
24
- specify "mixed && and ||" do
25
- sql = User.select { |m| m.name == 'jon' || m.age == 21 && m.password == 'pass' }.to_sql
26
- sql.should == "SELECT * FROM users WHERE (users.name = 'jon' OR (users.age = 21 AND users.password = 'pass'))"
27
- end
28
-
29
- specify "grouped && and ||" do
30
- sql = User.select { |m| (m.name == 'jon' || m.name == 'rick') && m.age == 21 }.to_sql
31
- sql.should == "SELECT * FROM users WHERE ((users.name = 'jon' OR users.name = 'rick') AND users.age = 21)"
32
- end
33
-
34
- specify "simple >/<" do
35
- sql = User.select { |m| m.age > 21 }.to_sql
36
- sql.should == "SELECT * FROM users WHERE users.age > 21"
37
-
38
- sql = User.select { |m| m.age >= 21 }.to_sql
39
- sql.should == "SELECT * FROM users WHERE users.age >= 21"
40
-
41
- sql = User.select { |m| m.age < 21 }.to_sql
42
- sql.should == "SELECT * FROM users WHERE users.age < 21"
43
- end
44
-
45
- specify "array.include? item" do
46
- sql = User.select { |m| [1, 2, 3, 4].include? m.id }.to_sql
47
- sql.should == "SELECT * FROM users WHERE users.id IN (1, 2, 3, 4)"
48
- end
49
-
50
- specify "variable'd array.include? item" do
51
- array = [1, 2, 3, 4]
52
- sql = User.select { |m| array.include? m.id }.to_sql
53
- sql.should == "SELECT * FROM users WHERE users.id IN (1, 2, 3, 4)"
54
- end
55
-
56
- specify "simple == with variables" do
57
- me = 'chris'
58
- sql = User.select { |m| m.name == me }.to_sql
59
- sql.should == "SELECT * FROM users WHERE users.name = '#{me}'"
60
- end
61
-
62
- specify "simple == with method arguments" do
63
- def test_it(name)
64
- sql = User.select { |m| m.name == name }.to_sql
65
- sql.should == "SELECT * FROM users WHERE users.name = '#{name}'"
66
- end
67
-
68
- test_it('chris')
69
- end
70
-
71
- specify "simple == with instance variables" do
72
- @me = 'chris'
73
- sql = User.select { |m| m.name == @me }.to_sql
74
- sql.should == "SELECT * FROM users WHERE users.name = '#{@me}'"
75
- end
76
-
77
- specify "simple == with instance variable method call" do
78
- require 'ostruct'
79
- @person = OpenStruct.new(:name => 'chris')
80
-
81
- sql = User.select { |m| m.name == @person.name }.to_sql
82
- sql.should == "SELECT * FROM users WHERE users.name = '#{@person.name}'"
83
- end
84
-
85
- specify "simple == with global variables" do
86
- $my_name = 'boston'
87
- sql = User.select { |m| m.name == $my_name }.to_sql
88
- sql.should == "SELECT * FROM users WHERE users.name = '#{$my_name}'"
89
- end
90
-
91
- specify "simple == with method call" do
92
- def band
93
- 'megadeth'
94
- end
95
-
96
- sql = User.select { |m| m.name == band }.to_sql
97
- sql.should == "SELECT * FROM users WHERE users.name = '#{band}'"
98
- end
99
-
100
- specify "simple =~ with string" do
101
- sql = User.select { |m| m.name =~ 'chris' }.to_sql
102
- sql.should == "SELECT * FROM users WHERE users.name LIKE 'chris'"
103
-
104
- sql = User.select { |m| m.name =~ 'chri%' }.to_sql
105
- sql.should == "SELECT * FROM users WHERE users.name LIKE 'chri%'"
106
- end
107
-
108
- specify "simple !~ with string" do
109
- sql = User.select { |m| m.name !~ 'chris' }.to_sql
110
- sql.should == "SELECT * FROM users WHERE users.name NOT LIKE 'chris'"
111
-
112
- sql = User.select { |m| !(m.name =~ 'chris') }.to_sql
113
- sql.should == "SELECT * FROM users WHERE users.name NOT LIKE 'chris'"
114
- end
115
-
116
- specify "simple =~ with regexp" do
117
- sql = User.select { |m| m.name =~ /chris/ }.to_sql
118
- sql.should == "SELECT * FROM users WHERE users.name REGEXP 'chris'"
119
- end
120
-
121
- specify "simple =~ with regexp flags" do
122
- sql = User.select { |m| m.name =~ /chris/i }.to_sql
123
- sql.should == "SELECT * FROM users WHERE users.name REGEXP 'chris'"
124
- end
125
-
126
- specify "simple LOWER()" do
127
- sql = User.select { |m| m.name.downcase =~ 'chris%' }.to_sql
128
- sql.should == "SELECT * FROM users WHERE LOWER(users.name) LIKE 'chris%'"
129
- end
130
-
131
- specify "simple UPPER()" do
132
- sql = User.select { |m| m.name.upcase =~ 'chris%' }.to_sql
133
- sql.should == "SELECT * FROM users WHERE UPPER(users.name) LIKE 'chris%'"
134
- end
135
-
136
- specify "undefined equality symbol" do
137
- should.raise { User.select { |m| m.name =* /chris/ }.to_sql }
138
- end
139
-
140
- specify "block variable / assigning variable conflict" do
141
- m = User.select { |m| m.name == 'chris' }.to_sql
142
- m.should == "SELECT * FROM users WHERE users.name = 'chris'"
143
- end
144
-
145
- specify "simple == with inline ruby" do
146
- sql = User.select { |m| m.created_at == 2.days.ago.to_s(:db) }.to_sql
147
- sql.should == "SELECT * FROM users WHERE users.created_at = '#{2.days.ago.to_s(:db)}'"
148
- end
149
-
150
- specify "inspect" do
151
- User.select { |u| u.name }.inspect.should.match %r(call #to_sql or #to_hash)
152
- end
153
- end
154
-
155
- context "Where (using detect)" do
156
- specify "simple ==" do
157
- User.expects(:select).returns(mock(:first => true))
158
- User.detect { |m| m.name == 'chris' }
159
- end
160
-
161
- specify "nothing found" do
162
- User.expects(:select).returns(mock(:first => nil))
163
- User.detect { |m| m.name == 'chris' }.should.be.nil
164
- end
165
- end
166
-
167
- context "Where (using [])" do
168
- specify "finds a single row" do
169
- User.expects(:find).with(1)
170
- User[1]
171
- end
172
- end
173
-
174
- context "PostgreSQL specific" do
175
- setup do
176
- ActiveRecord::Base.connection = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.new 'fake_connection', 'fake_logger'
177
- end
178
-
179
- teardown do
180
- ActiveRecord::Base.remove_connection
181
- end
182
-
183
- specify "quoting of column name" do
184
- me = 'chris'
185
- sql = User.select { |m| m.name == me }.to_sql
186
- sql.should == %(SELECT * FROM users WHERE users."name" = '#{me}')
187
- end
188
-
189
- specify "simple =~ with regexp" do
190
- sql = User.select { |m| m.name =~ /chris/ }.to_sql
191
- sql.should == %(SELECT * FROM users WHERE users."name" ~ 'chris')
192
- end
193
-
194
- specify "insensitive =~" do
195
- sql = User.select { |m| m.name =~ /chris/i }.to_sql
196
- sql.should == %(SELECT * FROM users WHERE users."name" ~* 'chris')
197
- end
198
-
199
- specify "negated =~" do
200
- sql = User.select { |m| m.name !~ /chris/ }.to_sql
201
- sql.should == %(SELECT * FROM users WHERE users."name" !~ 'chris')
202
- end
203
-
204
- specify "negated insensitive =~" do
205
- sql = User.select { |m| m.name !~ /chris/i }.to_sql
206
- sql.should == %(SELECT * FROM users WHERE users."name" !~* 'chris')
207
- end
208
- end
209
-
210
- context "MySQL specific" do
211
- setup do
212
- ActiveRecord::Base.connection = ActiveRecord::ConnectionAdapters::MysqlAdapter.new('connection', 'logger', 'options', 'config')
213
- end
214
-
215
- teardown do
216
- ActiveRecord::Base.remove_connection
217
- end
218
-
219
- specify "quoting of column name" do
220
- me = 'chris'
221
- sql = User.select { |m| m.name == me }.to_sql
222
- sql.should == "SELECT * FROM users WHERE users.`name` = '#{me}'"
223
- end
224
-
225
- specify "simple =~ with regexp" do
226
- sql = User.select { |m| m.name =~ /chris/ }.to_sql
227
- sql.should == "SELECT * FROM users WHERE users.`name` REGEXP 'chris'"
228
- end
229
- end
230
-
231
- context "Adapter without overrides" do
232
- setup do
233
- ActiveRecord::Base.connection = ActiveRecord::ConnectionAdapters::FakeAdapter.new('connection', 'logger')
234
- end
235
-
236
- teardown do
237
- ActiveRecord::Base.remove_connection
238
- end
239
-
240
- specify "quoting of column name" do
241
- me = 'chris'
242
- sql = User.select { |m| m.name == me }.to_sql
243
- sql.should == "SELECT * FROM users WHERE users.name = '#{me}'"
244
- end
245
- end