Skip to content
Browse files

Merge pull request #511 from AlexKVal/simpler_syntax

simpler --tag TAG[:VALUE] parsing and remove small duplication
  • Loading branch information...
2 parents bb2b02a + b062e79 commit a94414fca945b6f0e1e9c6bc552340b333e0ad8c @dchelimsky dchelimsky committed
View
9 lib/rspec/core/option_parser.rb
@@ -154,14 +154,7 @@ def parser(options)
name = name.to_sym
options[filter_type] ||= {}
- options[filter_type][name] = case value
- when /^(true|false|nil)$/
- eval(value)
- when nil
- true
- else
- value
- end
+ options[filter_type][name] = value.nil? ? true : eval(value) rescue value
end
parser.on('--default_path PATH', 'Set the default path where RSpec looks for examples.',
View
6 spec/rspec/core/configuration_options_spec.rb
@@ -140,9 +140,9 @@
describe "--format, -f" do
it "sets :formatter" do
- parse_options('--format', 'd').should include(:formatters => [['d']])
- parse_options('-f', 'd').should include(:formatters => [['d']])
- parse_options('-fd').should include(:formatters => [['d']])
+ [['--format', 'd'], ['-f', 'd'], '-fd'].each do |args|
+ parse_options(*args).should include(:formatters => [['d']])
+ end
end
example "can accept a class name" do
View
5 spec/rspec/core/option_parser_spec.rb
@@ -109,6 +109,11 @@ module RSpec::Core
options = Parser.parse!([option, 'foo:false', option, 'bar:true', option, 'foo:true'])
options[:inclusion_filter].should eq(:foo => true, :bar => true)
end
+
+ it "treats 'any_string' as 'any_string'" do
+ options = Parser.parse!([option, 'foo:any_string'])
+ options[:inclusion_filter].should eq(:foo => 'any_string')
+ end
end
context "with ~" do

0 comments on commit a94414f

Please sign in to comment.
Something went wrong with that request. Please try again.