Extract Capybara setup to a helper file
Any Capybara-related test setup has been moved to `capybara_helper.rb`. Now we just must require this file in order to run tests with Capybara. I also moved the `#console_log` helper to this file to showcase how other global helper methods could be defined in this file.
This commit is contained in:
committed by
benjamin wil
parent
ce85301e70
commit
d66a46f044
@@ -1,9 +1,4 @@
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helper'))
|
||||
require 'selenium-webdriver'
|
||||
require 'capybara/dsl'
|
||||
|
||||
Capybara.default_driver = ::CAPYBARA_DRIVER
|
||||
Capybara.server = :webrick
|
||||
require_relative '../capybara_helper'
|
||||
|
||||
def console_log(page, level = :severe)
|
||||
page.driver.browser.logs.get(:browser).select{|log| log.level == level.to_s.upcase }
|
||||
@@ -21,7 +16,7 @@ end
|
||||
|
||||
context 'Frontend with mathjax' do
|
||||
include Capybara::DSL
|
||||
|
||||
|
||||
setup do
|
||||
@path = cloned_testpath("examples/lotr.git")
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
@@ -29,21 +24,21 @@ context 'Frontend with mathjax' do
|
||||
Precious::App.set(:wiki_options, {mathjax: true})
|
||||
Capybara.app = Precious::App
|
||||
end
|
||||
|
||||
|
||||
test 'no unexpected errors on /' do
|
||||
visit '/'
|
||||
log = console_log(page)
|
||||
assert_only_expected_errors(log)
|
||||
end
|
||||
|
||||
|
||||
test 'no unexpected errors on /create/' do
|
||||
visit '/create/Foobar'
|
||||
log = console_log(page)
|
||||
assert_only_expected_errors(log)
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
Capybara.reset_sessions!
|
||||
Capybara.use_default_driver
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user