djsun-mongo_mapper 0.5.5.3 → 0.5.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,41 +43,41 @@ class PaginationTest < Test::Unit::TestCase
43
43
 
44
44
  should "accept conditions" do
45
45
  result = @document.paginate({
46
- :conditions => {:last_name => 'Nunemaker'},
47
- :order => "age DESC",
48
- :per_page => 2,
49
- :page => 1,
46
+ :last_name => 'Nunemaker',
47
+ :order => "age DESC",
48
+ :per_page => 2,
49
+ :page => 1,
50
50
  })
51
51
  result.should == [@doc1, @doc3]
52
52
  result.first.age.should == 27
53
53
  end
54
54
 
55
- should "withstand rigor" do
55
+ should "withstand rigor" do
56
56
  result = @document.paginate({
57
- :per_page => 1,
58
- :page => 1,
59
- :order => 'age desc',
60
- :conditions => {:last_name => 'Nunemaker'}
57
+ :per_page => 1,
58
+ :page => 1,
59
+ :order => 'age desc',
60
+ :last_name => 'Nunemaker'
61
61
  })
62
62
  result.should == [@doc1]
63
63
  result.total_entries.should == 2
64
64
  result.total_pages.should == 2
65
65
 
66
66
  result = @document.paginate({
67
- :per_page => 1,
68
- :page => 2,
69
- :order => 'age desc',
70
- :conditions => {:last_name => 'Nunemaker'}
67
+ :per_page => 1,
68
+ :page => 2,
69
+ :order => 'age desc',
70
+ :last_name => 'Nunemaker'
71
71
  })
72
72
  result.should == [@doc3]
73
73
  result.total_entries.should == 2
74
74
  result.total_pages.should == 2
75
75
 
76
76
  result = @document.paginate({
77
- :per_page => 2,
78
- :page => 1,
79
- :order => 'age desc',
80
- :conditions => {:last_name => 'Nunemaker'}
77
+ :per_page => 2,
78
+ :page => 1,
79
+ :order => 'age desc',
80
+ :last_name => 'Nunemaker'
81
81
  })
82
82
  result.should == [@doc1, @doc3]
83
83
  result.total_entries.should == 2
@@ -170,8 +170,8 @@ class ValidationsTest < Test::Unit::TestCase
170
170
  doc.save.should be_true
171
171
 
172
172
  @document \
173
- .stubs(:find) \
174
- .with(:first, :conditions => {:name => 'joe'}, :limit => 1) \
173
+ .stubs(:first) \
174
+ .with(:name => 'joe') \
175
175
  .returns(doc)
176
176
 
177
177
  doc.name = "joe"
@@ -184,14 +184,35 @@ class ValidationsTest < Test::Unit::TestCase
184
184
  doc.save.should be_true
185
185
 
186
186
  @document \
187
- .stubs(:find) \
188
- .with(:first, :conditions => {:name => 'joe'}, :limit => 1) \
187
+ .stubs(:first) \
188
+ .with(:name => 'joe') \
189
189
  .returns(doc)
190
190
 
191
191
  doc2 = @document.new("name" => "joe")
192
192
  doc2.should have_error_on(:name)
193
193
  end
194
194
 
195
+ should "allow multiple blank entries if :allow_blank => true" do
196
+ document = Class.new do
197
+ include MongoMapper::Document
198
+ set_collection_name 'test'
199
+
200
+ key :name
201
+ validates_uniqueness_of :name, :allow_blank => :true
202
+ end
203
+
204
+ doc = document.new("name" => "")
205
+ doc.save.should be_true
206
+
207
+ document \
208
+ .stubs(:first) \
209
+ .with(:name => '') \
210
+ .returns(doc)
211
+
212
+ doc2 = document.new("name" => "")
213
+ doc2.should_not have_error_on(:name)
214
+ end
215
+
195
216
  context "scoped by a single attribute" do
196
217
  setup do
197
218
  @document = Class.new do
@@ -210,8 +231,8 @@ class ValidationsTest < Test::Unit::TestCase
210
231
  doc.save.should be_true
211
232
 
212
233
  @document \
213
- .stubs(:find) \
214
- .with(:first, :conditions => {:name => 'joe', :scope => "one"}, :limit => 1) \
234
+ .stubs(:first) \
235
+ .with(:name => 'joe', :scope => "one") \
215
236
  .returns(doc)
216
237
 
217
238
  doc2 = @document.new("name" => "joe", "scope" => "one")
@@ -223,8 +244,8 @@ class ValidationsTest < Test::Unit::TestCase
223
244
  doc.save.should be_true
224
245
 
225
246
  @document \
226
- .stubs(:find) \
227
- .with(:first, :conditions => {:name => 'joe', :scope => "two"}, :limit => 1) \
247
+ .stubs(:first) \
248
+ .with(:name => 'joe', :scope => 'two') \
228
249
  .returns(nil)
229
250
 
230
251
  doc2 = @document.new("name" => "joe", "scope" => "two")
@@ -251,8 +272,8 @@ class ValidationsTest < Test::Unit::TestCase
251
272
  doc.save.should be_true
252
273
 
253
274
  @document \
254
- .stubs(:find) \
255
- .with(:first, :conditions => {:name => 'joe', :first_scope => "one", :second_scope => "two"}, :limit => 1) \
275
+ .stubs(:first) \
276
+ .with(:name => 'joe', :first_scope => 'one', :second_scope => 'two') \
256
277
  .returns(doc)
257
278
 
258
279
  doc2 = @document.new("name" => "joe", "first_scope" => "one", "second_scope" => "two")
@@ -264,8 +285,8 @@ class ValidationsTest < Test::Unit::TestCase
264
285
  doc.save.should be_true
265
286
 
266
287
  @document \
267
- .stubs(:find) \
268
- .with(:first, :conditions => {:name => 'joe', :first_scope => "one", :second_scope => "one"}, :limit => 1) \
288
+ .stubs(:first) \
289
+ .with(:name => 'joe', :first_scope => 'one', :second_scope => 'one') \
269
290
  .returns(nil)
270
291
 
271
292
  doc2 = @document.new("name" => "joe", "first_scope" => "one", "second_scope" => "one")
@@ -288,8 +309,8 @@ class ValidationsTest < Test::Unit::TestCase
288
309
  doc.should_not have_error_on(:name)
289
310
 
290
311
  @document \
291
- .stubs(:find) \
292
- .with(:first, :conditions => {:name => 'John'}, :limit => 1) \
312
+ .stubs(:first) \
313
+ .with(:name => 'John') \
293
314
  .returns(doc)
294
315
 
295
316
  second_john = @document.create(:name => 'John')
data/test/models.rb CHANGED
@@ -68,12 +68,6 @@ class Message
68
68
  belongs_to :room
69
69
  end
70
70
 
71
- class Answer
72
- include MongoMapper::Document
73
-
74
- key :body, String
75
- end
76
-
77
71
  class Enter < Message; end
78
72
  class Exit < Message; end
79
73
  class Chat < Message; end
@@ -85,6 +79,12 @@ class Room
85
79
  many :messages, :polymorphic => true
86
80
  end
87
81
 
82
+ class Answer
83
+ include MongoMapper::Document
84
+
85
+ key :body, String
86
+ end
87
+
88
88
  class Project
89
89
  include MongoMapper::Document
90
90
 
data/test/test_helper.rb CHANGED
@@ -25,6 +25,8 @@ end
25
25
  DefaultDatabase = 'test' unless defined?(DefaultDatabase)
26
26
  AlternateDatabase = 'test2' unless defined?(AlternateDatabase)
27
27
 
28
- logger = Logger.new(File.expand_path(File.dirname(__FILE__) + '/../tmp/test.log'))
29
- MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017, :logger => logger)
28
+ test_dir = File.expand_path(File.dirname(__FILE__) + '/../tmp')
29
+ FileUtils.mkdir_p(test_dir) unless File.exist?(test_dir)
30
+
31
+ MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017, :logger => Logger.new(test_dir + '/test.log'))
30
32
  MongoMapper.database = DefaultDatabase
@@ -166,14 +166,12 @@ class DocumentTest < Test::Unit::TestCase
166
166
  doc_1 = @document.new('name' => "Doc 1")
167
167
  doc_2 = @document.new('name' => "Doc 1")
168
168
  doc_1.should == doc_2
169
- doc_2.should == doc_1 # check transitivity
170
169
  end
171
170
 
172
171
  should "not be == if key values are different" do
173
172
  doc_1 = @document.new('name' => "Doc 1")
174
173
  doc_2 = @document.new('name' => "Doc 2")
175
174
  doc_1.should_not == doc_2
176
- doc_2.should_not == doc_1 # check transitivity
177
175
  end
178
176
 
179
177
  should "not care about type" do
@@ -186,7 +184,7 @@ class DocumentTest < Test::Unit::TestCase
186
184
  doc = @document.new('name' => "Doc 1")
187
185
  person = @person.new('name' => "Doc 1")
188
186
  doc.should == person
189
- person.should == doc # check transitivity
187
+ person.should == doc # test commutativity
190
188
  end
191
189
  end
192
190
 
@@ -195,14 +193,12 @@ class DocumentTest < Test::Unit::TestCase
195
193
  doc_1 = @document.new('name' => "Doc 1")
196
194
  doc_2 = @document.new('name' => "Doc 1")
197
195
  doc_1.should eql?(doc_2)
198
- doc_2.should eql?(doc_1) # check transitivity
199
196
  end
200
197
 
201
198
  should "not be == if type matches but key values are different" do
202
199
  doc_1 = @document.new('name' => "Doc 1")
203
200
  doc_2 = @document.new('name' => "Doc 2")
204
201
  doc_1.should_not eql?(doc_2)
205
- doc_2.should_not eql?(doc_1) # check transitivity
206
202
  end
207
203
 
208
204
  should "not be eql? if types are different even if values are the same" do
@@ -215,7 +211,7 @@ class DocumentTest < Test::Unit::TestCase
215
211
  doc = @document.new('name' => "Doc 1")
216
212
  person = @person.new('name' => "Doc 1")
217
213
  doc.should_not eql?(person)
218
- person.should_not eql?(doc) # check transitivity
214
+ person.should_not eql?(doc) # test commutativity
219
215
  end
220
216
  end
221
217
  end # instance of a document
@@ -649,14 +649,12 @@ class EmbeddedDocumentTest < Test::Unit::TestCase
649
649
  doc_1 = @document.new('name' => "Doc 1")
650
650
  doc_2 = @document.new('name' => "Doc 1")
651
651
  doc_1.should == doc_2
652
- doc_2.should == doc_1 # check transitivity
653
652
  end
654
653
 
655
654
  should "not be == if key values are different" do
656
655
  doc_1 = @document.new('name' => "Doc 1")
657
656
  doc_2 = @document.new('name' => "Doc 2")
658
657
  doc_1.should_not == doc_2
659
- doc_2.should_not == doc_1 # check transitivity
660
658
  end
661
659
 
662
660
  should "not care about type" do
@@ -669,7 +667,7 @@ class EmbeddedDocumentTest < Test::Unit::TestCase
669
667
  doc = @document.new('name' => "Doc 1")
670
668
  person = @person.new('name' => "Doc 1")
671
669
  doc.should == person
672
- person.should == doc # check transitivity
670
+ person.should == doc # test commutativity
673
671
  end
674
672
  end
675
673
 
@@ -678,14 +676,12 @@ class EmbeddedDocumentTest < Test::Unit::TestCase
678
676
  doc_1 = @document.new('name' => "Doc 1")
679
677
  doc_2 = @document.new('name' => "Doc 1")
680
678
  doc_1.should eql?(doc_2)
681
- doc_2.should eql?(doc_1) # check transitivity
682
679
  end
683
680
 
684
681
  should "not be == if type matches but key values are different" do
685
682
  doc_1 = @document.new('name' => "Doc 1")
686
683
  doc_2 = @document.new('name' => "Doc 2")
687
684
  doc_1.should_not eql?(doc_2)
688
- doc_2.should_not eql?(doc_1) # check transitivity
689
685
  end
690
686
 
691
687
  should "not be eql? if types are different even if values are the same" do
@@ -698,7 +694,7 @@ class EmbeddedDocumentTest < Test::Unit::TestCase
698
694
  doc = @document.new('name' => "Doc 1")
699
695
  person = @person.new('name' => "Doc 1")
700
696
  doc.should_not eql?(person)
701
- person.should_not eql?(doc) # check transitivity
697
+ person.should_not eql?(doc) # check commutativity
702
698
  end
703
699
  end
704
700
 
@@ -1,73 +1,73 @@
1
1
  require 'test_helper'
2
+ require 'models'
2
3
 
3
4
  class FinderOptionsTest < Test::Unit::TestCase
4
5
  include MongoMapper
5
6
 
6
7
  should "raise error if provided something other than a hash" do
7
- lambda { FinderOptions.new }.should raise_error(ArgumentError)
8
- lambda { FinderOptions.new(1) }.should raise_error(ArgumentError)
8
+ lambda { FinderOptions.new(Room) }.should raise_error(ArgumentError)
9
+ lambda { FinderOptions.new(Room, 1) }.should raise_error(ArgumentError)
9
10
  end
10
11
 
11
12
  should "symbolize the keys of the hash provided" do
12
- FinderOptions.new('offset' => 1).options.keys.map do |key|
13
+ FinderOptions.new(Room, 'offset' => 1).options.keys.map do |key|
13
14
  key.should be_instance_of(Symbol)
14
15
  end
15
16
  end
16
17
 
17
- context "#criteria" do
18
- should "convert conditions to criteria" do
19
- FinderOptions.expects(:to_mongo_criteria).with(:foo => 1).returns({})
20
- FinderOptions.new(:conditions => {:foo => 1}).criteria
18
+ context "Converting conditions to criteria" do
19
+ should "not add _type to query if model does not have superclass that is single collection inherited" do
20
+ FinderOptions.new(Message, :foo => 'bar').criteria.should == {
21
+ :foo => 'bar'
22
+ }
21
23
  end
22
- end
23
-
24
- context "#options" do
25
- should "convert options to mongo options" do
26
- FinderOptions.expects(:to_mongo_options).with(:order => 'foo asc', :select => 'foo,bar').returns({})
27
- FinderOptions.new(:order => 'foo asc', :select => 'foo,bar').options
24
+
25
+ should "automatically add _type to query if model is single collection inherited" do
26
+ FinderOptions.new(Enter, :foo => 'bar').criteria.should == {
27
+ :foo => 'bar',
28
+ :_type => 'Enter'
29
+ }
28
30
  end
29
- end
30
-
31
- context "Converting conditions to criteria" do
31
+
32
32
  should "work with simple criteria" do
33
- FinderOptions.to_mongo_criteria(:foo => 'bar').should == {
33
+ FinderOptions.new(Room, :foo => 'bar').criteria.should == {
34
34
  :foo => 'bar'
35
35
  }
36
36
 
37
- FinderOptions.to_mongo_criteria(:foo => 'bar', :baz => 'wick').should == {
37
+ FinderOptions.new(Room, :foo => 'bar', :baz => 'wick').criteria.should == {
38
38
  :foo => 'bar',
39
39
  :baz => 'wick'
40
40
  }
41
41
  end
42
42
 
43
43
  should "convert id to _id" do
44
- FinderOptions.to_mongo_criteria(:id => '1').should == {
44
+ FinderOptions.new(Room, :id => '1').criteria.should == {
45
45
  :_id => '1'
46
46
  }
47
47
  end
48
48
 
49
49
  should "use $in for arrays" do
50
- FinderOptions.to_mongo_criteria(:foo => [1,2,3]).should == {
50
+ FinderOptions.new(Room, :foo => [1,2,3]).criteria.should == {
51
51
  :foo => {'$in' => [1,2,3]}
52
52
  }
53
53
  end
54
54
 
55
55
  should "not use $in for arrays if already using array operator" do
56
- FinderOptions.to_mongo_criteria(:foo => {'$all' => [1,2,3]}).should == {
56
+ FinderOptions.new(Room, :foo => {'$all' => [1,2,3]}).criteria.should == {
57
57
  :foo => {'$all' => [1,2,3]}
58
58
  }
59
59
 
60
- FinderOptions.to_mongo_criteria(:foo => {'$any' => [1,2,3]}).should == {
60
+ FinderOptions.new(Room, :foo => {'$any' => [1,2,3]}).criteria.should == {
61
61
  :foo => {'$any' => [1,2,3]}
62
62
  }
63
63
  end
64
64
 
65
65
  should "work arbitrarily deep" do
66
- FinderOptions.to_mongo_criteria(:foo => {:bar => [1,2,3]}).should == {
66
+ FinderOptions.new(Room, :foo => {:bar => [1,2,3]}).criteria.should == {
67
67
  :foo => {:bar => {'$in' => [1,2,3]}}
68
68
  }
69
69
 
70
- FinderOptions.to_mongo_criteria(:foo => {:bar => {'$any' => [1,2,3]}}).should == {
70
+ FinderOptions.new(Room, :foo => {:bar => {'$any' => [1,2,3]}}).criteria.should == {
71
71
  :foo => {:bar => {'$any' => [1,2,3]}}
72
72
  }
73
73
  end
@@ -76,166 +76,166 @@ class FinderOptionsTest < Test::Unit::TestCase
76
76
  context "ordering" do
77
77
  should "single field with ascending direction" do
78
78
  sort = [['foo', 1]]
79
- FinderOptions.to_mongo_options(:order => 'foo asc')[:sort].should == sort
80
- FinderOptions.to_mongo_options(:order => 'foo ASC')[:sort].should == sort
79
+ FinderOptions.new(Room, :order => 'foo asc').options[:sort].should == sort
80
+ FinderOptions.new(Room, :order => 'foo ASC').options[:sort].should == sort
81
81
  end
82
82
 
83
83
  should "single field with descending direction" do
84
84
  sort = [['foo', -1]]
85
- FinderOptions.to_mongo_options(:order => 'foo desc')[:sort].should == sort
86
- FinderOptions.to_mongo_options(:order => 'foo DESC')[:sort].should == sort
85
+ FinderOptions.new(Room, :order => 'foo desc').options[:sort].should == sort
86
+ FinderOptions.new(Room, :order => 'foo DESC').options[:sort].should == sort
87
87
  end
88
88
 
89
89
  should "convert field without direction to ascending" do
90
90
  sort = [['foo', 1]]
91
- FinderOptions.to_mongo_options(:order => 'foo')[:sort].should == sort
91
+ FinderOptions.new(Room, :order => 'foo').options[:sort].should == sort
92
92
  end
93
93
 
94
94
  should "convert multiple fields with directions" do
95
95
  sort = [['foo', -1], ['bar', 1], ['baz', -1]]
96
- FinderOptions.to_mongo_options(:order => 'foo desc, bar asc, baz desc')[:sort].should == sort
96
+ FinderOptions.new(Room, :order => 'foo desc, bar asc, baz desc').options[:sort].should == sort
97
97
  end
98
98
 
99
99
  should "convert multiple fields with some missing directions" do
100
100
  sort = [['foo', -1], ['bar', 1], ['baz', 1]]
101
- FinderOptions.to_mongo_options(:order => 'foo desc, bar, baz')[:sort].should == sort
101
+ FinderOptions.new(Room, :order => 'foo desc, bar, baz').options[:sort].should == sort
102
102
  end
103
103
 
104
104
  should "just use sort if sort and order are present" do
105
105
  sort = [['$natural', 1]]
106
- FinderOptions.to_mongo_options(:sort => sort, :order => 'foo asc')[:sort].should == sort
106
+ FinderOptions.new(Room, :sort => sort, :order => 'foo asc').options[:sort].should == sort
107
107
  end
108
108
 
109
109
  should "convert natural in order to proper" do
110
110
  sort = [['$natural', 1]]
111
- FinderOptions.to_mongo_options(:order => '$natural asc')[:sort].should == sort
111
+ FinderOptions.new(Room, :order => '$natural asc').options[:sort].should == sort
112
112
  sort = [['$natural', -1]]
113
- FinderOptions.to_mongo_options(:order => '$natural desc')[:sort].should == sort
113
+ FinderOptions.new(Room, :order => '$natural desc').options[:sort].should == sort
114
114
  end
115
115
 
116
116
  should "work for natural order ascending" do
117
- FinderOptions.to_mongo_options(:sort => {'$natural' => 1})[:sort]['$natural'].should == 1
117
+ FinderOptions.new(Room, :sort => {'$natural' => 1}).options[:sort]['$natural'].should == 1
118
118
  end
119
119
 
120
120
  should "work for natural order descending" do
121
- FinderOptions.to_mongo_options(:sort => {'$natural' => -1})[:sort]['$natural'].should == -1
121
+ FinderOptions.new(Room, :sort => {'$natural' => -1}).options[:sort]['$natural'].should == -1
122
122
  end
123
123
  end
124
124
 
125
125
  context "skip" do
126
126
  should "default to 0" do
127
- FinderOptions.to_mongo_options({})[:skip].should == 0
127
+ FinderOptions.new(Room, {}).options[:skip].should == 0
128
128
  end
129
129
 
130
130
  should "use skip provided" do
131
- FinderOptions.to_mongo_options(:skip => 2)[:skip].should == 2
131
+ FinderOptions.new(Room, :skip => 2).options[:skip].should == 2
132
132
  end
133
133
 
134
134
  should "covert string to integer" do
135
- FinderOptions.to_mongo_options(:skip => '2')[:skip].should == 2
135
+ FinderOptions.new(Room, :skip => '2').options[:skip].should == 2
136
136
  end
137
137
 
138
138
  should "convert offset to skip" do
139
- FinderOptions.to_mongo_options(:offset => 1)[:skip].should == 1
139
+ FinderOptions.new(Room, :offset => 1).options[:skip].should == 1
140
140
  end
141
141
  end
142
142
 
143
143
  context "limit" do
144
144
  should "default to 0" do
145
- FinderOptions.to_mongo_options({})[:limit].should == 0
145
+ FinderOptions.new(Room, {}).options[:limit].should == 0
146
146
  end
147
147
 
148
148
  should "use limit provided" do
149
- FinderOptions.to_mongo_options(:limit => 2)[:limit].should == 2
149
+ FinderOptions.new(Room, :limit => 2).options[:limit].should == 2
150
150
  end
151
151
 
152
152
  should "covert string to integer" do
153
- FinderOptions.to_mongo_options(:limit => '2')[:limit].should == 2
153
+ FinderOptions.new(Room, :limit => '2').options[:limit].should == 2
154
154
  end
155
155
  end
156
156
 
157
157
  context "fields" do
158
158
  should "default to nil" do
159
- FinderOptions.to_mongo_options({})[:fields].should be(nil)
159
+ FinderOptions.new(Room, {}).options[:fields].should be(nil)
160
160
  end
161
161
 
162
162
  should "be converted to nil if empty string" do
163
- FinderOptions.to_mongo_options(:fields => '')[:fields].should be(nil)
163
+ FinderOptions.new(Room, :fields => '').options[:fields].should be(nil)
164
164
  end
165
165
 
166
166
  should "be converted to nil if []" do
167
- FinderOptions.to_mongo_options(:fields => [])[:fields].should be(nil)
167
+ FinderOptions.new(Room, :fields => []).options[:fields].should be(nil)
168
168
  end
169
169
 
170
170
  should "should work with array" do
171
- FinderOptions.to_mongo_options({:fields => %w(a b)})[:fields].should == %w(a b)
171
+ FinderOptions.new(Room, {:fields => %w(a b)}).options[:fields].should == %w(a b)
172
172
  end
173
173
 
174
174
  should "convert comma separated list to array" do
175
- FinderOptions.to_mongo_options({:fields => 'a, b'})[:fields].should == %w(a b)
175
+ FinderOptions.new(Room, {:fields => 'a, b'}).options[:fields].should == %w(a b)
176
176
  end
177
177
 
178
178
  should "also work as select" do
179
- FinderOptions.new(:select => %w(a b)).options[:fields].should == %w(a b)
179
+ FinderOptions.new(Room, :select => %w(a b)).options[:fields].should == %w(a b)
180
180
  end
181
181
  end
182
182
 
183
183
  context "Condition auto-detection" do
184
184
  should "know :conditions are criteria" do
185
- finder = FinderOptions.new(:conditions => {:foo => 'bar'})
185
+ finder = FinderOptions.new(Room, :conditions => {:foo => 'bar'})
186
186
  finder.criteria.should == {:foo => 'bar'}
187
187
  finder.options.keys.should_not include(:conditions)
188
188
  end
189
189
 
190
190
  should "know fields is an option" do
191
- finder = FinderOptions.new(:fields => ['foo'])
191
+ finder = FinderOptions.new(Room, :fields => ['foo'])
192
192
  finder.options[:fields].should == ['foo']
193
193
  finder.criteria.keys.should_not include(:fields)
194
194
  end
195
195
 
196
196
  # select gets converted to fields so just checking keys
197
197
  should "know select is an option" do
198
- finder = FinderOptions.new(:select => 'foo')
198
+ finder = FinderOptions.new(Room, :select => 'foo')
199
199
  finder.options.keys.should include(:sort)
200
200
  finder.criteria.keys.should_not include(:select)
201
201
  finder.criteria.keys.should_not include(:fields)
202
202
  end
203
203
 
204
204
  should "know skip is an option" do
205
- finder = FinderOptions.new(:skip => 10)
205
+ finder = FinderOptions.new(Room, :skip => 10)
206
206
  finder.options[:skip].should == 10
207
207
  finder.criteria.keys.should_not include(:skip)
208
208
  end
209
209
 
210
210
  # offset gets converted to skip so just checking keys
211
211
  should "know offset is an option" do
212
- finder = FinderOptions.new(:offset => 10)
212
+ finder = FinderOptions.new(Room, :offset => 10)
213
213
  finder.options.keys.should include(:skip)
214
214
  finder.criteria.keys.should_not include(:skip)
215
215
  finder.criteria.keys.should_not include(:offset)
216
216
  end
217
217
 
218
218
  should "know limit is an option" do
219
- finder = FinderOptions.new(:limit => 10)
219
+ finder = FinderOptions.new(Room, :limit => 10)
220
220
  finder.options[:limit].should == 10
221
221
  finder.criteria.keys.should_not include(:limit)
222
222
  end
223
223
 
224
224
  should "know sort is an option" do
225
- finder = FinderOptions.new(:sort => [['foo', 1]])
225
+ finder = FinderOptions.new(Room, :sort => [['foo', 1]])
226
226
  finder.options[:sort].should == [['foo', 1]]
227
227
  finder.criteria.keys.should_not include(:sort)
228
228
  end
229
229
 
230
230
  # order gets converted to sort so just checking keys
231
231
  should "know order is an option" do
232
- finder = FinderOptions.new(:order => 'foo')
232
+ finder = FinderOptions.new(Room, :order => 'foo')
233
233
  finder.options.keys.should include(:sort)
234
234
  finder.criteria.keys.should_not include(:sort)
235
235
  end
236
236
 
237
237
  should "work with full range of things" do
238
- finder_options = FinderOptions.new({
238
+ finder_options = FinderOptions.new(Room, {
239
239
  :foo => 'bar',
240
240
  :baz => true,
241
241
  :sort => [['foo', 1]],