From f3007a5fc27a93c847d2810a1e97f6e1d5102fa7 Mon Sep 17 00:00:00 2001 From: Jeremy Woertink Date: Sun, 21 Jul 2024 15:07:45 -0700 Subject: [PATCH] Remove mention of be_on_page since that method no longer exists. Fixes #1286 --- .../guides/testing/html_and_interactivity.cr | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/actions/guides/testing/html_and_interactivity.cr b/src/actions/guides/testing/html_and_interactivity.cr index 14b82f69..5175c13e 100644 --- a/src/actions/guides/testing/html_and_interactivity.cr +++ b/src/actions/guides/testing/html_and_interactivity.cr @@ -57,6 +57,10 @@ class Guides::Testing::HtmlAndInteractivity < GuideAction When writing flow specs, it’s best to *write the spec as a full flow that a user might take*. For example, here is a flow for publishing an article: + When writing flow specs, your flow object will handle all of the interactions, + and should read as a step-by-step guide that a user will take flowing from point A to B. + Each of your spec assertions can remain in the spec for transparency. + ```crystal # spec/flows/publish_post_spec.cr describe "Publish post flow" do @@ -65,10 +69,12 @@ class Guides::Testing::HtmlAndInteractivity < GuideAction flow.start_draft flow.create_draft - flow.draft_should_be_saved + flow.should have_element("@draft-title") flow.open_draft flow.publish_post - flow.post_should_be_published + + flow.should have_element("@post-title") + flow.should have_text("Published Post") end end ``` @@ -92,10 +98,6 @@ class Guides::Testing::HtmlAndInteractivity < GuideAction click "@save-draft" end - def draft_should_be_created - draft_title.should be_on_page - end - def open_draft draft_title.click end @@ -109,10 +111,6 @@ class Guides::Testing::HtmlAndInteractivity < GuideAction title: "Published Post" click "@publish-post" end - - def post_should_be_published - el("@post-title", text: "Published Post").should be_on_page - end end ``` @@ -320,11 +318,12 @@ class Guides::Testing::HtmlAndInteractivity < GuideAction ### Asserting elements are on the page - You can use `el` combined with the `be_on_page` matcher to assert that an - element is on the page: + You can use the `have_element` and `have_text` expectations to check for specific elements using CSS + selectors, or elements containing specific text. ```crystal - el("@post-title", text: "My post").should be_on_page + flow.should have_element(%(span[data-arg="4"])) + flow.should have_text("Welcome") ``` ### Asserting the current URL path