Jevan Wu
Jevan Wu

Reputation: 51

Minitest: Capybara error when calling #assert_current_path?

I want to compare the expected path and current path to justify whether the test is passed within Minitest.

I found the method Capybara::SessionMatchers#assert_current_path. I guess this method can fulfill my requirement.

But when I wrote:

page.assert_current_path()

In my test, the error showed: no #assert_current_path method

I've seen the Capybara::Session has included the Capybara::SessionMatchers. I'm confused of why I cannot call the #assert_current_path method. Does Capybara have the functionality to compare current path and expected path? coz use page content to justify the result is not stable for me.

Upvotes: 3

Views: 673

Answers (2)

Thomas Walpole
Thomas Walpole

Reputation: 49870

Make sure you're running Capybara 2.5+ - the assert_current_path matcher wasn't added until 2.5.0

page.assert_current_path('/expected/path')

Upvotes: 3

user2322409
user2322409

Reputation: 824

Try this

uri = URI.parse(current_url)

if you need check additional params

"#{uri.path}?#{uri.query}".should == your_path(:your_params => 'your_value')

Upvotes: -1

Related Questions