Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue Mar 22, 2012 · 0 comments
Closed

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

ghost opened this issue Mar 22, 2012 · 0 comments

Comments

@ghost
Copy link

ghost commented Mar 22, 2012

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_options:
  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))
    end

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant