> -----Original Message----- > From: rspec-users-boun...@rubyforge.org [mailto:rspec-users- > boun...@rubyforge.org] On Behalf Of David Chelimsky > Sent: Sunday, April 19, 2009 10:03 AM > To: rspec-users > Subject: Re: [rspec-users] Custom Example Groups > > So you probably want to wrap asset_recognizes and assert_generates in > custom matchers at that point: > > def with_method(verb) do |verb| > subject { {:path => description_args.first, :method => verb } } > yield > end > > Spec::Matchers.define :be_accepted do > match do |path_and_method| > wrap_expectation do > assert_recognizes path_and_method > end > end > end > > That's all off the top of my head, so it might not work exactly as/is > - but that's the basic idea. >
Oh, perfect. I didn't think of making the subject a hash. Is it best just to use it within any matcher using that DSL syntax? Thanks, Brandon Just one more question. When should you use wrap_expectation? > Cheers, > David > > > > > Thanks, > > Brandon > > > >> Cheers, > >> David > >> > >> > > >> > Thanks, > >> > Brandon > >> > > >> >> Cheers, > >> >> David > >> >> > >> >> > > >> >> > Pat > >> >> > > >> >> > On Sat, Apr 18, 2009 at 11:31 PM, Brandon Olivares > >> >> > <programmer2...@gmail.com> wrote: > >> >> >> Hi, > >> >> >> > >> >> >> I want to build a custom example group, but there really > aren't > >> any > >> >> examples > >> >> >> anywhere for how to do so. The new chapter in The RSpec Book > >> talks > >> >> about it, > >> >> >> but doesn't actually show an example, only how to register it. > >> >> >> > >> >> >> Looking at rspec-rails, I can see a pattern, but I don't know > if > >> >> that's > >> >> >> specific to rspec-rails, or if it is what should be done. In > >> rspec- > >> >> rails, it > >> >> >> has: > >> >> >> > >> >> >> Class << self > >> >> >> > >> >> >> Within the class, and all the methods are within that. > >> >> >> > >> >> >> So, are there any examples anywhere for how to write an > example > >> >> group? > >> >> >> > >> >> >> Also, if I set an instance variable within the example group, > >> will > >> >> the > >> >> >> matchers specific to that group be able to access it? That'll > >> >> simplify my > >> >> >> design a bit. > >> >> >> > >> >> >> Thanks, > >> >> >> Brandon > >> >> >> > >> >> >> _______________________________________________ > >> >> >> rspec-users mailing list > >> >> >> rspec-users@rubyforge.org > >> >> >> http://rubyforge.org/mailman/listinfo/rspec-users > >> >> >> > >> >> > _______________________________________________ > >> >> > rspec-users mailing list > >> >> > rspec-users@rubyforge.org > >> >> > http://rubyforge.org/mailman/listinfo/rspec-users > >> >> > > >> >> _______________________________________________ > >> >> rspec-users mailing list > >> >> rspec-users@rubyforge.org > >> >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > > >> > _______________________________________________ > >> > rspec-users mailing list > >> > rspec-users@rubyforge.org > >> > http://rubyforge.org/mailman/listinfo/rspec-users > >> > > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users@rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users@rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users