Skip to content

Commit

Permalink
remove deprecated cli option
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Mar 21, 2014
1 parent 3df9383 commit d7161b7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 35 deletions.
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
--default_path spec
--order rand
--warnings
4 changes: 2 additions & 2 deletions features/Upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Now you can just type
rspec

to run all the specs in the `spec` directory. If you keep your specs in a
different directory, you can override the default with the `--default_path`
different directory, you can override the default with the `--default-path`
argument in a config file:

# in .rspec
--default_path specs
--default-path specs

### `rspec` command supports multiple line numbers

Expand Down
12 changes: 6 additions & 6 deletions features/configuration/default_path.feature
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Feature: default_path
Feature: default-path

As of rspec-2.7, you can just type `rspec` to run all specs that live
in the `spec` directory.

This is supported by a `--default_path` option, which is set to `spec` by
This is supported by a `--default-path` option, which is set to `spec` by
default. If you prefer to keep your specs in a different directory, or assign
an individual file to `--default_path`, you can do so on the command line or
an individual file to `--default-path`, you can do so on the command line or
in a configuration file (`.rspec`, `~/.rspec`, or a custom file).

NOTE: this option is not supported on `RSpec.configuration`, as it needs to
be set before spec files are loaded.

Scenario: run `rspec` with default default_path (`spec` directory)
Scenario: run `rspec` with default default-path (`spec` directory)
Given a file named "spec/example_spec.rb" with:
"""ruby
describe "an example" do
Expand All @@ -22,10 +22,10 @@ Feature: default_path
When I run `rspec`
Then the output should contain "1 example, 0 failures"

Scenario: run `rspec` with customized default_path
Scenario: run `rspec` with customized default-path
Given a file named ".rspec" with:
"""
--default_path behavior
--default-path behavior
"""
Given a file named "behavior/example_spec.rb" with:
"""ruby
Expand Down
15 changes: 1 addition & 14 deletions lib/rspec/core/option_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ def self.parse(args)
def parse(args)
return {} if args.empty?

convert_deprecated_args(args)

options = args.delete('--tty') ? {:tty => true} : {}
begin
parser(options).parse!(args)
Expand All @@ -23,17 +21,6 @@ def parse(args)
options
end

def convert_deprecated_args(args)
args.map! { |arg|
case arg
when "--default_path"
"--default-path"
else
arg
end
}
end

def parser(options)
OptionParser.new do |parser|
parser.banner = "Usage: rspec [options] [files or directories]\n\n"
Expand Down Expand Up @@ -205,7 +192,7 @@ def parser(options)

# these options would otherwise be confusing to users, so we forcibly prevent them from executing
# --I is too similar to -I
# -d was a shorthand for --debugger, which is removed, but now would trigger --default_path
# -d was a shorthand for --debugger, which is removed, but now would trigger --default-path
invalid_options = %w[-d --I]

parser.on_tail('-h', '--help', "You're looking at it.") do
Expand Down
10 changes: 5 additions & 5 deletions spec/rspec/core/configuration_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
end

it "sets default_path before loading specs" do
opts = config_options_object(*%w[--default_path spec])
opts = config_options_object(*%w[--default-path spec])
config = RSpec::Core::Configuration.new
expect(config).to receive(:force).with(:default_path => 'spec').ordered
expect(config).to receive(:get_files_to_run).ordered
Expand All @@ -64,7 +64,7 @@
end

it "sets default_path before `files_or_directories_to_run` since it relies on it" do
opts = config_options_object(*%w[--default_path spec])
opts = config_options_object(*%w[--default-path spec])
config = RSpec::Core::Configuration.new
expect(config).to receive(:force).with(:default_path => 'spec').ordered
expect(config).to receive(:files_or_directories_to_run=).ordered
Expand Down Expand Up @@ -103,7 +103,7 @@
["--failure-exit-code", "3", :failure_exit_code, 3 ],
["--pattern", "foo/bar", :pattern, "foo/bar"],
["--failure-exit-code", "37", :failure_exit_code, 37],
["--default_path", "behavior", :default_path, "behavior"],
["--default-path", "behavior", :default_path, "behavior"],
["--order", "rand", :order, "rand"],
["--seed", "37", :order, "rand:37"],
["--drb-port", "37", :drb_port, 37]
Expand Down Expand Up @@ -311,12 +311,12 @@
end
end

describe "default_path" do
describe "default-path" do
it "gets set before files_or_directories_to_run" do
config = RSpec::Core::Configuration.new
expect(config).to receive(:force).with(:default_path => 'foo').ordered
expect(config).to receive(:get_files_to_run).ordered
opts = config_options_object("--default_path", "foo")
opts = config_options_object("--default-path", "foo")
opts.configure(config)
config.files_to_run
end
Expand Down
7 changes: 0 additions & 7 deletions spec/rspec/core/option_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ def generate_help_text
expect { generate_help_text }.to_not output(useless_lines).to_stdout
end

describe "--default_path" do
it "gets converted to --default-path" do
options = Parser.parse(%w[--default_path foo])
expect(options[:default_path]).to eq "foo"
end
end

describe "--default-path" do
it "sets the default path where RSpec looks for examples" do
options = Parser.parse(%w[--default-path foo])
Expand Down

0 comments on commit d7161b7

Please sign in to comment.