class KnapsackPro::Pure::Queue::RSpecPure
Constants
- FAILURE_EXIT_CODE
- FORMATTERS
Public Instance Methods
add_knapsack_pro_formatters_to(spec_opts)
click to toggle source
# File lib/knapsack_pro/pure/queue/rspec_pure.rb, line 12 def add_knapsack_pro_formatters_to(spec_opts) return spec_opts unless spec_opts return spec_opts if FORMATTERS.all? { |formatter| spec_opts.include?(formatter) } FORMATTERS.each do |formatter| next if spec_opts.include?(formatter) spec_opts += " --format #{formatter}" end spec_opts end
args_with_seed_option_added_when_viable(order_option, seed, args)
click to toggle source
# File lib/knapsack_pro/pure/queue/rspec_pure.rb, line 28 def args_with_seed_option_added_when_viable(order_option, seed, args) return args if order_option && !order_option.include?('rand') return args if order_option && order_option.to_s.split(':')[1] return args unless seed.used? args + ['--seed', seed.value] end
error_exit_code(rspec_error_exit_code)
click to toggle source
# File lib/knapsack_pro/pure/queue/rspec_pure.rb, line 24 def error_exit_code(rspec_error_exit_code) rspec_error_exit_code || FAILURE_EXIT_CODE end
exit_summary(unexecuted_test_files)
click to toggle source
# File lib/knapsack_pro/pure/queue/rspec_pure.rb, line 65 def exit_summary(unexecuted_test_files) return if unexecuted_test_files.empty? "Unexecuted tests on this CI node (including pending tests): #{unexecuted_test_files.join(' ')}" end
prepare_cli_args(args, has_format_option, has_require_rails_helper_option, rails_helper_exists, test_dir)
click to toggle source
# File lib/knapsack_pro/pure/queue/rspec_pure.rb, line 37 def prepare_cli_args(args, has_format_option, has_require_rails_helper_option, rails_helper_exists, test_dir) (args || '').split .yield_self { args_with_at_least_one_formatter(_1, has_format_option) } .yield_self { args_with_require_rails_helper_if_needed(_1, has_require_rails_helper_option, rails_helper_exists) } .yield_self { args_with_default_options(_1, test_dir) } end
rspec_command(args, test_file_paths, scope)
click to toggle source
# File lib/knapsack_pro/pure/queue/rspec_pure.rb, line 44 def rspec_command(args, test_file_paths, scope) messages = [] return messages if test_file_paths.empty? case scope when :batch_finished messages << 'To retry the last batch of tests fetched from the Queue API, please run the following command on your machine:' when :queue_finished messages << 'To retry all the tests assigned to this CI node, please run the following command on your machine:' end stringified_cli_args = args.join(' ') FORMATTERS.each do |formatter| stringified_cli_args.sub!(" --format #{formatter}", '') end messages << "bundle exec rspec #{stringified_cli_args} " + KnapsackPro::TestFilePresenter.stringify_paths(test_file_paths) messages end
Private Instance Methods
args_with_at_least_one_formatter(cli_args, has_format_option)
click to toggle source
# File lib/knapsack_pro/pure/queue/rspec_pure.rb, line 73 def args_with_at_least_one_formatter(cli_args, has_format_option) return cli_args if has_format_option cli_args + ['--format', 'progress'] end
args_with_default_options(cli_args, test_dir)
click to toggle source
# File lib/knapsack_pro/pure/queue/rspec_pure.rb, line 86 def args_with_default_options(cli_args, test_dir) new_cli_args = cli_args + [ '--default-path', test_dir, ] FORMATTERS.each do |formatter| new_cli_args += ['--format', formatter] end new_cli_args end
args_with_require_rails_helper_if_needed(cli_args, has_require_rails_helper_option, rails_helper_exists)
click to toggle source
# File lib/knapsack_pro/pure/queue/rspec_pure.rb, line 79 def args_with_require_rails_helper_if_needed(cli_args, has_require_rails_helper_option, rails_helper_exists) return cli_args if has_require_rails_helper_option return cli_args unless rails_helper_exists cli_args + ['--require', 'rails_helper'] end