chriskottom / minitest_cookbook_source

Source code examples and sample projects for The Minitest Cookbook
54 stars 20 forks source link

Use instance variables instead of local variables in CommentsHelper test #4

Closed JunichiIto closed 8 years ago

JunichiIto commented 9 years ago

I wonder if the following code in Testing Helpers section works. I think commnet1-3 should be @comment1-3.

describe CommentsHelper do
  let(:post)  { posts(:with_comments) }

  before do
    comment1 = post.comments.build(text: "Comment 1",
                                   user: "a@example.com")
    comment2 = post.comments.build(text: "Comment 2",
                                   user: "b@example.com")
    comment3 = post.comments.build(text: "Comment 3",
                                   user: "c@example.com")
  end

  describe "#comments_for" do
    it "renders each top-level comment" do
      render_comments_for(post)
      [comment1, comment2, comment3].each do |comment|
        assert_template partial: "_comment", locals: { comment: comment }
      end
    end
  end
end
chriskottom commented 9 years ago

You're correct, this doesn't work as written. I'll be putting out a big update in a few weeks, and I'll make sure to fix this. Nice catch!

JunichiIto commented 9 years ago

Okay, I am looking forward to the big update.

chriskottom commented 9 years ago

I'm hoping to get a big revision out in August, but I might try to fix some of these small issues before that in a small patch version.