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

migration on RR mock framework #18

Open
azzz opened this issue Jun 11, 2012 · 2 comments
Open

migration on RR mock framework #18

azzz opened this issue Jun 11, 2012 · 2 comments

Comments

@azzz
Copy link

azzz commented Jun 11, 2012

What do you think about using RR instead of default rspec mocks?
I see that you wrote a lot of specs using rspec mocks. But RR looks simpler and faster. It is just idea, of course: maybe you already had discussion and i just meddle in other people's business:]
I can rewrite specs if you approve this idea.

@jurgens
Copy link
Collaborator

jurgens commented Jun 11, 2012

what are benefits?

@azzz
Copy link
Author

azzz commented Jun 11, 2012

For example, less code:

mock(User).find_or_create_with_oauth { user }

instead of

User.should_receive(:find_or_create_with_oauth).and_return(user)

And supporting mocks with proxy:

mock.proxy(User).find_or_create_with_oauth(anything)

User.find_or_create_with_oauth will be called and process and rspec also check it. I.e. if you want to mock method and you also need to really process the method.

mock.proxy(view).render(:partial => "user_info") do |html|
  html.should include("John Doe")
  "Different html"
end

Look: view#render will be processed and you can use rspec matchers in mock

Also it supports a mocks with checking attributes:
Just look this gem https://github.com/btakita/rr
We are using it in gettaxi.com and it is very cool.

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