/usr/lib/ruby/vendor_ruby/capybara/spec/spec_helper.rb is in ruby-capybara 2.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | require "rspec"
require "capybara"
require "capybara/rspec" # Required here instead of in rspec_spec to avoid RSpec deprecation warning
require "capybara/spec/test_app"
require "nokogiri"
# Alias be_truthy/be_falsey if not already defined to be able to use in RSpec 2 and 3
unless RSpec::Matchers.method_defined?(:be_truthy)
RSpec::Matchers.module_eval do
alias be_truthy be_true
alias be_falsey be_false
alias be_falsy be_false
end
end
module Capybara
module SpecHelper
class << self
def configure(config)
config.filter_run_excluding :requires => method(:filter).to_proc
config.before { Capybara::SpecHelper.reset! }
config.after { Capybara::SpecHelper.reset! }
end
def reset!
Capybara.app = TestApp
Capybara.app_host = nil
Capybara.default_selector = :xpath
Capybara.default_max_wait_time = 1
Capybara.ignore_hidden_elements = true
Capybara.exact = false
Capybara.exact_options = false
Capybara.raise_server_errors = true
Capybara.visible_text_only = false
Capybara.match = :smart
Capybara.wait_on_first_by_default = false
end
def filter(requires, metadata)
if requires and metadata[:capybara_skip]
requires.any? do |require|
metadata[:capybara_skip].include?(require)
end
else
false
end
end
def spec(name, options={}, &block)
@specs ||= []
@specs << [name, options, block]
end
def run_specs(session, name, options={})
specs = @specs
RSpec.describe Capybara::Session, name, options do
include Capybara::SpecHelper
include Capybara::RSpecMatchers
before do
@session = session
end
after do
@session.reset_session!
end
specs.each do |spec_name, spec_options, block|
describe spec_name, spec_options do
class_eval(&block)
end
end
end
end
end # class << self
def silence_stream(stream)
old_stream = stream.dup
stream.reopen(RbConfig::CONFIG['host_os'] =~ /rmswin|mingw/ ? 'NUL:' : '/dev/null')
stream.sync = true
yield
ensure
stream.reopen(old_stream)
end
def quietly
silence_stream(STDOUT) do
silence_stream(STDERR) do
yield
end
end
end
def extract_results(session)
expect(session).to have_xpath("//pre[@id='results']")
YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.inner_html.lstrip
end
end
end
Dir[File.dirname(__FILE__) + "/session/**/*.rb"].each { |file| require_relative file }
|