mongomodel 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -14,7 +14,7 @@ module MongoModel
14
14
  subject { TestDocument.new }
15
15
 
16
16
  describe "#save" do
17
- it "should return false" do
17
+ it "returns false" do
18
18
  subject.save.should be_false
19
19
  end
20
20
  end
@@ -24,23 +24,23 @@ module MongoModel
24
24
  subject.errors.stub!(:full_messages).and_return(["first error", "second error"])
25
25
  end
26
26
 
27
- it "should raise a MongoModel::DocumentInvalid exception" do
27
+ it "raises a MongoModel::DocumentInvalid exception" do
28
28
  lambda { subject.save! }.should raise_error(MongoModel::DocumentInvalid, "Validation failed: first error, second error")
29
29
  end
30
30
  end
31
31
 
32
32
  shared_examples_for "saving without validation" do
33
- it "should not validate the document" do
33
+ it "does not validate the document" do
34
34
  subject.should_not_receive(:valid?)
35
35
  save
36
36
  end
37
37
 
38
- it "should save the document" do
38
+ it "saves the document" do
39
39
  subject.should_receive(:create_or_update).and_return(true)
40
40
  save
41
41
  end
42
42
 
43
- it "should return true" do
43
+ it "returns true" do
44
44
  save.should be_true
45
45
  end
46
46
  end
@@ -67,11 +67,11 @@ module MongoModel
67
67
  TestDocument.validates_presence_of :title, :on => :custom
68
68
  end
69
69
 
70
- it "should save in default context" do
70
+ it "saves in default context" do
71
71
  subject.save.should be_true
72
72
  end
73
73
 
74
- it "should not save in custom context" do
74
+ it "does not save in custom context" do
75
75
  subject.save(:context => :custom).should be_false
76
76
  end
77
77
  end
@@ -86,17 +86,17 @@ module MongoModel
86
86
  end
87
87
 
88
88
  context "attributes hash" do
89
- it "should pass attributes to instance" do
89
+ it "passes attributes to instance" do
90
90
  @user = User.create!(:name => 'Test', :age => 18)
91
91
  @user.name.should == 'Test'
92
92
  @user.age.should == 18
93
93
  end
94
94
 
95
- it "should save! the instance" do
95
+ it "saves! the instance" do
96
96
  User.create!(:name => 'Test').should_not be_a_new_record
97
97
  end
98
98
 
99
- it "should yield the instance to a given block before saving" do
99
+ it "yields the instance to a given block before saving" do
100
100
  block_called = false
101
101
 
102
102
  User.create!(:name => 'Test') do |u|
@@ -109,7 +109,7 @@ module MongoModel
109
109
  block_called.should be_true
110
110
  end
111
111
 
112
- it "should raise an exception if the document is invalid" do
112
+ it "raises an exception if the document is invalid" do
113
113
  lambda { User.create! }.should raise_error(DocumentInvalid)
114
114
  end
115
115
  end
@@ -119,7 +119,7 @@ module MongoModel
119
119
  User.create!([{ :name => 'Test', :age => 18 }, { :name => 'Second', :age => 21 }], &block)
120
120
  end
121
121
 
122
- it "should return instances in array with associated attributes" do
122
+ it "returns instances in array with associated attributes" do
123
123
  @users = create_users
124
124
  @users[0].name.should == 'Test'
125
125
  @users[0].age.should == 18
@@ -127,11 +127,11 @@ module MongoModel
127
127
  @users[1].age.should == 21
128
128
  end
129
129
 
130
- it "should save! each instance" do
130
+ it "saves! each instance" do
131
131
  create_users.each { |user| user.should_not be_a_new_record }
132
132
  end
133
133
 
134
- it "should yield each instance to a given block before saving" do
134
+ it "yields each instance to a given block before saving" do
135
135
  block_called = 0
136
136
 
137
137
  create_users do |u|
@@ -144,7 +144,7 @@ module MongoModel
144
144
  block_called.should == 2
145
145
  end
146
146
 
147
- it "should raise an exception if a document is invalid" do
147
+ it "raises an exception if a document is invalid" do
148
148
  lambda { User.create!([ {}, {} ]) }.should raise_error(DocumentInvalid)
149
149
  end
150
150
  end
@@ -155,7 +155,7 @@ module MongoModel
155
155
  define_class(:TestDocument, Document)
156
156
 
157
157
  describe ":unique => true" do
158
- it "should add a validates_uniqueness_of validation" do
158
+ it "adds a validates_uniqueness_of validation" do
159
159
  TestDocument.should_receive(:validates_uniqueness_of).with(:title)
160
160
  TestDocument.property :title, String, :unique => true
161
161
  end
@@ -2,11 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  module MongoModel
4
4
  specs_for(Document) do
5
- it "should inherit from EmbeddedDocument" do
5
+ it "inherits from EmbeddedDocument" do
6
6
  Document.ancestors.should include(EmbeddedDocument)
7
7
  end
8
8
 
9
- it "should have an id property" do
9
+ it "has an id property" do
10
10
  property = Document.properties[:id]
11
11
  property.name.should == :id
12
12
  property.as.should == '_id'
@@ -19,15 +19,15 @@ module MongoModel
19
19
 
20
20
  subject { DocumentA.new(:id => 'test') }
21
21
 
22
- it "should be equal to another document of the same class with the same id" do
22
+ it "is equal to another document of the same class with the same id" do
23
23
  subject.should == DocumentA.new(:id => 'test')
24
24
  end
25
25
 
26
- it "should not be equal to another document of the same class with a different id" do
26
+ it "is not equal to another document of the same class with a different id" do
27
27
  subject.should_not == DocumentA.new(:id => 'not-test')
28
28
  end
29
29
 
30
- it "should not be equal to another document of a different class with the same id" do
30
+ it "is not equal to another document of a different class with the same id" do
31
31
  subject.should_not == DocumentB.new(:id => 'test')
32
32
  end
33
33
  end
@@ -53,12 +53,12 @@ module MongoModel
53
53
  @missing = missing
54
54
  end
55
55
 
56
- it "should belong to the same collection as its parent" do
56
+ it "belongs to the same collection as its parent" do
57
57
  SpecialEvent.collection_name.should == Event.collection_name
58
58
  VerySpecialEvent.collection_name.should == Event.collection_name
59
59
  end
60
60
 
61
- it "should be an instance of the correct class when loaded" do
61
+ it "is an instance of the correct class when loaded" do
62
62
  Event.find(@event.id).should be_an_instance_of(Event)
63
63
  Event.find(@special.id).should be_an_instance_of(SpecialEvent)
64
64
  Event.find(@very_special.id).should be_an_instance_of(VerySpecialEvent)
@@ -69,21 +69,21 @@ module MongoModel
69
69
  VerySpecialEvent.find(@very_special.id).should be_an_instance_of(VerySpecialEvent)
70
70
  end
71
71
 
72
- it "should default to superclass type if type missing" do
72
+ it "defaults to superclass type if type missing" do
73
73
  Event.find(@missing.id).should be_an_instance_of(Event)
74
74
  end
75
75
 
76
- it "should consider document missing when finding from subclass using id of parent instance" do
76
+ it "considers document missing when finding from subclass using id of parent instance" do
77
77
  lambda { SpecialEvent.find(@event.id) }.should raise_error(MongoModel::DocumentNotFound)
78
78
  lambda { VerySpecialEvent.find(@special.id) }.should raise_error(MongoModel::DocumentNotFound)
79
79
  end
80
80
 
81
81
  describe "loading documents" do
82
- it "should load all documents from root class" do
82
+ it "loads all documents from root class" do
83
83
  Event.all.should include(@event, @special, @very_special, @super_special, @missing)
84
84
  end
85
85
 
86
- it "should only load subclass documents from subclass" do
86
+ it "only loads subclass documents from subclass" do
87
87
  SpecialEvent.all.should include(@special, @very_special, @super_special)
88
88
  SpecialEvent.all.should_not include(@event, @missing)
89
89
 
@@ -2,18 +2,18 @@ require 'spec_helper'
2
2
 
3
3
  module MongoModel
4
4
  specs_for(EmbeddedDocument, Document) do
5
- it "should be an abstract class" do
5
+ it "is an abstract class" do
6
6
  described_class.should be_an_abstract_class
7
7
  end
8
8
 
9
- it "should instantiate with nil" do
9
+ it "instantiates with nil" do
10
10
  described_class.new(nil).should be_an_instance_of(described_class)
11
11
  end
12
12
 
13
13
  describe "subclasses" do
14
14
  define_class(:TestDocument, described_class)
15
15
 
16
- it "should not be an abstract class" do
16
+ it "is not an abstract class" do
17
17
  TestDocument.should_not be_an_abstract_class
18
18
  end
19
19
  end
@@ -44,52 +44,52 @@ module MongoModel
44
44
 
45
45
  subject { DocumentA.new(:id => 'test', :name => 'Test') }
46
46
 
47
- it "should be equal to another document of the same class with identical attributes" do
47
+ it "is equal to another document of the same class with identical attributes" do
48
48
  subject.should == DocumentA.new(:id => 'test', :name => 'Test')
49
49
  end
50
50
 
51
- it "should not be equal to another document of the same class with different attributes" do
51
+ it "is not equal to another document of the same class with different attributes" do
52
52
  subject.should_not == DocumentA.new(:id => 'test', :name => 'Different')
53
53
  subject.should_not == DocumentA.new(:id => 'test', :name => 'Test', :special_attribute => 'Different')
54
54
  end
55
55
 
56
- it "should not be equal to another document of a different class with identical attributes" do
56
+ it "is not equal to another document of a different class with identical attributes" do
57
57
  subject.should_not == DocumentB.new(:id => 'test', :name => 'Different')
58
58
  end
59
59
  end
60
60
 
61
61
  describe "single collection inheritance" do
62
- it "should not typecast to parent type when assigning to property" do
62
+ it "does not typecast to parent type when assigning to property" do
63
63
  parent.event.should be_an_instance_of(SpecialEvent)
64
64
  end
65
65
 
66
- it "should be an instance of the correct class when reloaded" do
66
+ it "is an instance of the correct class when reloaded" do
67
67
  reloaded.event.should be_an_instance_of(SpecialEvent)
68
68
  end
69
69
  end
70
70
 
71
71
  describe "parent document" do
72
72
  context "on an embedded document" do
73
- it "should set the parent document on the embedded document" do
73
+ it "sets the parent document on the embedded document" do
74
74
  parent.event.parent_document.should == parent
75
75
  end
76
76
 
77
- it "should set the parent document on the embedded document when loaded from database" do
77
+ it "sets the parent document on the embedded document when loaded from database" do
78
78
  reloaded.event.parent_document.should == reloaded
79
79
  end
80
80
  end
81
81
 
82
82
  context "on a collection" do
83
- it "should set the parent document on the collection" do
83
+ it "sets the parent document on the collection" do
84
84
  parent.events.parent_document.should == parent
85
85
  end
86
86
 
87
- it "should set the parent document on each item added to a collection" do
87
+ it "sets the parent document on each item added to a collection" do
88
88
  parent.events << special
89
89
  parent.events.first.parent_document.should == parent
90
90
  end
91
91
 
92
- it "should set the parent document on each item in a collection when loaded from database" do
92
+ it "sets the parent document on each item in a collection when loaded from database" do
93
93
  parent.events << special
94
94
  reloaded.events.first.parent_document.should == parent
95
95
  end
@@ -13,13 +13,13 @@ describe MongoModel do
13
13
  }
14
14
  end
15
15
 
16
- it "should should merge configuration with defaults" do
16
+ it "shoulds merge configuration with defaults" do
17
17
  MongoModel.configuration.host.should == '127.0.0.1'
18
18
  MongoModel.configuration.port.should == 27017
19
19
  MongoModel.configuration.database.should == 'mydb'
20
20
  end
21
21
 
22
- it "should establish database connection to given database" do
22
+ it "establishes database connection to given database" do
23
23
  database = MongoModel.database
24
24
  connection = database.connection
25
25
 
@@ -34,14 +34,14 @@ describe MongoModel do
34
34
  MongoModel.configuration = "mongodb://127.0.0.2:27019/mydb"
35
35
  end
36
36
 
37
- it "should should merge configuration with defaults" do
37
+ it "shoulds merge configuration with defaults" do
38
38
  MongoModel.configuration.host.should == '127.0.0.2'
39
39
  MongoModel.configuration.port.should == 27019
40
40
  MongoModel.configuration.database.should == 'mydb'
41
41
  end
42
42
  end
43
43
 
44
- it "should have a logger accessor" do
44
+ it "has a logger accessor" do
45
45
  logger = mock('logger').as_null_object
46
46
  MongoModel.logger = logger
47
47
  MongoModel.logger.should == logger
@@ -9,15 +9,15 @@ module MongoModel
9
9
 
10
10
  it { should be_a_subclass_of(Array) }
11
11
 
12
- it "should have type Object" do
12
+ it "has type Object" do
13
13
  subject.type.should == Object
14
14
  end
15
15
 
16
- it "should not show its type when inspecting" do
16
+ it "does not show its type when inspecting" do
17
17
  subject.inspect.should == "Collection"
18
18
  end
19
19
 
20
- it "should allow any object to be added to the collection" do
20
+ it "allows any object to be added to the collection" do
21
21
  collection = subject.new
22
22
  collection << 123
23
23
  collection << "Hello"
@@ -25,18 +25,18 @@ module MongoModel
25
25
  collection.should == [123, "Hello", doc]
26
26
  end
27
27
 
28
- it "should convert to mongo representation" do
28
+ it "converts to mongo representation" do
29
29
  collection = subject.new([123, "Hello", doc])
30
30
  collection.to_mongo.should == [123, "Hello", { "_type" => 'TestDocument' }]
31
31
  end
32
32
 
33
- it "should load from mongo representation" do
33
+ it "loads from mongo representation" do
34
34
  collection = subject.from_mongo([123, "Hello", { "_type" => 'TestDocument' }])
35
35
  collection.should be_a(subject)
36
36
  collection.should == [123, "Hello", doc]
37
37
  end
38
38
 
39
- it "should cache collection types" do
39
+ it "caches collection types" do
40
40
  Collection[String].should equal(Collection[String])
41
41
  Collection[TestDocument].should equal(Collection[TestDocument])
42
42
  end
@@ -47,20 +47,20 @@ module MongoModel
47
47
  it { should be_a_subclass_of(Collection) }
48
48
  it { should be_a_subclass_of(Array) }
49
49
 
50
- it "should have type String" do
50
+ it "has type String" do
51
51
  subject.type.should == String
52
52
  end
53
53
 
54
- it "should show its type when inspecting" do
54
+ it "shows its type when inspecting" do
55
55
  subject.inspect.should == "Collection[String]"
56
56
  end
57
57
 
58
- it "should convert to mongo representation" do
58
+ it "converts to mongo representation" do
59
59
  collection = subject.new(["a", "bcd", "efg"])
60
60
  collection.to_mongo.should == ["a", "bcd", "efg"]
61
61
  end
62
62
 
63
- it "should load from mongo representation" do
63
+ it "loads from mongo representation" do
64
64
  collection = subject.from_mongo(["a", "bcd", "efg"])
65
65
  collection.should be_a(subject)
66
66
  collection.should == ["a", "bcd", "efg"]
@@ -69,73 +69,73 @@ module MongoModel
69
69
  describe "casting" do
70
70
  subject { Collection[String].new }
71
71
 
72
- it "should cast elements when instantiating" do
72
+ it "casts elements when instantiating" do
73
73
  Collection[String].new(["abc", 123, 56.2]).should == ["abc", "123", "56.2"]
74
74
  end
75
75
 
76
- it "should cast elements on <<" do
76
+ it "casts elements on <<" do
77
77
  subject << "abc"
78
78
  subject << 123
79
79
  subject << 56.2
80
80
  subject.should == ["abc", "123", "56.2"]
81
81
  end
82
82
 
83
- it "should cast elements on []=" do
83
+ it "casts elements on []=" do
84
84
  subject[0] = "abc"
85
85
  subject[1] = 123
86
86
  subject[2] = 56.2
87
87
  subject.should == ["abc", "123", "56.2"]
88
88
  end
89
89
 
90
- it "should cast elements on +" do
90
+ it "casts elements on +" do
91
91
  result = subject + ["abc", 123, 56.2]
92
92
  result.should be_an_instance_of(Collection[String])
93
93
  result.should == ["abc", "123", "56.2"]
94
94
  end
95
95
 
96
- it "should cast elements on concat" do
96
+ it "casts elements on concat" do
97
97
  subject.concat(["abc", 123, 56.2])
98
98
  subject.should == ["abc", "123", "56.2"]
99
99
  end
100
100
 
101
- it "should cast elements on delete" do
101
+ it "casts elements on delete" do
102
102
  subject.push("abc", 123, 56.2)
103
103
  subject.delete(123)
104
104
  subject.delete(56.2)
105
105
  subject.should == ["abc"]
106
106
  end
107
107
 
108
- it "should cast elements on index" do
108
+ it "casts elements on index" do
109
109
  subject.push("abc", 123, 56.2)
110
110
  subject.index(123).should == 1
111
111
  subject.index(56.2).should == 2
112
112
  end
113
113
 
114
- it "should cast elements on insert" do
114
+ it "casts elements on insert" do
115
115
  subject.insert(0, 56.2)
116
116
  subject.insert(0, "abc")
117
117
  subject.insert(1, 123)
118
118
  subject.should == ["abc", "123", "56.2"]
119
119
  end
120
120
 
121
- it "should cast elements on push" do
121
+ it "casts elements on push" do
122
122
  subject.push("abc", 123, 56.2)
123
123
  subject.should == ["abc", "123", "56.2"]
124
124
  end
125
125
 
126
- it "should cast elements on rindex" do
126
+ it "casts elements on rindex" do
127
127
  subject.push("abc", 123, 56.2, 123)
128
128
  subject.rindex(123).should == 3
129
129
  subject.rindex(56.2).should == 2
130
130
  end
131
131
 
132
- it "should cast elements on unshift" do
132
+ it "casts elements on unshift" do
133
133
  subject.unshift("abc")
134
134
  subject.unshift(123, 56.2)
135
135
  subject.should == ["123", "56.2", "abc"]
136
136
  end
137
137
 
138
- it "should cast elements on include?" do
138
+ it "casts elements on include?" do
139
139
  subject.push("abc", 123, 56.2)
140
140
  subject.should include(123)
141
141
  subject.should include(56.2)
@@ -150,20 +150,20 @@ module MongoModel
150
150
  it { should be_a_subclass_of(Collection) }
151
151
  it { should be_a_subclass_of(Array) }
152
152
 
153
- it "should have type TestDocument" do
153
+ it "has type TestDocument" do
154
154
  subject.type.should == TestDocument
155
155
  end
156
156
 
157
- it "should show its type when inspecting" do
157
+ it "shows its type when inspecting" do
158
158
  subject.inspect.should == "Collection[TestDocument]"
159
159
  end
160
160
 
161
- it "should convert to mongo representation" do
161
+ it "converts to mongo representation" do
162
162
  collection = subject.new([doc])
163
163
  collection.to_mongo.should == [{ "_type" => 'TestDocument' }]
164
164
  end
165
165
 
166
- it "should load from mongo representation" do
166
+ it "loads from mongo representation" do
167
167
  collection = subject.from_mongo([{ "_type" => 'TestDocument' }])
168
168
  collection.should be_a(subject)
169
169
  collection.should == [doc]
@@ -176,26 +176,26 @@ module MongoModel
176
176
  it { should be_a_subclass_of(Collection) }
177
177
  it { should be_a_subclass_of(Array) }
178
178
 
179
- it "should have type CustomClass" do
179
+ it "has type CustomClass" do
180
180
  subject.type.should == CustomClass
181
181
  end
182
182
 
183
- it "should show its type when inspecting" do
183
+ it "shows its type when inspecting" do
184
184
  subject.inspect.should == "Collection[CustomClass]"
185
185
  end
186
186
 
187
- it "should convert to mongo representation" do
187
+ it "converts to mongo representation" do
188
188
  collection = subject.new([CustomClass.new("abc"), CustomClass.new("123")])
189
189
  collection.to_mongo.should == [{ :name => "abc" }, { :name => "123" }]
190
190
  end
191
191
 
192
- it "should load from mongo representation" do
192
+ it "loads from mongo representation" do
193
193
  collection = subject.from_mongo([{ :name => "abc" }, { :name => "123" }])
194
194
  collection.should be_a(subject)
195
195
  collection.should == [CustomClass.new("abc"), CustomClass.new("123")]
196
196
  end
197
197
 
198
- it "should load from mongo representation of single item" do
198
+ it "loads from mongo representation of single item" do
199
199
  collection = subject.from_mongo({ :name => "abc" })
200
200
  collection.should be_a(subject)
201
201
  collection.should == [CustomClass.new("abc")]
@@ -211,16 +211,16 @@ module MongoModel
211
211
 
212
212
  subject { TestDocument.new }
213
213
 
214
- it "should cast items to collection type" do
214
+ it "casts items to collection type" do
215
215
  subject.test_collection.should == [CustomClass.new('abc'), CustomClass.new('def')]
216
216
  end
217
217
 
218
- it "should allow items to be added to collection" do
218
+ it "allows items to be added to collection" do
219
219
  subject.test_collection << '123'
220
220
  subject.test_collection.should == [CustomClass.new('abc'), CustomClass.new('def'), CustomClass.new('123')]
221
221
  end
222
222
 
223
- it "should not share collections between instances" do
223
+ it "does not share collections between instances" do
224
224
  subject.test_collection << '123'
225
225
  TestDocument.new.test_collection.should_not == subject.test_collection
226
226
  end
@@ -243,30 +243,30 @@ module MongoModel
243
243
  let(:empty) { TestDocument.new }
244
244
  subject { TestDocument.new(:embedded => embedded1, :embedded_collection => [embedded2, embedded3]) }
245
245
 
246
- it "should default to an empty collection" do
246
+ it "defaults to an empty collection" do
247
247
  empty.embedded_collection.should be_an_instance_of(Collection[Embedded])
248
248
  empty.embedded_collection.should be_empty
249
249
  end
250
250
 
251
- it "should include the embedded properties in the embedded documents list" do
251
+ it "includes the embedded properties in the embedded documents list" do
252
252
  subject.embedded_documents.should include(embedded1)
253
253
  end
254
254
 
255
- it "should include the elements in the collection in the embedded documents list" do
255
+ it "includes the elements in the collection in the embedded documents list" do
256
256
  subject.embedded_documents.should include(embedded2, embedded3)
257
257
  end
258
258
 
259
- it "should cast items to embedded document class when assigning array of hashes" do
259
+ it "casts items to embedded document class when assigning array of hashes" do
260
260
  subject.embedded_collection = [ { :number => 5 }, { :number => 99 } ]
261
261
  subject.embedded_collection.should == [ Embedded.new(:number => 5), Embedded.new(:number => 99) ]
262
262
  end
263
263
 
264
- it "should cast items to embedded document class when assigning collection hash" do
264
+ it "casts items to embedded document class when assigning collection hash" do
265
265
  subject.embedded_collection = { :_collection => true, :items => [ { :number => 49 }, { :number => 64 } ] }
266
266
  subject.embedded_collection.should == [ Embedded.new(:number => 49), Embedded.new(:number => 64) ]
267
267
  end
268
268
 
269
- it "should cast item to embedded document class when assigning attributes hash" do
269
+ it "casts item to embedded document class when assigning attributes hash" do
270
270
  subject.embedded_collection = { :number => 8 }
271
271
  subject.embedded_collection.should == [ Embedded.new(:number => 8) ]
272
272
  end