/
env.rb
64 lines (53 loc) · 1.84 KB
/
env.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# frozen_string_literal: true
# While you're here, handy tip for debugging: try to attach @announce-output
# @announce-command to the scenarios/features to see what's going on
require "bundler"
Bundler.setup
require "aruba/cucumber"
require "aruba/config/jruby" if RUBY_ENGINE == "jruby"
require "capybara/cucumber"
require "capybara/apparition"
require "simplecov"
# Fake rack app for capybara that just returns the latest coverage report from aruba temp project dir
Capybara.app = lambda { |env|
request_path = env["REQUEST_PATH"] || "/"
request_path = "/index.html" if request_path == "/"
corresponding_file_path =
File.join(File.dirname(__FILE__), "../../tmp/aruba/project/coverage", request_path)
content =
if File.exist?(corresponding_file_path)
File.read(corresponding_file_path)
else
# See #776 for whatever reason sometimes JRuby in one feature couldn't
# find the loading.gif - which isn't essential so answering empty string
# should be good enough
warn "Couldn't find #{corresponding_file_path} generating empty response"
""
end
[
200,
{"Content-Type" => "text/html"},
[content]
]
}
Capybara.configure do |config|
config.ignore_hidden_elements = false
config.server = :webrick
config.default_driver = :apparition
end
Before("@branch_coverage") do
skip_this_scenario unless SimpleCov.branch_coverage_supported?
end
Before("@rails6") do
# Rails 6 only supports Ruby 2.5+
skip_this_scenario if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5")
end
Before("@process_fork") do
# Process.fork is NotImplementedError in jruby
skip_this_scenario if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
end
Aruba.configure do |config|
config.allow_absolute_paths = true
# JRuby needs a bit longer to get going
config.exit_timeout = RUBY_ENGINE == "jruby" ? 60 : 20
end