File tree Expand file tree Collapse file tree 1 file changed +29
-2
lines changed Expand file tree Collapse file tree 1 file changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -165,13 +165,40 @@ class << self; attr_accessor :name; end
165
165
166
166
describe "#attributes" do
167
167
168
- let ( :person ) do
169
- Person . new ( title : "Sir" )
168
+ let! ( :person ) do
169
+ Person . create! ( title : "Sir" )
170
170
end
171
171
172
172
it "returns the attributes with indifferent access" do
173
173
expect ( person [ :title ] ) . to eq ( "Sir" )
174
174
end
175
+
176
+ context "when instantiating a new document" do
177
+ it "returns a Hash" do
178
+ expect ( person . attributes . class ) . to eq ( Hash )
179
+ end
180
+ end
181
+
182
+ context "when retrieving a document from the database" do
183
+
184
+ let ( :from_db ) { Person . first }
185
+
186
+ context "when legacy_attributes is false" do
187
+ config_override :legacy_attributes , false
188
+
189
+ it "returns a Hash" do
190
+ expect ( from_db . attributes . class ) . to eq ( Hash )
191
+ end
192
+ end
193
+
194
+ context "when legacy_attributes is true" do
195
+ config_override :legacy_attributes , true
196
+
197
+ it "returns a BSON::Document" do
198
+ expect ( from_db . attributes . class ) . to eq ( BSON ::Document )
199
+ end
200
+ end
201
+ end
175
202
end
176
203
177
204
describe "#identity" do
You can’t perform that action at this time.
0 commit comments