Skip to content

Support Regex in assert_path/2 #233

Description

@vasspilka

Hey, so in some cases we might redirect but not know the exact path upfront, for example let's say that we create a new post and than we expect to get redirected to that post. That might look something like:

      conn
      |> login_user(user)
      |> visit("/app/posts/new")
      |> fill_in("Title", with: "Some")
      |> fill_in("Content", with: "Post")
      |> click_button("Create")
      |> assert_path(~r"/app/posts/.+/show")

Right now this will fail as Regex is not supported. A workaround currently is to use then

      ...
      |> click_button("Create ")
      |> then(fn conn ->
        current_path = PhoenixTest.Driver.current_path(conn)
        assert current_path =~ ~r"/app/posts/.+/show"

        conn
      end)

But the former makes for cleaner code.

Would we want to support this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    let's get a PR goingThe idea seems good. Happy to review a PR

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions