Forgive me if the question is a common one... does rspec have any concept like given "a certain set of paths" do it "should be able to recreate them" do; end it "..."; end end ? Thanks. -r
On Tue, Dec 22, 2009 at 9:35 AM, rogerdpack <rogerpack2005 at gmail.com> wrote:> Forgive me if the question is a common one... > > does rspec have any concept like > > given "a certain set of paths" do > > it "should be able to recreate them" do; end > it "..."; end > end >Not built into rspec. There is a merb extension that does that, but there is no "when" and "then" counterpart, so I didn''t want to add it to rspec. HTH, David> ? > Thanks. > -r > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091222/bb56f198/attachment.html>
On Tue, Dec 22, 2009 at 10:38 AM, David Chelimsky <dchelimsky at gmail.com> wrote:> On Tue, Dec 22, 2009 at 9:35 AM, rogerdpack <rogerpack2005 at gmail.com> wrote: >> >> Forgive me if the question is a common one... >> >> does rspec have any concept like >> >> given "a certain set of paths" do >> >> ?it "should be able to recreate them" do; end >> ?it "..."; end >> end > > Not built into rspec. There is a merb extension that does that, but there is > no "when" and "then" counterpart, so I didn''t want to add it to rspec.It looks like that merb extension was about injecting a part of a before block by adding an option to describe, yes? http://www.mail-archive.com/rspec-users at rubyforge.org/msg07327.html I don''t see that that''s what Roger is asking for though. It seems to me that he''s asking more for yet another synonym for describe or context. In which case I''d suggest just using describe or context as in: context "given a certain set of paths" do before(:each) do # code to set up the paths however the included specs need them, e.g. @paths = ["a/b", "c/d"] end it "should be able to recreate them" do; end it "..."; end end I tend to use describe for the top level, and context when nested. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale
On Tue, Dec 22, 2009 at 10:15 AM, Rick DeNatale <rick.denatale at gmail.com>wrote:> On Tue, Dec 22, 2009 at 10:38 AM, David Chelimsky <dchelimsky at gmail.com> > wrote: > > On Tue, Dec 22, 2009 at 9:35 AM, rogerdpack <rogerpack2005 at gmail.com> > wrote: > >> > >> Forgive me if the question is a common one... > >> > >> does rspec have any concept like > >> > >> given "a certain set of paths" do > >> > >> it "should be able to recreate them" do; end > >> it "..."; end > >> end > > > > Not built into rspec. There is a merb extension that does that, but there > is > > no "when" and "then" counterpart, so I didn''t want to add it to rspec. > > It looks like that merb extension was about injecting a part of a > before block by adding an option to describe, yes? > http://www.mail-archive.com/rspec-users at rubyforge.org/msg07327.html > > I don''t see that that''s what Roger is asking for though. It seems to > me that he''s asking more for yet another synonym for describe or > context. > > In which case I''d suggest just using describe or context as in: > > context "given a certain set of paths" do > before(:each) do > # code to set up the paths however the included specs need them, e.g. > @paths = ["a/b", "c/d"] > end > > it "should be able to recreate them" do; end > it "..."; end > end > > I tend to use describe for the top level, and context when nested. >Ah - I see what you mean. Though, I tend to use describe() for nouns and context for context. describe "something" do context "in some state" do Usuall that works out that the outer block starts w/ describe and the inner starts w/ context, but sometimes there are describe blocks nested within describe blocks as well. --> Rick DeNatale > > Blog: http://talklikeaduck.denhaven2.com/ > Twitter: http://twitter.com/RickDeNatale > WWR: http://www.workingwithrails.com/person/9021-rick-denatale > LinkedIn: http://www.linkedin.com/in/rickdenatale > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091222/b96e4bdb/attachment-0001.html>
> context "given a certain set of paths" doAhh so it''s called context. Cool (though I''ll admit that naming it "given" can make it sound more like an English sentence, so an alias would be a suggestion). Much thanks. -r
On Tue, Dec 22, 2009 at 10:31 AM, rogerdpack <rogerpack2005 at gmail.com>wrote:> > > context "given a certain set of paths" do > > Ahh so it''s called context. > > Cool (though I''ll admit that naming it "given" can make it sound more > like an English sentence, so an alias would be a suggestion). >http://gist.github.com/206969 I''m not adding that to rspec though, as we already have enough confusion just between context and describe :) Cheers, David> Much thanks. > -r > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091222/2c386cc0/attachment.html>