Skip to content

Commit decc627

Browse files
joeltaylorJonRowe
authored andcommitted
Update model example to match Relish (#1919)
1 parent 0e63986 commit decc627

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,14 @@ For example:
147147
```ruby
148148
require "rails_helper"
149149

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
156158
end
157159
end
158160
```

0 commit comments

Comments
 (0)