Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support default_path option across all supported rubies

The issue was the non-deterministic order of hash keys.
  • Loading branch information...
commit 1da8e3179a3ff911b1035e79ab22202eeca92554 1 parent 9f7b495
@dchelimsky dchelimsky authored
View
9 features/configuration/default_path.feature
@@ -1,4 +1,3 @@
-@no-ruby-186
Feature: default_path
As of rspec-2.7 (not yet released), you can just type `rspec` to run all
@@ -6,13 +5,11 @@ Feature: default_path
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 the `--default_path`, you can do so on the command line
- or in a configuration file (`.rspec`, `~/.rspec`, or a custom file).
+ 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 get loaded.
-
- WARNING: this feature is not supported on Ruby-1.8.6
+ be set before spec files are loaded.
Scenario: run `rspec` with default default_path (`spec` directory)
Given a file named "spec/example_spec.rb" with:
View
11 lib/rspec/core/configuration_options.rb
@@ -9,9 +9,7 @@ def initialize(args)
end
def configure(config)
- keys = options.keys
- keys.unshift(:requires) if keys.delete(:requires)
- keys.unshift(:libs) if keys.delete(:libs)
+ keys = order(options.keys, :libs, :requires, :default_path)
formatters = options[:formatters] if keys.delete(:formatters)
@@ -71,6 +69,13 @@ def parse_options
private
+ def order(keys, *ordered)
+ ordered.reverse.each do |key|
+ keys.unshift(key) if keys.delete(key)
+ end
+ keys
+ end
+
def file_options
custom_options_file ? custom_options : global_options.merge(local_options)
end
View
10 spec/rspec/core/configuration_options_spec.rb
@@ -203,9 +203,17 @@ def parse_options(*args)
it "parses dir and files from 'spec/file1_spec.rb, spec/file2_spec.rb'" do
parse_options("dir", "spec/file1_spec.rb", "spec/file2_spec.rb").should include(:files_or_directories_to_run => ["dir", "spec/file1_spec.rb", "spec/file2_spec.rb"])
-
end
+ end
+ describe "default_path" do
+ it "gets set before files_or_directories_to_run" do
+ config = double("config").as_null_object
+ config.should_receive(:default_path=).ordered
+ config.should_receive(:files_or_directories_to_run=).ordered
+ opts = config_options_object("--default_path", "foo")
+ opts.configure(config)
+ end
end
# TODO ensure all options are output
Please sign in to comment.
Something went wrong with that request. Please try again.