mongomodel 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. data/Appraisals +12 -0
  2. data/bin/console +1 -2
  3. data/gemfiles/mongo_mapper.gemfile +12 -0
  4. data/gemfiles/mongoid.gemfile +12 -0
  5. data/lib/mongomodel.rb +3 -0
  6. data/lib/mongomodel/compatibility/mongo_mapper.rb +23 -0
  7. data/lib/mongomodel/compatibility/mongoid.rb +17 -0
  8. data/lib/mongomodel/concerns/properties.rb +5 -0
  9. data/lib/mongomodel/concerns/validations.rb +5 -3
  10. data/lib/mongomodel/support/core_extensions.rb +4 -4
  11. data/lib/mongomodel/support/mongo_options.rb +4 -2
  12. data/lib/mongomodel/support/mongo_order.rb +4 -0
  13. data/lib/mongomodel/support/scope.rb +1 -1
  14. data/lib/mongomodel/version.rb +1 -1
  15. data/spec/mongomodel/attributes/store_spec.rb +12 -12
  16. data/spec/mongomodel/concerns/associations/belongs_to_spec.rb +13 -13
  17. data/spec/mongomodel/concerns/associations/has_many_by_foreign_key_spec.rb +25 -25
  18. data/spec/mongomodel/concerns/associations/has_many_by_ids_spec.rb +25 -25
  19. data/spec/mongomodel/concerns/attribute_methods/before_type_cast_spec.rb +5 -5
  20. data/spec/mongomodel/concerns/attribute_methods/dirty_spec.rb +21 -21
  21. data/spec/mongomodel/concerns/attribute_methods/multi_parameter_assignment_spec.rb +3 -3
  22. data/spec/mongomodel/concerns/attribute_methods/protected_spec.rb +10 -10
  23. data/spec/mongomodel/concerns/attribute_methods/query_spec.rb +6 -6
  24. data/spec/mongomodel/concerns/attribute_methods/read_spec.rb +6 -6
  25. data/spec/mongomodel/concerns/attribute_methods/write_spec.rb +5 -5
  26. data/spec/mongomodel/concerns/attribute_methods_spec.rb +5 -5
  27. data/spec/mongomodel/concerns/attributes_spec.rb +13 -13
  28. data/spec/mongomodel/concerns/callbacks_spec.rb +11 -11
  29. data/spec/mongomodel/concerns/logging_spec.rb +2 -2
  30. data/spec/mongomodel/concerns/observing_spec.rb +3 -3
  31. data/spec/mongomodel/concerns/pretty_inspect_spec.rb +5 -5
  32. data/spec/mongomodel/concerns/properties_spec.rb +6 -6
  33. data/spec/mongomodel/concerns/serialization/json_serialization_spec.rb +6 -6
  34. data/spec/mongomodel/concerns/timestamps_spec.rb +10 -10
  35. data/spec/mongomodel/concerns/translation_spec.rb +1 -1
  36. data/spec/mongomodel/concerns/validations_spec.rb +12 -4
  37. data/spec/mongomodel/document/callbacks_spec.rb +10 -10
  38. data/spec/mongomodel/document/collection_modifiers_spec.rb +1 -1
  39. data/spec/mongomodel/document/dynamic_finders_spec.rb +5 -5
  40. data/spec/mongomodel/document/finders_spec.rb +9 -9
  41. data/spec/mongomodel/document/indexes_spec.rb +19 -19
  42. data/spec/mongomodel/document/optimistic_locking_spec.rb +8 -8
  43. data/spec/mongomodel/document/persistence_spec.rb +38 -38
  44. data/spec/mongomodel/document/scopes_spec.rb +8 -8
  45. data/spec/mongomodel/document/validations/uniqueness_spec.rb +9 -9
  46. data/spec/mongomodel/document/validations_spec.rb +16 -16
  47. data/spec/mongomodel/document_spec.rb +11 -11
  48. data/spec/mongomodel/embedded_document_spec.rb +13 -13
  49. data/spec/mongomodel/mongomodel_spec.rb +4 -4
  50. data/spec/mongomodel/support/collection_spec.rb +40 -40
  51. data/spec/mongomodel/support/map_spec.rb +41 -41
  52. data/spec/mongomodel/support/mongo_operator_spec.rb +11 -9
  53. data/spec/mongomodel/support/mongo_options_spec.rb +17 -17
  54. data/spec/mongomodel/support/mongo_order_spec.rb +22 -22
  55. data/spec/mongomodel/support/property_spec.rb +21 -12
  56. data/spec/mongomodel/support/scope_spec.rb +134 -134
  57. data/spec/spec_helper.rb +1 -0
  58. data/spec/specdoc.opts +0 -3
  59. metadata +7 -5
@@ -16,19 +16,19 @@ module MongoModel
16
16
 
17
17
  it { should be_a_subclass_of(Hash) }
18
18
 
19
- it "should have from type String" do
19
+ it "has from type String" do
20
20
  subject.from.should == String
21
21
  end
22
22
 
23
- it "should have to type Object" do
23
+ it "has to type Object" do
24
24
  subject.to.should == Object
25
25
  end
26
26
 
27
- it "should not show its type when inspecting" do
27
+ it "does not show its type when inspecting" do
28
28
  subject.inspect.should == "Map"
29
29
  end
30
30
 
31
- it "should allow any string->object mappings to be added" do
31
+ it "allows any string->object mappings to be added" do
32
32
  map = subject.new
33
33
  map["hello"] = 123
34
34
  map["foo"] = "Bonjour"
@@ -36,18 +36,18 @@ module MongoModel
36
36
  map.should == { "hello" => 123, "foo" => "Bonjour", "mydoc" => doc }
37
37
  end
38
38
 
39
- it "should convert to mongo representation" do
39
+ it "converts to mongo representation" do
40
40
  map = subject.new({ "hello" => 123, "mydoc" => doc })
41
41
  map.to_mongo.should == { "hello" => 123, "mydoc" => { "_type" => 'TestDocument', "name" => "Foobar" } }
42
42
  end
43
43
 
44
- it "should load from mongo representation" do
44
+ it "loads from mongo representation" do
45
45
  map = subject.from_mongo({ "hello" => 123, "mydoc" => { "_type" => 'TestDocument', "name" => "Foobar" } })
46
46
  map.should be_a(subject)
47
47
  map.should == { "hello" => 123, "mydoc" => doc }
48
48
  end
49
49
 
50
- it "should cache map types" do
50
+ it "caches map types" do
51
51
  Map[Symbol => String].should equal(Map[Symbol => String])
52
52
  Map[String => TestDocument].should equal(Map[String => TestDocument])
53
53
  end
@@ -56,77 +56,77 @@ module MongoModel
56
56
  let(:klass) { Map[String => String] }
57
57
  subject { klass.new("123" => "456", "12.5" => "foobar") }
58
58
 
59
- it "should show its types when inspecting" do
59
+ it "shows its types when inspecting" do
60
60
  klass.inspect.should == "Map[String => String]"
61
61
  end
62
62
 
63
- it "should cast key/values when instantiating" do
63
+ it "casts key/values when instantiating" do
64
64
  map = klass.new(123 => 456, 12.5 => :foobar)
65
65
  map.should == { "123" => "456", "12.5" => "foobar" }
66
66
  end
67
67
 
68
- it "should cast keys on []" do
68
+ it "casts keys on []" do
69
69
  subject[123].should == "456"
70
70
  end
71
71
 
72
- it "should cast key/values on []=" do
72
+ it "casts key/values on []=" do
73
73
  subject[12.5] = 456
74
74
  subject["12.5"].should == "456"
75
75
  end
76
76
 
77
- it "should cast key/values on #store" do
77
+ it "casts key/values on #store" do
78
78
  subject.store(12.5, 456)
79
79
  subject["12.5"].should == "456"
80
80
  end
81
81
 
82
- it "should cast keys on #delete" do
82
+ it "casts keys on #delete" do
83
83
  subject.delete(123)
84
84
  subject["123"].should be_nil
85
85
  end
86
86
 
87
- it "should cast keys on #fetch" do
87
+ it "casts keys on #fetch" do
88
88
  subject.fetch(123).should == "456"
89
89
  subject.fetch(999, "default").should == "default"
90
90
  end
91
91
 
92
- it "should cast keys on #has_key?, #include?, #key?, #member?" do
92
+ it "casts keys on #has_key?, #include?, #key?, #member?" do
93
93
  subject.has_key?(123).should be_true
94
94
  subject.include?(12.5).should be_true
95
95
  subject.key?(123).should be_true
96
96
  subject.member?(12.5).should be_true
97
97
  end
98
98
 
99
- it "should cast values on #has_value?, #value?" do
99
+ it "casts values on #has_value?, #value?" do
100
100
  subject.has_value?(456).should be_true
101
101
  subject.value?(456).should be_true
102
102
  end
103
103
 
104
104
  if Hash.method_defined?(:key)
105
- it "should cast values on #key" do
105
+ it "casts values on #key" do
106
106
  subject.key(456).should == "123"
107
107
  end
108
108
  else
109
- it "should cast values on #index" do
109
+ it "casts values on #index" do
110
110
  subject.index(456).should == "123"
111
111
  end
112
112
  end
113
113
 
114
- it "should cast key/values on #replace" do
114
+ it "casts key/values on #replace" do
115
115
  subject.replace(321 => 654, 5.12 => :barbaz)
116
116
  subject.should == { "321" => "654", "5.12" => "barbaz" }
117
117
  end
118
118
 
119
- it "should cast key/values on #merge" do
119
+ it "casts key/values on #merge" do
120
120
  map = subject.merge(321 => 654, 5.12 => :barbaz)
121
121
  map.should == { "123" => "456", "12.5" => "foobar", "321" => "654", "5.12" => "barbaz" }
122
122
  end
123
123
 
124
- it "should cast key/values on #merge!" do
124
+ it "casts key/values on #merge!" do
125
125
  subject.merge!(321 => 654, 5.12 => :barbaz)
126
126
  subject.should == { "123" => "456", "12.5" => "foobar", "321" => "654", "5.12" => "barbaz" }
127
127
  end
128
128
 
129
- it "should cast keys on #values_at" do
129
+ it "casts keys on #values_at" do
130
130
  subject.values_at(12.5, 123).should == ["foobar", "456"]
131
131
  end
132
132
  end
@@ -138,77 +138,77 @@ module MongoModel
138
138
  let(:klass) { Map[Symbol => TestDocument] }
139
139
  subject { klass.new(:abc => doc1, :another => doc2) }
140
140
 
141
- it "should show its types when inspecting" do
141
+ it "shows its types when inspecting" do
142
142
  klass.inspect.should == "Map[Symbol => TestDocument]"
143
143
  end
144
144
 
145
- it "should cast key/values when instantiating" do
145
+ it "casts key/values when instantiating" do
146
146
  map = klass.new("foo" => "First", "123" => "Another")
147
147
  map.should == { :foo => doc1, :"123" => doc2 }
148
148
  end
149
149
 
150
- it "should cast keys on []" do
150
+ it "casts keys on []" do
151
151
  subject["abc"].should == doc1
152
152
  end
153
153
 
154
- it "should cast key/values on []=" do
154
+ it "casts key/values on []=" do
155
155
  subject["def"] = "Another"
156
156
  subject[:def].should == doc2
157
157
  end
158
158
 
159
- it "should cast key/values on #store" do
159
+ it "casts key/values on #store" do
160
160
  subject.store("def", "Another")
161
161
  subject[:def].should == doc2
162
162
  end
163
163
 
164
- it "should cast keys on #delete" do
164
+ it "casts keys on #delete" do
165
165
  subject.delete("abc")
166
166
  subject[:abc].should be_nil
167
167
  end
168
168
 
169
- it "should cast keys on #fetch" do
169
+ it "casts keys on #fetch" do
170
170
  subject.fetch("abc").should == doc1
171
171
  subject.fetch("999", "default").should == "default"
172
172
  end
173
173
 
174
- it "should cast keys on #has_key?, #include?, #key?, #member?" do
174
+ it "casts keys on #has_key?, #include?, #key?, #member?" do
175
175
  subject.has_key?("abc").should be_true
176
176
  subject.include?("another").should be_true
177
177
  subject.key?("abc").should be_true
178
178
  subject.member?("another").should be_true
179
179
  end
180
180
 
181
- it "should cast values on #has_value?, #value?" do
181
+ it "casts values on #has_value?, #value?" do
182
182
  subject.has_value?("First").should be_true
183
183
  subject.value?("Another").should be_true
184
184
  end
185
185
 
186
186
  if Hash.method_defined?(:key)
187
- it "should cast values on #key" do
187
+ it "casts values on #key" do
188
188
  subject.key("First").should == :abc
189
189
  end
190
190
  else
191
- it "should cast values on #index" do
191
+ it "casts values on #index" do
192
192
  subject.index("First").should == :abc
193
193
  end
194
194
  end
195
195
 
196
- it "should cast key/values on #replace" do
196
+ it "casts key/values on #replace" do
197
197
  subject.replace("321" => "Bonus", "hello" => "Another")
198
198
  subject.should == { :"321" => TestDocument.new(:name => "Bonus"), :hello => doc2 }
199
199
  end
200
200
 
201
- it "should cast key/values on #merge" do
201
+ it "casts key/values on #merge" do
202
202
  map = subject.merge("321" => "Bonus", "hello" => "Another")
203
203
  map.should == { :abc => doc1, :another => doc2, :"321" => TestDocument.new(:name => "Bonus"), :hello => doc2 }
204
204
  end
205
205
 
206
- it "should cast key/values on #merge!" do
206
+ it "casts key/values on #merge!" do
207
207
  subject.merge!("321" => "Bonus", "hello" => "Another")
208
208
  subject.should == { :abc => doc1, :another => doc2, :"321" => TestDocument.new(:name => "Bonus"), :hello => doc2 }
209
209
  end
210
210
 
211
- it "should cast keys on #values_at" do
211
+ it "casts keys on #values_at" do
212
212
  subject.values_at(:another, :abc).should == [doc2, doc1]
213
213
  end
214
214
  end
@@ -217,7 +217,7 @@ module MongoModel
217
217
  let(:klass) { Map[Date => String] }
218
218
  subject { klass.new(Date.civil(2009, 11, 15) => "Hello world") }
219
219
 
220
- it "should cast key to String on #to_mongo" do
220
+ it "casts key to String on #to_mongo" do
221
221
  subject.to_mongo.should == { "2009/11/15" => "Hello world" }
222
222
  end
223
223
  end
@@ -242,7 +242,7 @@ module MongoModel
242
242
 
243
243
  subject { TestDocument.new(:test_map => { "1" => child1, "2" => child2 }) }
244
244
 
245
- it "should include the map values in the embedded documents list" do
245
+ it "includes the map values in the embedded documents list" do
246
246
  subject.embedded_documents.should include(child1, child2)
247
247
  end
248
248
  end
@@ -254,7 +254,7 @@ module MongoModel
254
254
 
255
255
  subject { TestDocument.new }
256
256
 
257
- it "should default to an empty map" do
257
+ it "defaults to an empty map" do
258
258
  subject.test_map.should be_an_instance_of(Map[Symbol => ChildDocument])
259
259
  subject.test_map.should be_empty
260
260
  end
@@ -267,7 +267,7 @@ module MongoModel
267
267
 
268
268
  subject { TestDocument.new }
269
269
 
270
- it "should cast key/values to map type" do
270
+ it "casts key/values to map type" do
271
271
  subject.test_map[:abc].should == ChildDocument.new(:name => 'abc')
272
272
  subject.test_map[:def].should == ChildDocument.new(:name => 'def')
273
273
  end
@@ -4,26 +4,28 @@ module MongoModel
4
4
  describe MongoOperator do
5
5
  subject { MongoOperator.new(:age, :gt) }
6
6
 
7
- it "should convert to mongo selector" do
7
+ it "converts to mongo selector" do
8
8
  subject.to_mongo_selector(14).should == { '$gt' => 14 }
9
9
  end
10
10
 
11
- it "should be equal to a MongoOperator with the same field and operator" do
11
+ it "is equal to a MongoOperator with the same field and operator" do
12
12
  subject.should == MongoOperator.new(:age, :gt)
13
13
  end
14
14
 
15
- it "should not be equal to a MongoOperator with a different field/operator" do
15
+ it "is not equal to a MongoOperator with a different field/operator" do
16
16
  subject.should_not == MongoOperator.new(:age, :lte)
17
17
  subject.should_not == MongoOperator.new(:date, :gt)
18
18
  end
19
-
20
- it "should be created from symbol methods" do
21
- :age.gt.should == MongoOperator.new(:age, :gt)
22
- :date.lte.should == MongoOperator.new(:date, :lte)
23
- :position.near.should == MongoOperator.new(:position, :near)
19
+
20
+ unless defined?(Origin) || defined?(SymbolOperator)
21
+ it "is created from symbol methods" do
22
+ :age.gt.should == MongoOperator.new(:age, :gt)
23
+ :date.lte.should == MongoOperator.new(:date, :lte)
24
+ :position.near.should == MongoOperator.new(:position, :near)
25
+ end
24
26
  end
25
27
 
26
- it "should be equal within a hash" do
28
+ it "is equal within a hash" do
27
29
  { :age.gt => 10 }.should == { :age.gt => 10 }
28
30
  end
29
31
  end
@@ -5,13 +5,13 @@ module MongoModel
5
5
  define_class(:TestDocument, Document)
6
6
 
7
7
  shared_examples_for "options without conditions" do
8
- it "should have an empty selector hash" do
8
+ it "has an empty selector hash" do
9
9
  subject.selector.should == {}
10
10
  end
11
11
  end
12
12
 
13
13
  shared_examples_for "options with conditions only" do
14
- it "should have an empty options hash" do
14
+ it "has an empty options hash" do
15
15
  subject.options.should == {}
16
16
  end
17
17
  end
@@ -21,7 +21,7 @@ module MongoModel
21
21
 
22
22
  it_should_behave_like "options without conditions"
23
23
 
24
- it "should have an empty options hash" do
24
+ it "has an empty options hash" do
25
25
  subject.options.should == {}
26
26
  end
27
27
  end
@@ -31,7 +31,7 @@ module MongoModel
31
31
 
32
32
  it_should_behave_like "options with conditions only"
33
33
 
34
- it "should include the conditions in the selector" do
34
+ it "includes the conditions in the selector" do
35
35
  subject.selector.should == { :foo => 'bar' }
36
36
  end
37
37
  end
@@ -41,7 +41,7 @@ module MongoModel
41
41
 
42
42
  it_should_behave_like "options with conditions only"
43
43
 
44
- it "should include the expanded conditions in the selector" do
44
+ it "includes the expanded conditions in the selector" do
45
45
  subject.selector.should == { :age => { '$gt' => 10 } }
46
46
  end
47
47
  end
@@ -51,7 +51,7 @@ module MongoModel
51
51
 
52
52
  it_should_behave_like "options with conditions only"
53
53
 
54
- it "should merge conditions in the selector" do
54
+ it "merges conditions in the selector" do
55
55
  subject.selector.should == { :age => { '$gt' => 10, '$lte' => 18 } }
56
56
  end
57
57
  end
@@ -61,7 +61,7 @@ module MongoModel
61
61
 
62
62
  it_should_behave_like "options with conditions only"
63
63
 
64
- it "should use the property as value in the selector" do
64
+ it "uses the property as value in the selector" do
65
65
  subject.selector.should == { '_id' => '123' }
66
66
  end
67
67
  end
@@ -71,7 +71,7 @@ module MongoModel
71
71
 
72
72
  it_should_behave_like "options without conditions"
73
73
 
74
- it "should include converted options in options hash" do
74
+ it "includes converted options in options hash" do
75
75
  subject.options.should == { :skip => 20, :limit => 10, :fields => [ :foo, :bar ]}
76
76
  end
77
77
  end
@@ -81,7 +81,7 @@ module MongoModel
81
81
 
82
82
  it_should_behave_like "options without conditions"
83
83
 
84
- it "should convert order to sort in options hash" do
84
+ it "converts order to sort in options hash" do
85
85
  subject.options.should == { :sort => [ ['foo', :descending] ] }
86
86
  end
87
87
  end
@@ -91,7 +91,7 @@ module MongoModel
91
91
 
92
92
  it_should_behave_like "options without conditions"
93
93
 
94
- it "should convert order to sort in options hash" do
94
+ it "converts order to sort in options hash" do
95
95
  subject.options.should == { :sort => [ ['bar', :ascending] ]}
96
96
  end
97
97
  end
@@ -101,7 +101,7 @@ module MongoModel
101
101
 
102
102
  it_should_behave_like "options without conditions"
103
103
 
104
- it "should convert order to sort in options hash" do
104
+ it "converts order to sort in options hash" do
105
105
  subject.options.should == { :sort => [ ['bar', :ascending] ]}
106
106
  end
107
107
  end
@@ -111,7 +111,7 @@ module MongoModel
111
111
 
112
112
  it_should_behave_like "options without conditions"
113
113
 
114
- it "should convert order to sort in options hash" do
114
+ it "converts order to sort in options hash" do
115
115
  subject.options.should == { :sort => [ ['foo', :ascending], ['bar', :descending]] }
116
116
  end
117
117
  end
@@ -121,7 +121,7 @@ module MongoModel
121
121
 
122
122
  it_should_behave_like "options without conditions"
123
123
 
124
- it "should convert order to sort in options hash" do
124
+ it "converts order to sort in options hash" do
125
125
  subject.options.should == { :sort => [ ['foo', :descending], ['baz', :ascending] ] }
126
126
  end
127
127
  end
@@ -131,7 +131,7 @@ module MongoModel
131
131
 
132
132
  it_should_behave_like "options without conditions"
133
133
 
134
- it "should use property as value as sort column" do
134
+ it "uses property as value as sort column" do
135
135
  subject.options.should == { :sort => [ ['_id', :descending] ] }
136
136
  end
137
137
  end
@@ -139,15 +139,15 @@ module MongoModel
139
139
  context "with conditions and options" do
140
140
  subject { MongoOptions.new(TestDocument, :conditions => { :age => 18 }, :order => :id.desc, :limit => 5) }
141
141
 
142
- it "should use conditions for selector" do
142
+ it "uses conditions for selector" do
143
143
  subject.selector.should == { :age => 18 }
144
144
  end
145
145
 
146
- it "should convert options" do
146
+ it "converts options" do
147
147
  subject.options.should == { :sort => [ ['_id', :descending] ], :limit => 5 }
148
148
  end
149
149
 
150
- it "should convert to array" do
150
+ it "converts to array" do
151
151
  subject.to_a.should == [ subject.selector, subject.options ]
152
152
  end
153
153
  end
@@ -8,64 +8,64 @@ module MongoModel
8
8
 
9
9
  subject { MongoOrder.new(c(:name, :ascending), c(:age, :descending)) }
10
10
 
11
- it "should convert to string" do
11
+ it "converts to string" do
12
12
  subject.to_s.should == "name ascending, age descending"
13
13
  end
14
14
 
15
15
  describe "#to_sort" do
16
- it "should convert to mongo sort array" do
16
+ it "converts to mongo sort array" do
17
17
  model = mock('model', :properties => mock('properties', :[] => nil))
18
18
  subject.to_sort(model).should == [['name', :ascending], ['age', :descending]]
19
19
  end
20
20
  end
21
21
 
22
- it "should be reversable" do
22
+ it "is reversable" do
23
23
  subject.reverse.should == MongoOrder.new(c(:name, :descending), c(:age, :ascending))
24
24
  end
25
25
 
26
- it "should equal another order object with identical clauses" do
26
+ it "equals another order object with identical clauses" do
27
27
  subject.should == MongoOrder.new(c(:name, :ascending), c(:age, :descending))
28
28
  end
29
29
 
30
- it "should equal another order object with different clauses" do
30
+ it "equals another order object with different clauses" do
31
31
  subject.should_not == MongoOrder.new(c(:name, :ascending))
32
32
  subject.should_not == MongoOrder.new(c(:age, :ascending), c(:name, :ascending))
33
33
  end
34
34
 
35
35
  describe "#parse" do
36
- it "should not change a MongoOrder" do
36
+ it "does not change a MongoOrder" do
37
37
  MongoOrder.parse(subject).should == subject
38
38
  end
39
39
 
40
- it "should convert individual clause to MongoOrder" do
40
+ it "converts individual clause to MongoOrder" do
41
41
  MongoOrder.parse(c(:name, :ascending)).should == MongoOrder.new(c(:name, :ascending))
42
42
  end
43
43
 
44
- it "should convert symbol to MongoOrder" do
44
+ it "converts symbol to MongoOrder" do
45
45
  MongoOrder.parse(:name).should == MongoOrder.new(c(:name, :ascending))
46
46
  end
47
47
 
48
- it "should convert array of clauses to MongoOrder" do
48
+ it "converts array of clauses to MongoOrder" do
49
49
  MongoOrder.parse([c(:name, :ascending), c(:age, :descending)]).should == MongoOrder.new(c(:name, :ascending), c(:age, :descending))
50
50
  end
51
51
 
52
- it "should convert array of symbols to MongoOrder" do
52
+ it "converts array of symbols to MongoOrder" do
53
53
  MongoOrder.parse([:name, :age]).should == MongoOrder.new(c(:name, :ascending), c(:age, :ascending))
54
54
  end
55
55
 
56
- it "should convert array of strings to MongoOrder" do
56
+ it "converts array of strings to MongoOrder" do
57
57
  MongoOrder.parse(['name ASC', 'age DESC']).should == MongoOrder.new(c(:name, :ascending), c(:age, :descending))
58
58
  end
59
59
 
60
- it "should convert string (no order specified) to MongoOrder" do
60
+ it "converts string (no order specified) to MongoOrder" do
61
61
  MongoOrder.parse('name').should == MongoOrder.new(c(:name, :ascending))
62
62
  end
63
63
 
64
- it "should convert string (single order) to MongoOrder" do
64
+ it "converts string (single order) to MongoOrder" do
65
65
  MongoOrder.parse('name DESC').should == MongoOrder.new(c(:name, :descending))
66
66
  end
67
67
 
68
- it "should convert string (multiple orders) to MongoOrder" do
68
+ it "converts string (multiple orders) to MongoOrder" do
69
69
  MongoOrder.parse('name DESC, age ASC').should == MongoOrder.new(c(:name, :descending), c(:age, :ascending))
70
70
  end
71
71
  end
@@ -74,33 +74,33 @@ module MongoModel
74
74
  describe MongoOrder::Clause do
75
75
  subject { MongoOrder::Clause.new(:name, :ascending) }
76
76
 
77
- it "should convert to string" do
77
+ it "converts to string" do
78
78
  subject.to_s.should == "name ascending"
79
79
  end
80
80
 
81
- it "should equal another clause with the same field and order" do
81
+ it "equals another clause with the same field and order" do
82
82
  subject.should == MongoOrder::Clause.new(:name, :ascending)
83
83
  end
84
84
 
85
- it "should equal another clause with a different field or order" do
85
+ it "equals another clause with a different field or order" do
86
86
  subject.should_not == MongoOrder::Clause.new(:age, :ascending)
87
87
  subject.should_not == MongoOrder::Clause.new(:name, :descending)
88
88
  end
89
89
 
90
- it "should be reversable" do
90
+ it "is reversable" do
91
91
  subject.reverse.should == MongoOrder::Clause.new(:name, :descending)
92
92
  end
93
93
 
94
94
  describe "#to_sort" do
95
95
  context "given property" do
96
- it "should use property as value to convert to mongo sort" do
96
+ it "uses property as value to convert to mongo sort" do
97
97
  property = mock('property', :as => '_name')
98
98
  subject.to_sort(property).should == ['_name', :ascending]
99
99
  end
100
100
  end
101
101
 
102
102
  context "given nil" do
103
- it "should convert to mongo sort" do
103
+ it "converts to mongo sort" do
104
104
  subject.to_sort(nil).should == ['name', :ascending]
105
105
  end
106
106
  end
@@ -110,11 +110,11 @@ module MongoModel
110
110
  let(:asc) { MongoOrder::Clause.new(:name, :ascending) }
111
111
  let(:desc) { MongoOrder::Clause.new(:name, :descending) }
112
112
 
113
- it "should create Clause from string (no order)" do
113
+ it "creates Clause from string (no order)" do
114
114
  MongoOrder::Clause.parse('name').should == asc
115
115
  end
116
116
 
117
- it "should create Clause from string (with order)" do
117
+ it "creates Clause from string (with order)" do
118
118
  MongoOrder::Clause.parse('name ASC').should == asc
119
119
  MongoOrder::Clause.parse('name asc').should == asc
120
120
  MongoOrder::Clause.parse('name ascending').should == asc