Let's say I'm working on a comments functionality that I want to add to the application I'm developing.
I can test it like so with a feature test:
scenario "they can comment on a book" do
visit book_url(book)
fill_in "Name", with: "John"
fill_in "Comment", with: "This is a comment."
click_button "Add Comment"
expect(current_path).to eq(book_path(book))
expect(page).to have_text("Your comment is successfully added")
expect(page).to have_text(Comment.last.content)
end
But what if I also add a functionality, wherein the user can decide whether or not a comment needs an approval. If it doesn't need an approval, then the above test would work. But if the user changes the settings and decides that a comment needs an approval before being published, this test wouldn't work.
What would be a good way to write a test covering all these scenarios?
Aucun commentaire:
Enregistrer un commentaire