-
Notifications
You must be signed in to change notification settings - Fork 384
Improve tests result consistency #581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
d67b86d
c9d22e3
3455e55
71a779d
79ed86d
fc3f6b8
a5ddd57
599b2bc
a6190eb
244a390
9314c70
a56a164
b0eaa5f
facb4b0
9b12367
338f9f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,27 +52,36 @@ | |
fill_in author_field, with: comment.author | ||
fill_in text_field, with: comment.text | ||
click_button("Post") | ||
sleep(1) | ||
|
||
# This will ensure we wait enough for the changes to be applied | ||
expect(page).to have_text("") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ahangarha, this is a very strange assertion! Please add self-review comments for WTF's like this! CC: @Judahmeek There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I mentioned in the comment above that line, we need to put some delay before getting assertion for comment count change. Before I fixed it with sleep but that is not efficient. This assertion makes it more efficient. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. expect page to display the new comment in the right format block (not in the input field). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already had a test to ensure the new comment is displayed on the page. This test was to ensure the comment was added to the database. Now, we combine them into one test with multiple assertions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
expect(Comment.all.count).to equal(new_comment_count) | ||
end | ||
|
||
it "comment count remains the same when author field is empty" do | ||
initial_comment_count = Comment.all.count | ||
fill_in text_field, with: comment.text | ||
click_button("Post") | ||
|
||
expect(page).to have_text("Author: can't be blank") | ||
expect(Comment.all.count).to equal(initial_comment_count) | ||
end | ||
|
||
it "comment count remains the same when text field is empty" do | ||
initial_comment_count = Comment.all.count | ||
fill_in author_field, with: comment.author | ||
click_button("Post") | ||
|
||
expect(page).to have_text("Text: can't be blank") | ||
expect(Comment.all.count).to equal(initial_comment_count) | ||
end | ||
|
||
it "comment count remains the same when both form fields are empty" do | ||
initial_comment_count = Comment.all.count | ||
click_button("Post") | ||
|
||
expect(page).to have_text("Author: can't be blank") | ||
expect(Comment.all.count).to equal(initial_comment_count) | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure the text is some unique value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When this test runs, we have a fresh database.