Hi I am having an issue with Cucumber where I am writing in one files some steps where rspec matcher do not seem to be accessible. So I have a file with my steps written like this require ''steputils'' Given "some step description 1 " do SomeClass.post(args) end Given "some step description 2 that is slighty different for better readability " do SomeClass.post(args) end and in steputils I have class Steputils def self.post(args) args.should_not be_empty end end But the code breaks when trying to run args.should_not be_empty that are valid rspec matchers.. Seems like it is not recognizing it. I tried to include Cucumber and Spec as part of my class but still not working. Any idea what I need to do to make it work? This will help refactoring some of the steps that may have similar code Also, is there a way to see all the existing step using the cucumber methods? because when you have a lot it would be nice to have a way to describe them for documentation purpose (like Rake does for task) Thanks Emmanuel
On Fri, Jan 2, 2009 at 7:20 PM, Emmanuel Pinault <seatmanu at gmail.com> wrote:> Hi > > I am having an issue with Cucumber where I am writing in one files some > steps where rspec matcher do not seem to be accessible. > > So I have a file with my steps written like this > > require ''steputils'' > > Given "some step description 1 " do > SomeClass.post(args) > end > > Given "some step description 2 that is slighty different for better > readability " do > SomeClass.post(args) > end > > > and in steputils I have > > class Steputils > > def self.post(args) > args.should_not be_empty > end > end > > > But the code breaks when trying to run args.should_not be_empty that are > valid rspec matchers.. Seems like it is not recognizing it. I tried to > include Cucumber and Spec as part of my classPlease post the full error message and backtrace. Did you require ''spec'' in your support/env.rb file? Aslak> > but still not working. Any idea what I need to do to make it work? This > will help refactoring some of the steps that may have similar code > > Also, is there a way to see all the existing step using the cucumber > methods? because when you have a lot it would be nice to have a way to > describe them for documentation purpose (like Rake does for task) > > Thanks > > Emmanuel > > > > > > _______________________________________________ > 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/20090102/0ebdf758/attachment.html>
On Fri, Jan 2, 2009 at 1:20 PM, Emmanuel Pinault <seatmanu at gmail.com> wrote:> So I have a file with my steps written like this > > require ''steputils'' > > Given "some step description 1 " do > SomeClass.post(args) > end > > Given "some step description 2 that is slighty different for better > readability " do > SomeClass.post(args) > end > > > and in steputils I have > > class Steputils > > def self.post(args) > args.should_not be_empty > end > endIs that code right? It looks to me like Steputils.post is never getting called. You''re calling SomeClass.post instead. Peter
I think I found a solution to my problem. in the Steputils class, instead of including, I perform an extend on Spec::Matcher so my class look like> > class Steputils >extend Spec::Matchers> def self.post(args) > args.should_not be_empty > end > endNow all the Matcher are visible in my class and tests are running fine again Thanks Emmanuel On Jan 2, 2009, at 10:34 AM, aslak hellesoy wrote:> > > On Fri, Jan 2, 2009 at 7:20 PM, Emmanuel Pinault > <seatmanu at gmail.com> wrote: > Hi > > I am having an issue with Cucumber where I am writing in one files > some steps where rspec matcher do not seem to be accessible. > > So I have a file with my steps written like this > > require ''steputils'' > > Given "some step description 1 " do > SomeClass.post(args) > end > > Given "some step description 2 that is slighty different for better > readability " do > SomeClass.post(args) > end > > > and in steputils I have > > class Steputils > > def self.post(args) > args.should_not be_empty > end > end > > > But the code breaks when trying to run args.should_not be_empty that > are valid rspec matchers.. Seems like it is not recognizing it. I > tried to include Cucumber and Spec as part of my class > > Please post the full error message and backtrace. > > Did you require ''spec'' in your support/env.rb file? > > Aslak > > > but still not working. Any idea what I need to do to make it work? > This will help refactoring some of the steps that may have similar > code > > Also, is there a way to see all the existing step using the cucumber > methods? because when you have a lot it would be nice to have a way > to describe them for documentation purpose (like Rake does for task) > > Thanks > > Emmanuel > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > 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/20090102/908b6002/attachment-0001.html>
Sorry, I made up the example to explain my problem but yes, it should be Steputils. post in each of the steps. But the problem was calling a spec matcher within that class. My solution to get it i to work is to extend my class with Spec::Matcher Thanks Emmanuel On Jan 2, 2009, at 10:45 AM, Peter Jaros wrote:> On Fri, Jan 2, 2009 at 1:20 PM, Emmanuel Pinault > <seatmanu at gmail.com> wrote: > >> So I have a file with my steps written like this >> >> require ''steputils'' >> >> Given "some step description 1 " do >> SomeClass.post(args) >> end >> >> Given "some step description 2 that is slighty different for better >> readability " do >> SomeClass.post(args) >> end >> >> >> and in steputils I have >> >> class Steputils >> >> def self.post(args) >> args.should_not be_empty >> end >> end > > Is that code right? It looks to me like Steputils.post is never > getting called. You''re calling SomeClass.post instead. > > Peter > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
Hi Aslak, 2009/1/2 aslak hellesoy <aslak.hellesoy at gmail.com>:> Did you require ''spec'' in your support/env.rb file?Is it now a standard to put the env.rb in the ''support'' folder? Mine is in the ''steps'' folder? Regards Aidy
On Fri, Jan 2, 2009 at 2:04 PM, aidy lewis <aidy.lewis at googlemail.com> wrote:> Hi Aslak, > > 2009/1/2 aslak hellesoy <aslak.hellesoy at gmail.com>: > >> Did you require ''spec'' in your support/env.rb file? > > Is it now a standard to put the env.rb in the ''support'' folder? Mine > is in the ''steps'' folder?That''s the direction, yes. features/step_definitions #for step definitions features/support #for everything else> > Regards > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Fri, Jan 2, 2009 at 9:11 PM, David Chelimsky <dchelimsky at gmail.com>wrote:> On Fri, Jan 2, 2009 at 2:04 PM, aidy lewis <aidy.lewis at googlemail.com> > wrote: > > Hi Aslak, > > > > 2009/1/2 aslak hellesoy <aslak.hellesoy at gmail.com>: > > > >> Did you require ''spec'' in your support/env.rb file? > > > > Is it now a standard to put the env.rb in the ''support'' folder? Mine > > is in the ''steps'' folder? >You can keep it wherever you want, but a recent new feature is that ruby files in the support dir get loaded before any other dir. This is needed in some cases. See History.txt on GitHub.> > That''s the direction, yes. > > features/step_definitions #for step definitions > features/support #for everything else > > > > > > > Regards > > > > Aidy > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > 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/20090102/86b2492f/attachment.html>