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

有帮助吗?

解决方案 2

Looking back at my question after coding rails for a year+, I now think that it should not be necessary to reference asset_url and not even asset_path from a capybara spec. It's like I was trying to test configuration. (oh young and naive me)

Assets on the page can be tested with should have_selector("[src$='my_image.png']"). Also, unless it's file upload, such tests are better left as view specs.

Cheers!

P.S. Thanks for the answer @tanzeeb-khalili. I believe we met in CampJS a few months back in Gold Coast. Small world! =)

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top