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

Don't auto-configure global concepts when rspec-mocks is required #7

Closed
dchelimsky opened this issue Jul 3, 2010 · 9 comments
Closed

Comments

@dchelimsky
Copy link
Contributor

Background: http://github.com/rspec/rspec-rails/issues#issue/114

require 'rspec-mocks' should not do any of:

  • add should_receive to Object
  • add should_not_receive to Object
  • add stub to Object
  • add double, mock, or stub methods to ExampleGroup or any the test-case class of other consuming framework
@dchelimsky
Copy link
Contributor Author

This should only happen when RSpec::Mocks::setup is called explicitly.

@wincent
Copy link

wincent commented Jul 3, 2010

Looking at the code now, looks like you've done a great job of compartmentalizing the "extensions to the Object namespace" and all the rest, so hopefully this won't be too painful to implement.

@wincent
Copy link

wincent commented Jul 3, 2010

I'm wondering if something as simple as this will be close to what's need:

http://gist.github.com/462638

Breaks 4 examples, though, so currently looking into that.

@dchelimsky
Copy link
Contributor Author

I'm about to push the fix.

@dchelimsky
Copy link
Contributor Author

It's not quite that simple :)

@dchelimsky
Copy link
Contributor Author

require 'rspec/mocks' does not add methods to Object or ExampleGroup

  • call RSpec::Mocks::setup(self) from an example to add double(),
    mock(), and stub() methods to self, and should_receive(),
    should_not_receive(), and stub() methods to Object.
  • NOTE the stub() on self is an alias for double(), whereas the stub()
    on every other object is a method stub declaration.

Closed by e8b3fde.

@wincent
Copy link

wincent commented Jul 3, 2010

Er, if you say so ;-)

Funnily enough, I found that my "simple" solution actually does pass all specs if I remove the config.include(RSpec::Mocks::Methods) from the spec_helper.

Nice work anyway.

Cheers,
Wincent

@dchelimsky
Copy link
Contributor Author

There was another step to this, which is that I wanted to simplify the API for the consuming framework. With the changes I made, rspec-core doesn't need to include RSpec::Mocks::ExampleMethods.

FWIW, I wasn't clear that you were working on a solution until I your comment with the gist above, at which point I was pretty much done with the work I was doing. I appreciate your efforts to contribute and don't want to waste your time when doing so, so I apologize for not making it more clear that this was in progress on my end.

Cheers,
David

@wincent
Copy link

wincent commented Jul 3, 2010

Don't worry about it, it's not like it took me long to do my 2-line patch + feature. The only thing that matters is that the project moves forward, one way or another.

Cheers,
Wincent

This issue was closed.
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

2 participants