Bart Zonneveld
2009-Jan-14 10:12 UTC
[rspec-users] Adding a custom matcher to a controller
Hey list, I''ve written a custom matcher (http://gist.github.com/46858) which I''d like to use in Cucumber specifically. In my spec_helper, I have required the file where the matcher lives in, and added it to Spec::Runner.configure. In one of my cucumber steps, I have: response.should have_notice ("foo"). However, when I run the feature, I get the following error: undefined method `has_notice?'' for #<ActionController::CgiResponse: 0x308fc84> (NoMethodError) Note the has_notice?... Any ideas on how to add this matcher to the response? cheers, bartz
aslak hellesoy
2009-Jan-14 11:10 UTC
[rspec-users] Adding a custom matcher to a controller
On Wed, Jan 14, 2009 at 11:12 AM, Bart Zonneveld <zuperinfinite at gmail.com>wrote:> Hey list, > > I''ve written a custom matcher (http://gist.github.com/46858) which I''d > like to use in Cucumber specifically. > In my spec_helper, I have required the file where the matcher lives in, and > added it to Spec::Runner.configure. > In one of my cucumber steps, I have: response.should have_notice("foo"). > However, when I run the feature, I get the following error: > undefined method `has_notice?'' for > #<ActionController::CgiResponse:0x308fc84> (NoMethodError) > Note the has_notice?... > > Any ideas on how to add this matcher to the response? >World do |world| world.extend(Matchers) world end Documented here: http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world Aslak> > cheers, > bartz > _______________________________________________ > 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/20090114/8bc1c671/attachment.html>
Bart Zonneveld
2009-Jan-14 11:34 UTC
[rspec-users] Adding a custom matcher to a controller
On 14-jan-2009, at 12:10, aslak hellesoy wrote:> On Wed, Jan 14, 2009 at 11:12 AM, Bart Zonneveld > <zuperinfinite at gmail.com> wrote: >> Hey list, >> >> I''ve written a custom matcher (http://gist.github.com/46858) which >> I''d like to use in Cucumber specifically. >> In my spec_helper, I have required the file where the matcher >> lives in, and added it to Spec::Runner.configure. >> In one of my cucumber steps, I have: response.should have_notice >> ("foo"). >> However, when I run the feature, I get the following error: >> undefined method `has_notice?'' for #<ActionController::CgiResponse: >> 0x308fc84> (NoMethodError) >> Note the has_notice?... >> >> Any ideas on how to add this matcher to the response? > > World do |world| > world.extend(Matchers) > world > endThanks, now my matcher did get included. However, I''m trying to use have_tag (as in http://gist.github.com/46868), and I get this error: undefined method `have_tag'' for #<Matchers::HaveNotice:0x2e4a5c8> (NoMethodError) Any ideas on how to make have_tag available in my custom matcher? thanks, bartz> Documented here: > > http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-worldNot particularly useful in this case, but if I have some spare time today, I''ll try to update the docs.
David Chelimsky
2009-Jan-14 15:43 UTC
[rspec-users] Adding a custom matcher to a controller
On Wed, Jan 14, 2009 at 5:34 AM, Bart Zonneveld <zuperinfinite at gmail.com> wrote:> > On 14-jan-2009, at 12:10, aslak hellesoy wrote: > >> On Wed, Jan 14, 2009 at 11:12 AM, Bart Zonneveld <zuperinfinite at gmail.com> >> wrote: >>> >>> Hey list, >>> >>> I''ve written a custom matcher (http://gist.github.com/46858) which I''d >>> like to use in Cucumber specifically. >>> In my spec_helper, I have required the file where the matcher lives in, >>> and added it to Spec::Runner.configure. >>> In one of my cucumber steps, I have: response.should have_notice("foo"). >>> However, when I run the feature, I get the following error: >>> undefined method `has_notice?'' for >>> #<ActionController::CgiResponse:0x308fc84> (NoMethodError) >>> Note the has_notice?... >>> >>> Any ideas on how to add this matcher to the response? >> >> World do |world| >> world.extend(Matchers) >> world >> end > > Thanks, now my matcher did get included. However, I''m trying to use have_tag > (as in http://gist.github.com/46868), and I get this error: > undefined method `have_tag'' for #<Matchers::HaveNotice:0x2e4a5c8> > (NoMethodError) > Any ideas on how to make have_tag available in my custom matcher?Gotta include the rspec-rails matchers as well (or webrat if you''re using those).> > thanks, > bartz > >> Documented here: >> >> http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world > > Not particularly useful in this case, but if I have some spare time today, > I''ll try to update the docs. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Bart Zonneveld
2009-Jan-14 21:47 UTC
[rspec-users] Adding a custom matcher to a controller
On 14 jan 2009, at 16:43, David Chelimsky wrote:> On Wed, Jan 14, 2009 at 5:34 AM, Bart Zonneveld <zuperinfinite at gmail.com > > wrote: >> >> On 14-jan-2009, at 12:10, aslak hellesoy wrote: >> >>> On Wed, Jan 14, 2009 at 11:12 AM, Bart Zonneveld <zuperinfinite at gmail.com >>> > >>> wrote: >>>> >>>> Hey list, >>>> >>>> I''ve written a custom matcher (http://gist.github.com/46858) >>>> which I''d >>>> like to use in Cucumber specifically. >>>> In my spec_helper, I have required the file where the matcher >>>> lives in, >>>> and added it to Spec::Runner.configure. >>>> In one of my cucumber steps, I have: response.should >>>> have_notice("foo"). >>>> However, when I run the feature, I get the following error: >>>> undefined method `has_notice?'' for >>>> #<ActionController::CgiResponse:0x308fc84> (NoMethodError) >>>> Note the has_notice?... >>>> >>>> Any ideas on how to add this matcher to the response? >>> >>> World do |world| >>> world.extend(Matchers) >>> world >>> end >> >> Thanks, now my matcher did get included. However, I''m trying to use >> have_tag >> (as in http://gist.github.com/46868), and I get this error: >> undefined method `have_tag'' for #<Matchers::HaveNotice:0x2e4a5c8> >> (NoMethodError) >> Any ideas on how to make have_tag available in my custom matcher? > > Gotta include the rspec-rails matchers as well (or webrat if you''re > using those).Uhm, yeah, but how? :) I''ve included this in spec_helper, so I thought the webrat/rspec-rails matchers were included automatically... thanks, bartz
David Chelimsky
2009-Jan-14 22:20 UTC
[rspec-users] Adding a custom matcher to a controller
On Wed, Jan 14, 2009 at 3:47 PM, Bart Zonneveld <zuperinfinite at gmail.com> wrote:> > On 14 jan 2009, at 16:43, David Chelimsky wrote: > >> On Wed, Jan 14, 2009 at 5:34 AM, Bart Zonneveld <zuperinfinite at gmail.com> >> wrote: >>> >>> On 14-jan-2009, at 12:10, aslak hellesoy wrote: >>> >>>> On Wed, Jan 14, 2009 at 11:12 AM, Bart Zonneveld >>>> <zuperinfinite at gmail.com> >>>> wrote: >>>>> >>>>> Hey list, >>>>> >>>>> I''ve written a custom matcher (http://gist.github.com/46858) which I''d >>>>> like to use in Cucumber specifically. >>>>> In my spec_helper, I have required the file where the matcher lives in, >>>>> and added it to Spec::Runner.configure. >>>>> In one of my cucumber steps, I have: response.should >>>>> have_notice("foo"). >>>>> However, when I run the feature, I get the following error: >>>>> undefined method `has_notice?'' for >>>>> #<ActionController::CgiResponse:0x308fc84> (NoMethodError) >>>>> Note the has_notice?... >>>>> >>>>> Any ideas on how to add this matcher to the response? >>>> >>>> World do |world| >>>> world.extend(Matchers) >>>> world >>>> end >>> >>> Thanks, now my matcher did get included. However, I''m trying to use >>> have_tag >>> (as in http://gist.github.com/46868), and I get this error: >>> undefined method `have_tag'' for #<Matchers::HaveNotice:0x2e4a5c8> >>> (NoMethodError) >>> Any ideas on how to make have_tag available in my custom matcher? >> >> Gotta include the rspec-rails matchers as well (or webrat if you''re >> using those). > > Uhm, yeah, but how? :) > I''ve included this in spec_helper, so I thought the webrat/rspec-rails > matchers were included automatically...Ah - I see the problem. They are, but outside the scope of the custom matcher. Here''s how I''ve gotten around this: http://gist.github.com/47126 - don''t know if that''ll work as/is, but it should give you the idea, which is to provide access to the scope in which have_tag is defined and call it on that scope. HTH, David> > thanks, > bartz > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >