Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Add -n short option for --next-failure #2434

Merged
merged 1 commit into from
Jun 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/rspec/core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def deprecation_stream=(value)

# @macro define_reader
# The file path to use for persisting example statuses. Necessary for the
# `--only-failures` and `--next-failures` CLI options.
# `--only-failures` and `--next-failure` CLI options.
#
# @overload example_status_persistence_file_path
# @return [String] the file path
Expand All @@ -170,7 +170,7 @@ def deprecation_stream=(value)
define_reader :example_status_persistence_file_path

# Sets the file path to use for persisting example statuses. Necessary for the
# `--only-failures` and `--next-failures` CLI options.
# `--only-failures` and `--next-failure` CLI options.
def example_status_persistence_file_path=(value)
@example_status_persistence_file_path = value
clear_values_derived_from_example_status_persistence_file_path
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/core/option_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def parser(options)
configure_only_failures(options)
end

parser.on("--next-failure", "Apply `--only-failures` and abort after one failure.",
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)
set_fail_fast(options, 1)
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/core/configuration_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
end
end

%w[ --only-failures --next-failure ].each do |option|
%w[ --only-failures --next-failure -n].each do |option|
describe option do
it "changes `config.only_failures?` to true" do
opts = config_options_object(option)
Expand Down
28 changes: 15 additions & 13 deletions spec/rspec/core/option_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,22 +185,24 @@ module RSpec::Core
end
end

describe "--next-failure" do
it 'is equivalent to `--tag last_run_status:failed --fail-fast --order defined`' do
long_form = Parser.parse(%w[ --tag last_run_status:failed --fail-fast --order defined ])
next_failure = Parser.parse(%w[ --next-failure ])
%w[--next-failure -n].each do |option|
describe option do
it 'is equivalent to `--tag last_run_status:failed --fail-fast --order defined`' do
long_form = Parser.parse(%w[ --tag last_run_status:failed --fail-fast --order defined ])
next_failure = Parser.parse([option])

expect(next_failure).to include(long_form)
end
expect(next_failure).to include(long_form)
end

it 'does not force `--order defined` over a specified `--seed 1234` option that comes before it' do
options = Parser.parse(%w[ --seed 1234 --next-failure ])
expect(options).to include(:order => "rand:1234")
end
it 'does not force `--order defined` over a specified `--seed 1234` option that comes before it' do
options = Parser.parse(['--seed', '1234', option])
expect(options).to include(:order => "rand:1234")
end

it 'does not force `--order defined` over a specified `--seed 1234` option that comes after it' do
options = Parser.parse(%w[ --next-failure --seed 1234 ])
expect(options).to include(:order => "rand:1234")
it 'does not force `--order defined` over a specified `--seed 1234` option that comes after it' do
options = Parser.parse([option, '--seed', '1234'])
expect(options).to include(:order => "rand:1234")
end
end
end

Expand Down