How to reference asset_url from capybara specs

Is there an easy way to reference asset_url from the capybara spec? Not only asset_path, but also the full URL, including port and host.

+4
source share
2 answers

Looking back at my question after coding rails for a year +, I now think that it is not necessary to refer to asset_url and even path_path from the capybara specification. As if I was trying to check the configuration. (oh young and naive)

Assets on the page can be checked with should have_selector("[src$='my_image.png']") . In addition, if it does not download files, it is better to leave such tests as representations.

Hooray!

PS Thanks for the answer @ tanzeeb-khalili. I think we met at CampJS a few months ago at the Gold Coast. Small world! =)

0
source

Not sure if there is a method that will give you the url, but you can get the host and path from Capybara.default_host and Capybara.default_port .

0
source

Source: https://habr.com/ru/post/1390405/


All Articles