From: Patrick Fernie Date: 2007-01-24T06:53:39+09:00 Subject: Re: test/spec -- was Re: I don't get rspec Is there an equivalent to autotest for rspec (autospec?)? I've googled around, but only came across a Rails plugin, which (perhaps obviously) is very Rails-centric. -P On 1/23/07, David Chelimsky wrote: > On 1/23/07, Christian Neukirchen wrote: > > Joel VanderWerf writes: > > > > > I like the continuity with test/unit. I'd be more likely to use this > > > than rspec for my older projects. > > > > > > Questions (from a BDD newbie): > > > > > > Are the context and specify argument strings purely documentation, or > > > do they need to be class or method names? > > > > They can contain anything except NUL bytes (the extended symbol > > syntax). They are turned into class and method names automatically > > (we need some special formatting for that due to Test::Unit > > restrictions). > > > > > Is it possible to nest contexts? Is this a good idea? > > > > test/spec allows them since 0.2, and I use them to group contexts that > > go together. Note that nothing is inherited, it's purely namespacing. > > RSpec doesn't have them, and they aren't interesting in implementing > > them AFAICT. > > That's correct. We've really struggled with this because users want a > means of sharing context material, but we believe that nesting > contexts is going to lead to specs that are confusing to look at. We > believe that clarity supercedes DRY in specs, and so we haven't > supported this yet. > > That said, you can include modules and get reuse that way: > > module SomeHelperMethodsUsefulAcrossContexts > end > > context "some context" do > include SomeHelperMethodsUsefulAcrossContexts > end > > I'd be surprised if test/spec doesn't already support this out of the box. > > Cheers, > David > > > > > > Inside of a context, is there a setup/teardown protocol as there is in > > > test/unit? > > > > Yes, you can use > > > > context "Blah" do > > setup do > > @blah = Blah.new > > end > > > > teardown do > > @blah.destroy! > > end > > end > > > > You can have multiple of these, and they are run in order of > > appearance. > > > > -- > > Christian Neukirchen http://chneukirchen.org > > > > > >