Class: KnapsackPro::Adapters::RSpecAdapter
Constant Summary
collapse
- TEST_DIR_PATTERN =
'spec/**{,/*/**}/*_spec.rb'
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseAdapter
adapter_bind_method_called_file, bind, #bind, #bind_queue_mode, slow_test_file?, verify_bind_method_called
Class Method Details
.ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!(cli_args) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/knapsack_pro/adapters/rspec_adapter.rb', line 6
def self.ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!(cli_args)
if KnapsackPro::Config::Env.rspec_split_by_test_examples? && has_tag_option?(cli_args)
error_message = 'It is not allowed to use the RSpec tag option together with the RSpec split by test examples feature. Please see: https://knapsackpro.com/faq/question/how-to-split-slow-rspec-test-files-by-test-examples-by-individual-it#warning-dont-use-rspec-tag-option'
KnapsackPro.logger.error(error_message)
raise error_message
end
end
|
23
24
25
|
# File 'lib/knapsack_pro/adapters/rspec_adapter.rb', line 23
def self.has_format_option?(cli_args)
cli_args.any? { |arg| arg.start_with?('-f') || arg.start_with?('--format') }
end
|
.has_tag_option?(cli_args) ⇒ Boolean
14
15
16
17
18
19
20
21
|
# File 'lib/knapsack_pro/adapters/rspec_adapter.rb', line 14
def self.has_tag_option?(cli_args)
cli_args.any? { |arg| arg.start_with?('-t') || arg.start_with?('--tag') }
end
|
.test_path(example) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/knapsack_pro/adapters/rspec_adapter.rb', line 27
def self.test_path(example)
example_group = example.metadata[:example_group]
if defined?(::Turnip) && Gem::Version.new(::Turnip::VERSION) < Gem::Version.new('2.0.0')
unless example_group[:turnip]
until example_group[:parent_example_group].nil?
example_group = example_group[:parent_example_group]
end
end
else
until example_group[:parent_example_group].nil?
example_group = example_group[:parent_example_group]
end
end
example_group[:file_path]
end
|
Instance Method Details
#bind_before_queue_hook ⇒ Object
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/knapsack_pro/adapters/rspec_adapter.rb', line 88
def bind_before_queue_hook
::RSpec.configure do |config|
config.before(:suite) do
unless ENV['KNAPSACK_PRO_BEFORE_QUEUE_HOOK_CALLED']
ENV['KNAPSACK_PRO_BEFORE_QUEUE_HOOK_CALLED'] = 'true'
KnapsackPro::Hooks::Queue.call_before_queue
end
end
end
end
|
#bind_save_report ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/knapsack_pro/adapters/rspec_adapter.rb', line 80
def bind_save_report
::RSpec.configure do |config|
config.after(:suite) do
KnapsackPro::Report.save
end
end
end
|
#bind_time_tracker ⇒ Object