debian-mirror-gitlab/features/support/env.rb

56 lines
1.6 KiB
Ruby
Raw Normal View History

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