Module: ActionDispatch::TestHelpers::PageDumpHelper
| Relationships & Source Files | |
| Namespace Children | |
| 
       Exceptions: 
      
     | |
| Extension / Inclusion / Inheritance Descendants | |
| 
       Included In: 
      
     | |
| Defined in: | actionpack/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb | 
Instance Method Summary
- 
    
      #save_and_open_page(path = html_dump_default_path)  
    
    
Saves the content of response body to a file and tries to open it in your browser.
 - #html_dump_default_path private
 - #open_file(path) private
 - #save_page(path = html_dump_default_path) private
 
Instance Method Details
#html_dump_default_path (private)
[ GitHub ]#open_file(path) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb', line 23
def open_file(path) require "launchy" Launchy.open(path) rescue LoadError warn "File saved to #{path}.\nPlease install the launchy gem to open the file automatically." end
#save_and_open_page(path = html_dump_default_path)
Saves the content of response body to a file and tries to open it in your browser. Launchy must be present in your Gemfile for the page to open automatically.
# File 'actionpack/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb', line 10
def save_and_open_page(path = html_dump_default_path) save_page(path).tap { |s_path| open_file(s_path) } end
#save_page(path = html_dump_default_path) (private)
# File 'actionpack/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb', line 15
def save_page(path = html_dump_default_path) raise InvalidResponse.new("Response is a redirection!") if response.redirection? path = Pathname.new(path) path.dirname.mkpath File.write(path, response.body) path end