Permalink
Browse files

Refactoring of ConfigurationOptions#parse_options

- Closes #346.
  • Loading branch information...
1 parent 44d305c commit 9e9129117003c4de91d32ff285b749898318d05f @rosenfeld rosenfeld committed with dchelimsky Apr 15, 2011
Showing with 7 additions and 20 deletions.
  1. +1 −0 features/Changelog.md
  2. +6 −20 lib/rspec/core/configuration_options.rb
View
@@ -16,6 +16,7 @@
defined. (Myron Marston)
* Pass the exit status of a DRb run to the invoking process. This causes
specs run via DRb to not just return true or false. (Ilkka Laukkanen)
+ * Refactoring of ConfigurationOptions#parse_options (Rodrigo Rosenfeld Rosas)
* Bug fixes
* Don't stumble over an exception without a message (Hans Hasselberg)
@@ -57,35 +57,21 @@ def drb_argv
end
def parse_options
- @options = begin
- options_to_merge = []
- if custom_options_file
- options_to_merge << custom_options
- else
- options_to_merge << global_options
- options_to_merge << local_options
- end
- options_to_merge << command_line_options
- options_to_merge << env_options
-
- options_to_merge.inject do |merged, options|
- merged.merge(options)
- end
- end
+ @options ||= [file_options, command_line_options, env_options].inject {|merged, o| merged.merge o}
end
private
+ def file_options
+ custom_options_file ? custom_options : global_options.merge(local_options)
+ end
+
def env_options
ENV["SPEC_OPTS"] ? Parser.parse!(ENV["SPEC_OPTS"].split) : {}
end
def command_line_options
- @command_line_options ||= begin
- options = Parser.parse!(@args)
- options[:files_or_directories_to_run] = @args
- options
- end
+ @command_line_options ||= Parser.parse!(@args).merge :files_or_directories_to_run => @args
end
def custom_options

0 comments on commit 9e91291

Please sign in to comment.