Skip to content

Commit

Permalink
Merge pull request #511 from AlexKVal/simpler_syntax
Browse files Browse the repository at this point in the history
simpler --tag TAG[:VALUE] parsing and remove small duplication
  • Loading branch information
dchelimsky committed Nov 30, 2011
2 parents bb2b02a + b062e79 commit a94414f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
9 changes: 1 addition & 8 deletions lib/rspec/core/option_parser.rb
Expand Up @@ -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.',
Expand Down
6 changes: 3 additions & 3 deletions spec/rspec/core/configuration_options_spec.rb
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/rspec/core/option_parser_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit a94414f

Please sign in to comment.