|
41 | 41 | end
|
42 | 42 |
|
43 | 43 | it "adds a new comment to the page and database" do
|
44 |
| - initital_comment_count = Comment.all.count |
| 44 | + initital_comment_count = Comment.count |
45 | 45 | new_comment_count = initital_comment_count + 1
|
46 | 46 | fill_in author_field, with: comment.author
|
47 | 47 | fill_in text_field, with: comment.text
|
48 | 48 | click_button("Post")
|
49 | 49 |
|
50 | 50 | expect(page).to have_css("h2", text: comment.author)
|
51 | 51 | expect(page).to have_css("p", text: comment.text)
|
52 |
| - expect(Comment.all.count).to equal(new_comment_count) |
| 52 | + expect(Comment.count).to equal(new_comment_count) |
53 | 53 | end
|
54 | 54 |
|
55 | 55 | it "comment count remains the same when author field is empty" do
|
56 |
| - initial_comment_count = Comment.all.count |
| 56 | + initial_comment_count = Comment.count |
57 | 57 | fill_in text_field, with: comment.text
|
58 | 58 | click_button("Post")
|
59 | 59 |
|
60 | 60 | expect(page).to have_text("Author: can't be blank")
|
61 |
| - expect(Comment.all.count).to equal(initial_comment_count) |
| 61 | + expect(Comment.count).to equal(initial_comment_count) |
62 | 62 | end
|
63 | 63 |
|
64 | 64 | it "comment count remains the same when text field is empty" do
|
65 |
| - initial_comment_count = Comment.all.count |
| 65 | + initial_comment_count = Comment.count |
66 | 66 | fill_in author_field, with: comment.author
|
67 | 67 | click_button("Post")
|
68 | 68 |
|
69 | 69 | expect(page).to have_text("Text: can't be blank")
|
70 |
| - expect(Comment.all.count).to equal(initial_comment_count) |
| 70 | + expect(Comment.count).to equal(initial_comment_count) |
71 | 71 | end
|
72 | 72 |
|
73 | 73 | it "comment count remains the same when both form fields are empty" do
|
74 |
| - initial_comment_count = Comment.all.count |
| 74 | + initial_comment_count = Comment.count |
75 | 75 | click_button("Post")
|
76 | 76 |
|
77 | 77 | expect(page).to have_text("Author: can't be blank")
|
78 |
| - expect(Comment.all.count).to equal(initial_comment_count) |
| 78 | + expect(Comment.count).to equal(initial_comment_count) |
79 | 79 | end
|
80 | 80 | end
|
81 | 81 | end
|
0 commit comments