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
Undefined method stub report #15
Comments
Myron - that spec output is fantastic. Let's not worry about other frameworks at all until this is up and running. I had not considered the means of reporting this. I need to give that some thought. Even though rspec-mocks is part of rspec, it's still a separate library, and I don't want to have any explicit dependencies on it from rspec-core other than the adapter. I think we need an API for external libraries to extend existing formatters. WDYT? I started to work on an event-based pub/sub messaging approach to reporting (on branch events), but put that off for rspec-2.1. I think that would make a formatter extension API much more feasible. Agree? In terms of naming, the names you have suggest that the stub is not defined rather than the method being stubbed. How about something like |
Exactly. This was the issue I was facing in trying to figure out the reporting, which is why I suggested adding an additional method to the mocking adapters for this--that would be the only point of contact. I think I like your API idea better, though :).
I took a look at the branch. It looks like that would allow me to know what the current running example is, but I'm not sure how that would play into the formatter API. What did you have in mind? I was originally thinking that we could just expose the current running example as a class method of
I thought about that, but to me it sounds like it's for stubs only and not for mocks (especially given Fowler's "mocks aren't stubs" article). I figured What did you have in mind for the formatter extension API? One complexity is that people can define external formatters--would I have to extend those as well? Or could we find a way to extend in a generic way that works for all formatters? |
@myronmarston - its "stubbed" not "stubed" :) |
@justinko: I was aware of that when I wrote the code. I'm dynamically generating those specs in a loop (one iteration for mocks, one iteration for stubs), and I just added "ed" in the doc string to the variable that has "mock" or "stub". I could put more logic in place so that it's spelled right, but I didn't think it was worth it. |
I tried to reply to the mailing list thread, but had some Google account problems. Just to clarify my understanding I wrote up a little example gist using the canonical My comment on the Gist describes a potential use case that I see for this kind of feature. Am I barking up the wrong tree? Also, do you need any help getting this implemented? What can I do to help? |
@jamesmartin: Thanks for sharing your example. The feature I've proposed here probably wouldn't help in an case like yours, because you are using pure test doubles, as opposed to setting a mock or stub on a concrete object. If your specs set the logger variable to The hold up on this feature is that we want the report to be printed at the end of the spec run, but there currently isn't support in rspec-core for this. There's an open issue about this that will need to be resolved first. In the meantime, check out aidmock. It may do what you want. Myron |
At this point, I've been using (and loving) rspec-fire for a while. I'm happy to let that remain in an extension gem and leave rspec-mocks how it is. |
As discussed on the mailing list, I've started the work on adding an undefined method stub report in a branch. I've got things to the point where I've recorded all the various bits of info, and now we just need to add the code to print the report. Since there wasn't much feedback from others, I figured it'd be easiest to nail down the details here, but we can take the conversation back to the mailing list if you'd prefer.
For reference, here's the current documentation output for the UndefinedMethodDouble specs:
David, at this point, I could use some input from you.
<pre>
block.setup_mocks_for_rspec
,verify_mocks_for_rspec
andteardown_mocks_for_rspec
), we can add an (optional) fourth method:print_summary_for_rspec
. For now, rspec-mocks would be the only one to actually do anything here, but in the future if any of the other mocking libraries provide similar functionality, they'd have a place to hook in.BTW, I'm not 100% happy with my naming of things (particularly
UndefinedMethodDouble
), so please make suggestions for anything you think could be organized or named better!The text was updated successfully, but these errors were encountered: