Created
June 4, 2013 12:14
-
-
Save skamithi/5705473 to your computer and use it in GitHub Desktop.
Capybara 2.0 / Rspec. Ability to launch browser when testing view specs. Not integration test..just regular view specs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#spec/support/capybara.rb | |
require 'capybara/rspec' | |
# Using chrome as browser to test in capybara. | |
Capybara.register_driver :selenium do |app| | |
Capybara::Selenium::Driver.new(app, :browser => :chrome) | |
end | |
# Works with Capybara 2.0 | |
def show_page(str) | |
path ||= "capybara-#{Time.new.strftime("%Y%m%d%H%M%S")}#{rand(10**10)}.html" | |
path = File.expand_path(path, Capybara.save_and_open_page_path) if Capybara.save_and_open_page_path | |
FileUtils.mkdir_p(File.dirname(path)) | |
File.open(path,'w') { |f| f.write(str) } | |
Launchy.open(path) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment