Permalink
Browse files

`--require` is merged among different configuration sources

* e.g., `--require` specified in SPEC_OPTS will be merged with
  `--require` specified in `.rspec`
* Fixes #594
  • Loading branch information...
1 parent 2cf3b45 commit 9518119f6700232a1aa5de88570ba09de741dd4f @alindeman alindeman committed Jun 9, 2012
Showing with 13 additions and 1 deletion.
  1. +5 −1 lib/rspec/core/configuration_options.rb
  2. +8 −0 spec/rspec/core/configuration_options_spec.rb
@@ -25,7 +25,9 @@ def configure(config)
def parse_options
@options ||= extract_filters_from(*all_configs).inject do |merged, pending|
- merged.merge(pending)
+ merged.merge(pending) { |key, oldval, newval|
+ MERGED_OPTIONS.include?(key) ? oldval + newval : newval
+ }
end
end
@@ -44,6 +46,8 @@ def filter_manager
:line_numbers, :full_description, :full_backtrace, :tty
].to_set
+ MERGED_OPTIONS = [:requires].to_set
@alindeman
alindeman Jun 9, 2012 Contributor

This seems a bit silly, but I thought maybe other options could benefit from it. Should options like -I (:libs) be merged too? @dchelimsky

@justinko
justinko Jun 11, 2012 Contributor

@alindeman makes sense to me

@dchelimsky
dchelimsky Jun 11, 2012 Member

@alindeman I think the -I option should be merged, too.

+
def force?(key)
!NON_FORCED_OPTIONS.include?(key)
end
@@ -95,6 +95,14 @@
config.should_receive(:debug=).with(true)
opts.configure(config)
end
+
+ it "merges --require specified by multiple configuration sources" do
+ ENV['SPEC_OPTS'] = "--require file_from_env"
+ opts = config_options_object(*%w[--require file_from_opts])
+ config = RSpec::Core::Configuration.new
+ config.should_receive(:requires=).with(["file_from_opts", "file_from_env"])
+ opts.configure(config)
+ end
end
describe "-c, --color, and --colour" do

0 comments on commit 9518119

Please sign in to comment.