gitlab-org--gitlab-foss/features/support/env.rb

55 lines
1.6 KiB
Ruby
Raw Normal View History

require './spec/simplecov_env'
SimpleCovEnv.start!
2012-09-10 03:52:43 -04:00
ENV['RAILS_ENV'] = 'test'
require './config/environment'
require 'rspec/expectations'
2013-01-09 01:14:05 -05:00
2016-06-08 05:43:13 -04:00
if ENV['CI']
require 'knapsack'
Knapsack::Adapters::SpinachAdapter.bind
2016-06-08 05:43:13 -04:00
end
%w(select2_helper test_env repo_helpers wait_for_requests sidekiq).each do |f|
require Rails.root.join('spec', 'support', f)
end
Dir["#{Rails.root}/features/steps/shared/*.rb"].each { |file| require file }
2012-09-10 11:35:03 -04:00
WebMock.allow_net_connect!
Spinach.hooks.before_run do
include RSpec::Mocks::ExampleMethods
RSpec::Mocks.setup
2014-07-31 12:24:53 -04:00
TestEnv.init(mailer: false)
2015-08-14 09:08:31 -04:00
# skip pre-receive hook check so we can use
# web editor and merge
TestEnv.disable_pre_receive
include FactoryGirl::Syntax::Methods
end
Spinach.hooks.after_scenario do |scenario_data, step_definitions|
if scenario_data.tags.include?('javascript')
include WaitForRequests
block_and_wait_for_requests_complete
end
end
module StdoutReporterWithScenarioLocation
# Override the standard reporter to show filename and line number next to each
# scenario for easy, focused re-runs
def before_scenario_run(scenario, step_definitions = nil)
@max_step_name_length = scenario.steps.map(&:name).map(&:length).max if scenario.steps.any?
name = scenario.name
# This number has no significance, it's just to line things up
max_length = @max_step_name_length + 19
out.puts "\n #{'Scenario:'.green} #{name.light_green.ljust(max_length)}" \
" # #{scenario.feature.filename}:#{scenario.line}"
end
end
Spinach::Reporter::Stdout.prepend(StdoutReporterWithScenarioLocation)