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

Any way to make transition from vanilla RSpec easier? #30

Open
marten opened this issue Jul 22, 2013 · 5 comments
Open

Any way to make transition from vanilla RSpec easier? #30

marten opened this issue Jul 22, 2013 · 5 comments

Comments

@marten
Copy link

marten commented Jul 22, 2013

If you add Bogus, you lose RSpec's double, and the syntax for stub changes. Is there any way of incrementally adding Bogus to an existing codebase?

We're on RSpec 2.14 with no deprecation warnings, so all our test doubles are instantiated with double() (stub/mock are deprecated), but we do have a bunch of object.stub(method: result). This means that (for us) Bogus' stub(object).method { result } should not conflict as long as we can keep object.stub working as in rspec_mocks.

@wrozka
Copy link
Collaborator

wrozka commented Jul 23, 2013

Hi, I've copied a little bit of rspec-mocks api on top of bogus in this gist. Check if it covers your use cases. It is tested and uses only public api, however it is still a hack, so I would use it only during the transition phase. :)

The double from the gist can create both named and anonymous fakes. Keep in mind that when you use anonymous fakes you loose all the safety benefits.

@psyho
Copy link
Owner

psyho commented Jul 25, 2013

We should probably consider making this mapping available as a part of Bogus.

@marten
Copy link
Author

marten commented Jul 25, 2013

Maybe an optional require 'bogus/rspec-mocks-compatibility' that the user does if it want it? That file might even raise if the loaded RSpec is known to be incompatible (alternatively: not known to be compatible).

The gist didn't seem to work, but I haven't had the time to track down why yet. Hopefully tomorrow. But thanks for your efforts, really appreciate it!

@wrozka
Copy link
Collaborator

wrozka commented Aug 2, 2013

What was the problem with the gist? I tested it on rspec 2.14.1 and bogus 0.1.3.

@ootoovak
Copy link

@wrozka I agree with @marten and @psyho's suggestion. I think it would help adoption as people would be more confident that the compatibility layer is kept up to date with the Bogus code and that it has some sort of test coverage with out having to come here to find the Gist and find out which version it has been tested against.

I know I have a large project that I would like to port over to Bogus eventually. Knowing I could trust the compatibility layer to stay in sync with Bogus while I make the transition would make me more confident in starting this.

I'm sure it is volunteer work to keep it all up to date so I can understand not wanting to commit to that but I just wanted to give you a use case for having it in the Gem rather than in a separate Gist. Great work so far!

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

4 participants