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
Mocking HTTP requests #18
Comments
I wrote a brief presentation on testing with Webmock and VCR; it's at http://marnen.github.com/webmock-presentation/webmock.html . Feel free to include a link if it's useful. |
Any suggestions for Rails 2 apps? |
@pawel2105 I've used Webmock and FakeWeb with Rails 2. |
I'd recommend changing the name of the topic to "stubbing HTTP requests" since what you're describing is stubbing (defining controlled responses to messages), not mocking (expecting that messages are received and failing when they are not). |
@dchelimsky The terminology is kind of unfortunate. "Mock object" really should have meant any test double, IMHO, but the term got appropriated for one particular type. You're right that a lot of HTTP mocking is more like stubbing. However...as I think about it, I realize that WebMock may be more like a true mock. If you use None of this really has any bearing on the test practice itself. But the argument is interesting. :) |
@dchelimsky I agree with the change on the strict meaning of stub and mock. |
@andreareginato fix topic name: #43 |
Thanks a lot. I'll take a day off to merge all needed changes, so keep little patience. |
You are welcome) @andreareginato what do you think of http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax? I think we should add this to betterspecs. |
@makaroni4 👍 for expect |
The pull request is on master. I've updated Mocking to Stubbing. Any correction and comment to the updated guideline is appreciated. |
I think you should also change the description from "Sometimes you need to access external services. In these cases you can't rely on the real service but you should mock it with solutions like webmock." to "Sometimes you need to access external services. In these cases you can't rely on the real service but you should stub it with solutions like webmock." |
@Passionate, you are right. Send me a pull request and I'll merge the docs. |
@andreareginato , sent . |
This page needs to be updated. Webmock is no longer maintained for RSpec 3, as per their README. As a suggestion, how about using RSpec's Mocks library? I am not familiar with it myself enough to write example code for it, though |
@onebree Apparently Webmock does work with RSpec 3: see the resolved issue at bblimke/webmock#396. I haven't tried it myself yet, though. I'd be surprised if it weren't compatible with RSpec 3, given that that's what Webmock's own tests use. :) |
I am using RSpec 3.1. At this point, I am just going to use the RSpec Mocks library that RSpec provides. I am also not comfortable using a gem that seems to not be maintained anymore... Given their badges that say failed build and out-of-date dependencies |
Right now I'm working on different project and would be great if you could Thanks a lot Hunter. On Mon, Mar 16, 2015 at 6:12 PM, Hunter Stevens notifications@github.com
Andrea Reginato |
@onebree Where do you get the impression that Webmock isn't maintained anymore? Last release (v.1.20.4) was November 2014, about 4 months ago, and last commit to master was 22 days ago. Webmock does a lot of good stuff. Don't reinvent it if you don't have to. |
On its README, it says it is only supporting up to RSpec 2.x, and its badges stated failed builds and out-of-date dependencies. Although I did contact someone on the Google Group -- they said they are updating the README as it does support RSpec 3. |
FWIW, I've never had any issues with Webmock; I suspect the failed build is more likely to mean that they never set up Travis properly. :) |
As I told the owner in the google group forum:
|
Write your thoughts about the "mocking HTTP requests " best practice.
The text was updated successfully, but these errors were encountered: