2016-07-21 08:44:18 +00:00
|
|
|
require './spec/simplecov_env'
|
|
|
|
SimpleCovEnv.start!
|
2013-01-05 11:30:42 +00:00
|
|
|
|
2012-09-10 07:52:43 +00:00
|
|
|
ENV['RAILS_ENV'] = 'test'
|
|
|
|
require './config/environment'
|
2013-12-06 15:40:39 +00:00
|
|
|
require 'rspec/expectations'
|
2013-01-09 06:14:05 +00:00
|
|
|
|
2016-06-08 09:43:13 +00:00
|
|
|
if ENV['CI']
|
|
|
|
require 'knapsack'
|
2016-07-13 09:03:06 +00:00
|
|
|
Knapsack::Adapters::SpinachAdapter.bind
|
2016-06-08 09:43:13 +00:00
|
|
|
end
|
2016-05-23 01:34:36 +00:00
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
%w(select2_helper test_env repo_helpers wait_for_requests sidekiq).each do |f|
|
2012-09-10 08:51:02 +00:00
|
|
|
require Rails.root.join('spec', 'support', f)
|
|
|
|
end
|
|
|
|
|
2015-04-25 18:20:15 +00:00
|
|
|
Dir["#{Rails.root}/features/steps/shared/*.rb"].each { |file| require file }
|
2012-09-10 15:35:03 +00:00
|
|
|
|
2012-09-10 11:27:11 +00:00
|
|
|
WebMock.allow_net_connect!
|
|
|
|
|
|
|
|
Spinach.hooks.before_run do
|
2015-02-12 18:48:42 +00:00
|
|
|
include RSpec::Mocks::ExampleMethods
|
2015-02-13 16:48:31 +00:00
|
|
|
RSpec::Mocks.setup
|
2014-07-31 16:24:53 +00:00
|
|
|
TestEnv.init(mailer: false)
|
2012-09-10 11:27:11 +00:00
|
|
|
|
2015-08-14 13:08:31 +00:00
|
|
|
# skip pre-receive hook check so we can use
|
|
|
|
# web editor and merge
|
|
|
|
TestEnv.disable_pre_receive
|
|
|
|
|
2012-09-26 02:34:29 +00:00
|
|
|
include FactoryGirl::Syntax::Methods
|
2017-06-29 17:06:35 +00:00
|
|
|
include GitlabRoutingHelper
|
2012-09-10 11:27:11 +00:00
|
|
|
end
|
2017-03-29 21:07:51 +00:00
|
|
|
|
2017-05-12 22:10:12 +00:00
|
|
|
Spinach.hooks.after_scenario do |scenario_data, step_definitions|
|
|
|
|
if scenario_data.tags.include?('javascript')
|
2017-04-26 10:40:52 +00:00
|
|
|
include WaitForRequests
|
2017-05-17 18:25:13 +00:00
|
|
|
block_and_wait_for_requests_complete
|
2017-04-26 10:40:52 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-29 21:07:51 +00:00
|
|
|
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)
|