Created
February 10, 2016 20:11
-
-
Save egardner/967b33e2893b6f550b7a to your computer and use it in GitHub Desktop.
Middleman v4 Testing Setup
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
require "middleman" | |
require "middleman/rack" | |
require "middleman-core/rack" | |
require "rspec" | |
require "capybara/rspec" | |
require "capybara/webkit" | |
module MiddlemanApplication | |
extend RSpec::SharedContext | |
main_app = ::Middleman::Application.new do || | |
config[:watcher_disable] = true | |
end | |
let(:app) do | |
main_app | |
end | |
Capybara.javascript_driver = :webkit | |
Capybara.default_max_wait_time = 5 | |
Capybara::Webkit.configure do |config| | |
config.allow_url("www.getty.edu") | |
config.allow_url("cdn.rawgit.com") | |
config.allow_url("api.mapbox.com") | |
config.allow_url("gettypubs.github.io") | |
config.block_unknown_urls | |
end | |
Capybara.app = ::Middleman::Rack.new(main_app).to_app do | |
set :root, File.expand_path(File.join(File.dirname(__FILE__), "..")) | |
set :environment, :development | |
set :show_exceptions, false | |
end | |
end | |
RSpec.configure do |config| | |
config.color = true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A basic
spec_helper
file for using RSpec, Capybara, and Capybara Webkit in Middleman v4.Got this working thanks to this example