-
-
Save Telmo/2384588 to your computer and use it in GitHub Desktop.
let vs def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "A user's comment" do | |
let(:user) { User.create! name: "John" } | |
let(:comment) { user.comments.create! } | |
it "delegates to user's name" do | |
comment.name.should eq(user.name) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "A user's comment" do | |
def user | |
@user ||= User.create! name: "John" | |
end | |
def comment | |
@comment ||= user.comments.create! | |
end | |
it "delegates to user's name" do | |
comment.name.should eq(user.name) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "A user's comment" do | |
def user; @user ||= User.create! name: "John"; end | |
def comment; @comment ||= user.comments.create!; end | |
it "delegates to user's name" do | |
comment.name.should eq(user.name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment