Showing posts with label Cucumber. Show all posts
Showing posts with label Cucumber. Show all posts

Thursday, March 26, 2015

Using local assets with save_and_open_page

Previously I talked about how to use save_and_open_page with Cucumber. Unfortunately, when you do this it renders an unstyled page. If you add

Capybara.asset_host = 'http://localhost:3000'

to your spec_helper.rb or Capybara config file, save_and_open_page will use your local server's assets - making it much easier to diagnose issues.

Thursday, March 19, 2015

Using save_and_open_page with Cucumber

Capybara has a nice utility method called save_and_open_page that will save the current page's HTML as a temp file and open it in your browser. This method is available by default in Ruby code (for example in an RSpec feature spec). As Cucumber is not direct Ruby, you can't directly say that. Fortunately, you can say

 Then show me the page  

and you'll get the same effect.