On Sat, Jan 24, 2009 at 12:08 PM, Stephen Eley <[email protected]> wrote:
> > On Sat, Jan 24, 2009 at 11:17 AM, Michael Klishin > <[email protected]> wrote: > > > > Merb's concept of testing of requests is "test the whole stack". It > > does not matter how isolated your tests are, > > as long as they do what they supposed to do: reveal problems as you do > > changes to the code. > > I've just gotta play Devil's Advocate here. > > What you are describing is not strictly Merb's concept of testing > requests. It's Yehuda Katz's concept of testing requests. It's a > pretty good concept and I happen to agree with it, but Yehuda and Ezra > have also said over and over that Merb should not be too opinionated. > That it may ship with particular default opinions, but if you have > *other* opinions it should not be too difficult to slot your own in. > > Philp may be somewhat annoying in his wheedling "ask questions by > complaining" style, but in this case he's actually right. There *is* > a gap in Merb testing. It really is harder to test partials or > helpers in Merb than it is in Rails. I tried it myself on a helper > for a little while and then gave up on it, because figuring out how to > simulate a view context for the testing turned out to be harder than > the code itself was worth. I blogged about the experience: > > http://extraneous.org/past/2009/1/3/learning_from_trying_too_hard/ > > As I said there, the lesson I took from that reinforced Yehuda's > philosophy. There's a sensible reason why the gap exists: there's no > help for view isolation testing because no one on the core team wanted > it. Fair enough. In my particular use case that wasn't a problem. > > BUT. I can think of cases where it'd be genuinely helpful. Plugins > would be a good example. If I want to share my little helper with the > world as a gem, it'd be a more useful test for *your* app if I tested > it in isolation against the Merb public API than if I rigged up a fake > mini-application in the specs. I'm sure it's possible to do that now > if one knew Merb's innards well enough, but there are no test helpers > for it, so it'd take pretty deep knowledge to set up the context. > > Merb and Rails are both good demonstrations that tools create > cultures. Following the lead of Merb's creators, this culture's > majority view is that integration testing is to be lauded and > isolation testing of controllers and views is to be denigrated. Fair > enough. But griping at everyone who raises the question, to say that > to want isolation testing means you're Doing It Wrong regardless of > business need or context, seems unnecessarily dogmatic. And my own > understanding was that Merb culture is supposed to be against > dogmatism. > > Am I wrong? No. I agree with you here. I have *never* been opposed to giving people tools to do more isolation testing, and I agree that this represents a gap in Merb testing. A couple of things to keep in mind (when solving this problem): - Merb's render_mixin is a mixin, not part of Merb::Controller or Merb::AbstractController. However, it does assume at least AbstractController capabilities. Therefore; - Option 1: Create a testing context that uses RenderMixin - Option 2: Use a one-off AbstractController to test partials I may take a look at it this week if nobody nabs it first. -- Yehuda > > > > -- > Have Fun, > Steve Eley ([email protected]) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > > > > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "merb" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/merb?hl=en -~----------~----~----~----~------~----~------~--~---
