Skip to content

Commit

Permalink
collapse configure_only methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse vonBergen committed Jan 31, 2024
1 parent f7a8d80 commit c9dfdd4
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions lib/rspec/core/option_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,18 @@ def parser(options)
FILTERING

parser.on('--only-failures', "Filter to just the examples that failed the last time they ran.") do
configure_only_failures(options)
configure_only(options, :only_failures, 'failed')
end

parser.on("-n", "--next-failure", "Apply `--only-failures` and abort after one failure.",
" (Equivalent to `--only-failures --fail-fast --order defined`)") do
configure_only_failures(options)
configure_only(options, :only_failures, 'failed')
set_fail_fast(options, 1)
options[:order] ||= 'defined'
end

parser.on('--only-pending', "Filter to just the examples that were pending the last time they ran.") do
configure_only_pending(options)
configure_only(options, :only_pending, 'pending')
end

parser.on('-P', '--pattern PATTERN', 'Load files matching pattern (default: "spec/**/*_spec.rb").') do |o|
Expand Down Expand Up @@ -319,14 +319,9 @@ def set_fail_fast(options, value)
options[:fail_fast] = value
end

def configure_only_failures(options)
options[:only_failures] = true
add_tag_filter(options, :inclusion_filter, :last_run_status, 'failed')
end

def configure_only_pending(options)
options[:only_pending] = true
add_tag_filter(options, :inclusion_filter, :last_run_status, 'pending')
def configure_only(options, type, value)
options[type] = true
add_tag_filter(options, :inclusion_filter, :last_run_status, value)
end
end
end

0 comments on commit c9dfdd4

Please sign in to comment.