Permalink
Browse files

`require 'rspec/autorun'` when running rcov

- Fixes #370.
  • Loading branch information...
dchelimsky committed May 19, 2011
1 parent 899c679 commit 90db0907e378c6551895b6a36fdde92d04e056c7
Showing with 3 additions and 0 deletions.
  1. +1 −0 features/Changelog.md
  2. +2 −0 lib/rspec/core.rb
View
@@ -4,6 +4,7 @@
* Bug fixes
* Don't extend nil when filters are nil
+ * `require 'rspec/autorun'` when running rcov.
### 2.6.0 / 2011-05-12
View
@@ -26,6 +26,8 @@
require 'rspec/core/version'
require 'rspec/core/errors'
+require 'rspec/autorun' if $0.split(File::SEPARATOR).last == 'rcov'
+
module RSpec
autoload :Matchers, 'rspec/matchers'

9 comments on commit 90db090

@sundbp

This comment has been minimized.

Show comment Hide comment
@sundbp

sundbp Jul 11, 2011

This fix is only partial, it fails for the case when bundler is used and rcov is executed via bundle exec.

Something like this would do the trick:
require 'rspec/autorun' if $0.split(File::SEPARATOR).last == 'rcov' or [$0, $1, $2].join(" ") == 'bundle exec rcov'

This fix is only partial, it fails for the case when bundler is used and rcov is executed via bundle exec.

Something like this would do the trick:
require 'rspec/autorun' if $0.split(File::SEPARATOR).last == 'rcov' or [$0, $1, $2].join(" ") == 'bundle exec rcov'

@dchelimsky

This comment has been minimized.

Show comment Hide comment
@dchelimsky

dchelimsky Jul 11, 2011

Owner

@sundbp - lots of people use aliases for bundle exec, so that wouldn't solve this problem. Would you do me a favor and raise an issue on this so we have a better place for the conversation?

Owner

dchelimsky replied Jul 11, 2011

@sundbp - lots of people use aliases for bundle exec, so that wouldn't solve this problem. Would you do me a favor and raise an issue on this so we have a better place for the conversation?

@sundbp

This comment has been minimized.

Show comment Hide comment
@sundbp

sundbp Jul 12, 2011

Ah, right. Sure, done.
#422

Ah, right. Sure, done.
#422

@caifara

This comment has been minimized.

Show comment Hide comment
@caifara

caifara Aug 2, 2011

I was having problems running rcov in cucumber as it was running rspec after my features:

bundle exec rcov "....cucumber-0.10.7/bin/cucumber" -o "rcov" --rails --exclude osx\/objc,gems\/,spec\/  -- -t @doesnotexist
Bundling your gems. This may take a few minutes on first run.
Using the default profile...
0 scenarios
0 steps
0m0.000s
No examples matched {:doesnotexist=>true}.


Finished in 0.00004 seconds
0 examples, 0 failures

I didn't really look into this long enough (finding this took ages), but commenting out this line made my cucumber features run again like normal. Did I do something wrong somewhere else or is this line not good enough?

I was having problems running rcov in cucumber as it was running rspec after my features:

bundle exec rcov "....cucumber-0.10.7/bin/cucumber" -o "rcov" --rails --exclude osx\/objc,gems\/,spec\/  -- -t @doesnotexist
Bundling your gems. This may take a few minutes on first run.
Using the default profile...
0 scenarios
0 steps
0m0.000s
No examples matched {:doesnotexist=>true}.


Finished in 0.00004 seconds
0 examples, 0 failures

I didn't really look into this long enough (finding this took ages), but commenting out this line made my cucumber features run again like normal. Did I do something wrong somewhere else or is this line not good enough?

@dchelimsky

This comment has been minimized.

Show comment Hide comment
@dchelimsky

dchelimsky Aug 2, 2011

Owner

@caifara - interesting situation - bundler is requiring 'rspec/core' because it's part of the bundle. Try adding gem 'rspec-core', :require => false to your Gemfile. That should be ok because your spec_helper probably requires what it needs from rspec for when you run specs. Let me know if that works.

Owner

dchelimsky replied Aug 2, 2011

@caifara - interesting situation - bundler is requiring 'rspec/core' because it's part of the bundle. Try adding gem 'rspec-core', :require => false to your Gemfile. That should be ok because your spec_helper probably requires what it needs from rspec for when you run specs. Let me know if that works.

@caifara

This comment has been minimized.

Show comment Hide comment
@caifara

caifara Aug 3, 2011

That works, but I also use email_spec which requires rspec so I'm yet again running rSpec after cucumber (https://github.com/bmabey/email-spec/blob/master/lib/email_spec.rb). Should I raise an issue over there (I'm afraid other libraries may also require rspec, so this may not be the most effective solution).

That works, but I also use email_spec which requires rspec so I'm yet again running rSpec after cucumber (https://github.com/bmabey/email-spec/blob/master/lib/email_spec.rb). Should I raise an issue over there (I'm afraid other libraries may also require rspec, so this may not be the most effective solution).

@dchelimsky

This comment has been minimized.

Show comment Hide comment
@dchelimsky

dchelimsky Aug 3, 2011

Owner

There's really nothing that other gems that actually depend on rspec can do here. Would you do me a favor and raise this as a new issue and reference this thread? We're probably going to need a different solution in rspec itself.

Owner

dchelimsky replied Aug 3, 2011

There's really nothing that other gems that actually depend on rspec can do here. Would you do me a favor and raise this as a new issue and reference this thread? We're probably going to need a different solution in rspec itself.

@caifara

This comment has been minimized.

Show comment Hide comment
@caifara

caifara Aug 3, 2011

Here you are: #431

Here you are: #431

@dchelimsky

This comment has been minimized.

Show comment Hide comment
@dchelimsky

dchelimsky Aug 3, 2011

Owner

Thanks!

Owner

dchelimsky replied Aug 3, 2011

Thanks!

Please sign in to comment.