File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -147,12 +147,14 @@ For example:
147
147
``` ruby
148
148
require " rails_helper"
149
149
150
- RSpec .describe User , :type => :model do
151
- it " orders by last name" do
152
- lindeman = User .create!(first_name: " Andy" , last_name: " Lindeman" )
153
- chelimsky = User .create!(first_name: " David" , last_name: " Chelimsky" )
154
-
155
- expect(User .ordered_by_last_name).to eq([chelimsky, lindeman])
150
+ RSpec .describe Post , :type => :model do
151
+ context " with 2 or more comments" do
152
+ it " orders them in reverse chronologically" do
153
+ post = Post .create!
154
+ comment1 = post.comments.create!(:body => " first comment" )
155
+ comment2 = post.comments.create!(:body => " second comment" )
156
+ expect(post.reload.comments).to eq([comment2, comment1])
157
+ end
156
158
end
157
159
end
158
160
```
You can’t perform that action at this time.
0 commit comments