Skip to content

Commit f46430b

Browse files
committed
Improve rescript tests
In this commit, a deply is put between UI interaction and database check. This, fixed false positive test pass for not updating database on empty form submission.
1 parent 64f16a1 commit f46430b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

spec/rescript/rescript_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,35 @@
5050
fill_in author_field, with: comment.author
5151
fill_in text_field, with: comment.text
5252
click_button("Post")
53+
54+
page.driver.browser.manage.timeouts.implicit_wait = 1
55+
5356
expect(Comment.all.count).to equal(new_comment_count)
5457
end
5558

5659
it "comment count remains the same when author field is empty" do
5760
initial_comment_count = Comment.all.count
5861
fill_in text_field, with: comment.text
5962
click_button("Post")
63+
64+
expect(page).to have_text(/Can't save the comment!/)
6065
expect(Comment.all.count).to equal(initial_comment_count)
6166
end
6267

6368
it "comment count remains the same when text field is empty" do
6469
initial_comment_count = Comment.all.count
6570
fill_in author_field, with: comment.author
6671
click_button("Post")
72+
73+
expect(page).to have_text(/Can't save the comment!/)
6774
expect(Comment.all.count).to equal(initial_comment_count)
6875
end
6976

7077
it "comment count remains the same when both form fields are empty" do
7178
initial_comment_count = Comment.all.count
7279
click_button("Post")
80+
81+
expect(page).to have_text(/Can't save the comment!/)
7382
expect(Comment.all.count).to equal(initial_comment_count)
7483
end
7584
end

0 commit comments

Comments
 (0)