Skip to content

can't use --example with SPEC_OPTS or .rspec file #586

eldelaney opened this Issue Mar 22, 2012 · 0 comments

2 participants


The parsing of --example from SPEC_OPTS or .rspec is broken.

In both cases the options are parsed by splitting it based on spaces, which means
that spaces can not be included in the example argument. For example:

$ SPEC_OPTS='--example "foo bar"' /usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby -I /home/cross/tail/work/accept -I /home/cross/tail/accept /usr/local/rvm/gems/ruby-1.9.3-p125/bin/rspec -fn /home/cross/tail/accept/twtail_spec_short.rb /home/cross/tail/accept/twtail_spec.rb
  ENV[SPEC_OPTS]: --example "foo bar"
  split: {:full_description=>/"foo/}
Run options: include {:full_description=>/(?-mix:"foo)/}

All examples were filtered out

Finished in 0.00003 seconds
0 examples, 0 failures

As you can see rspec only associated the "foo with the --example because the arguments
are split based on spaces:

    ENV["SPEC_OPTS"] ? Parser.parse!(ENV["SPEC_OPTS"].split) : {}

To get around this previously we would replace all spaces with .'s (periods) which would
work fine with Regexp, but with the newer versions of RSpec escape the Regexp:

    parser.on('-e', '--example STRING', "Run examples whose full nested names include STRING") do |o|
      options[:full_description] = Regexp.compile(Regexp.escape(o))

While this corrects the behavior for processing --example from the command line it
further breaks processing --example from SPEC_OPTS or the .rpsec file.

@justinko justinko closed this in 268eeb4 Mar 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.