http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html -- Posted via http://www.ruby-forum.com/.
On Fri, Apr 10, 2009 at 8:07 PM, James Byrne <lists at ruby-forum.com> wrote:> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.htmlStrongly agreed. I''ve been watching all of the Mountain West RubyConf presentations, and came close to skipping the BDD one, thinking "I''ve been working with this stuff for a few months now, do I really need to spend time on one more Cucumber tutorial?" But as it happened, I learned quite a bit -- both in fundamental philosophy, and a few syntax tricks I''d never picked up on. Great job, Ben! -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org
Stephen Eley wrote:> On Fri, Apr 10, 2009 at 8:07 PM, James Byrne <lists at ruby-forum.com> wrote: > >> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html >> > > Strongly agreed. I''ve been watching all of the Mountain West RubyConf > presentations, and came close to skipping the BDD one, thinking "I''ve > been working with this stuff for a few months now, do I really need to > spend time on one more Cucumber tutorial?" But as it happened, I > learned quite a bit -- both in fundamental philosophy, and a few > syntax tricks I''d never picked up on. > > Great job, Ben! > >Thanks! I also recommend reading/viewing is Joesph''s presentation from SoR: http://blog.josephwilk.net/ruby/outside-in-development-with-cucumber-and-rspec.html I have been eagerly awaiting the video but I don''t think it is online yet. However, there are recorded code demos (minus the sound) in it you can watch right now. -Ben
Nice presentation Ben, very good coverage of the process in so limited time. Like Stephen I picked some syntax tips that I didn''t know. Hector On Apr 11, 12:35?am, Ben Mabey <b... at benmabey.com> wrote:> Stephen Eley wrote: > > On Fri, Apr 10, 2009 at 8:07 PM, James Byrne <li... at ruby-forum.com> wrote: > > >>http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben... > > > Strongly agreed. ?I''ve been watching all of the Mountain West RubyConf > > presentations, and came close to skipping the BDD one, thinking "I''ve > > been working with this stuff for a few months now, do I really need to > > spend time on one more Cucumber tutorial?" ?But as it happened, I > > learned quite a bit -- both in fundamental philosophy, and a few > > syntax tricks I''d never picked up on. > > > Great job, Ben! > > Thanks! > > I also recommend reading/viewing is Joesph''s presentation from SoR: > > http://blog.josephwilk.net/ruby/outside-in-development-with-cucumber-... > > I have been eagerly awaiting the video but I don''t think it is online > yet. ?However, there are recorded code demos (minus the sound) in it you > can watch right now. > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
Maybe not as clear as Ben''s http://skillsmatter.com/podcast/ajax-ria/cucumber-celerity-firewatir Aidy 2009/4/11 James Byrne <lists at ruby-forum.com>:> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 11 Apr 2009, at 01:07, James Byrne wrote:> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.htmlGreat job with the talk Ben, it''s a really good intro to Cucumber and I will be pointing anyone who asks towards it. One question about the kitten-killing. I was surprised that defining methods in your env / step_definition files adds methods to *every instance* of Object. I thought it just added those methods to the particular instance of Object that''s used to create the World. Did I misunderstand the you in the talk, or misunderstand the code in Cucumber? cheers, Matt Wynne http://beta.songkick.com http://blog.mattwynne.net
Matt Wynne wrote:> > On 11 Apr 2009, at 01:07, James Byrne wrote: > >> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html >> > > Great job with the talk Ben, it''s a really good intro to Cucumber and > I will be pointing anyone who asks towards it. > > One question about the kitten-killing. I was surprised that defining > methods in your env / step_definition files adds methods to *every > instance* of Object. I thought it just added those methods to the > particular instance of Object that''s used to create the World. > > Did I misunderstand the you in the talk, or misunderstand the code in > Cucumber? >Well, the step definitions themselves don''t add themselves to every instance. The Given, When, and Then methods have actually killed some kittens and already live on Object (sometimes it is okay). The step methods will register the passed in blocks to the StepMother-- not onto Object. So if that is what you are referring to you are correct. However, if you want to create a ruby helper method then you will need to wrap it in a module to prevent to from being added to every object instance. In my example I had something like: def login_as(user) visit ''/login'' fill_in ''Email'', :with => user.email fill_in ''Password'', :with => ''password'' click_button end If you place that method in the top-level in either your env.rb or any step files it is going to be living on Object since Cucumber will load up these files as any other ruby file. So you could call #login_as on an Array or any other object! Definitely not what we want. So, you need to wrap it in a module and use the World hook to make the helper methods available only in your World (which you get a new one for every scenario). With the new World syntax (as of 0.2.3 I believe) it would be: module UserHelpers def login_as(user) visit ''/login'' fill_in ''Email'', :with => user.email fill_in ''Password'', :with => ''password'' click_button end end World(UserHelpers) I feel like I may of just repeated what I said in the presentation... so you still may be just as confused. :/ Let me know if that helps to clarify things or what part of it is confusing. -Ben
On 12 Apr 2009, at 16:35, Ben Mabey wrote:> Matt Wynne wrote: >> >> On 11 Apr 2009, at 01:07, James Byrne wrote: >> >>> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html >> >> Great job with the talk Ben, it''s a really good intro to Cucumber >> and I will be pointing anyone who asks towards it. >> >> One question about the kitten-killing. I was surprised that >> defining methods in your env / step_definition files adds methods >> to *every instance* of Object. I thought it just added those >> methods to the particular instance of Object that''s used to create >> the World. >> >> Did I misunderstand the you in the talk, or misunderstand the code >> in Cucumber? >> > Well, the step definitions themselves don''t add themselves to every > instance. The Given, When, and Then methods have actually killed > some kittens and already live on Object (sometimes it is okay). The > step methods will register the passed in blocks to the StepMother-- > not onto Object. So if that is what you are referring to you are > correct. > > However, if you want to create a ruby helper method then you will > need to wrap it in a module to prevent to from being added to every > object instance. In my example I had something like: > > def login_as(user) > visit ''/login'' > fill_in ''Email'', :with => user.email > fill_in ''Password'', :with => ''password'' > click_button > end > > If you place that method in the top-level in either your env.rb or > any step files it is going to be living on Object since Cucumber > will load up these files as any other ruby file. So you could call > #login_as on an Array or any other object! Definitely not what we > want. So, you need to wrap it in a module and use the World hook to > make the helper methods available only in your World (which you get > a new one for every scenario). With the new World syntax (as of > 0.2.3 I believe) it would be: > > module UserHelpers > def login_as(user) > visit ''/login'' > fill_in ''Email'', :with => user.email > fill_in ''Password'', :with => ''password'' > click_button > end > end > > World(UserHelpers) > > I feel like I may of just repeated what I said in the > presentation... so you still may be just as confused. :/ Let me > know if that helps to clarify things or what part of it is confusing.Yeah you did, but I think you''ve made me realise something obvious: there''s a difference between the ruby you write in the env and step matchers, and the ruby you write *inside* the step matchers. It''s the later that gets evaluated in the context of the World instance, the former that gets evaluated in the root namespace. Right? Matt Wynne http://beta.songkick.com http://blog.mattwynne.net
Matt Wynne wrote:> > On 12 Apr 2009, at 16:35, Ben Mabey wrote: > >> Matt Wynne wrote: >>> >>> On 11 Apr 2009, at 01:07, James Byrne wrote: >>> >>>> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html >>>> >>> >>> Great job with the talk Ben, it''s a really good intro to Cucumber >>> and I will be pointing anyone who asks towards it. >>> >>> One question about the kitten-killing. I was surprised that defining >>> methods in your env / step_definition files adds methods to *every >>> instance* of Object. I thought it just added those methods to the >>> particular instance of Object that''s used to create the World. >>> >>> Did I misunderstand the you in the talk, or misunderstand the code >>> in Cucumber? >>> >> Well, the step definitions themselves don''t add themselves to every >> instance. The Given, When, and Then methods have actually killed >> some kittens and already live on Object (sometimes it is okay). The >> step methods will register the passed in blocks to the StepMother-- >> not onto Object. So if that is what you are referring to you are >> correct. >> >> However, if you want to create a ruby helper method then you will >> need to wrap it in a module to prevent to from being added to every >> object instance. In my example I had something like: >> >> def login_as(user) >> visit ''/login'' >> fill_in ''Email'', :with => user.email >> fill_in ''Password'', :with => ''password'' >> click_button >> end >> >> If you place that method in the top-level in either your env.rb or >> any step files it is going to be living on Object since Cucumber will >> load up these files as any other ruby file. So you could call >> #login_as on an Array or any other object! Definitely not what we >> want. So, you need to wrap it in a module and use the World hook to >> make the helper methods available only in your World (which you get a >> new one for every scenario). With the new World syntax (as of 0.2.3 >> I believe) it would be: >> >> module UserHelpers >> def login_as(user) >> visit ''/login'' >> fill_in ''Email'', :with => user.email >> fill_in ''Password'', :with => ''password'' >> click_button >> end >> end >> >> World(UserHelpers) >> >> I feel like I may of just repeated what I said in the presentation... >> so you still may be just as confused. :/ Let me know if that helps >> to clarify things or what part of it is confusing. > > Yeah you did, but I think you''ve made me realise something obvious: > there''s a difference between the ruby you write in the env and step > matchers, and the ruby you write *inside* the step matchers. It''s the > later that gets evaluated in the context of the World instance, the > former that gets evaluated in the root namespace. > > Right?Correct. -Ben
aslak hellesoy wrote:> > > On Sun, Apr 12, 2009 at 5:35 PM, Ben Mabey <ben at benmabey.com > <mailto:ben at benmabey.com>> wrote: > > Matt Wynne wrote: > > > On 11 Apr 2009, at 01:07, James Byrne wrote: > > http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html > > > > Great job with the talk Ben, it''s a really good intro to > Cucumber and I will be pointing anyone who asks towards it. > > One question about the kitten-killing. I was surprised that > defining methods in your env / step_definition files adds > methods to *every instance* of Object. I thought it just added > those methods to the particular instance of Object that''s used > to create the World. > > Did I misunderstand the you in the talk, or misunderstand the > code in Cucumber? > > Well, the step definitions themselves don''t add themselves to > every instance. The Given, When, and Then methods have actually > killed some kittens and already live on Object (sometimes it is > okay). The step methods will register the passed in blocks to the > StepMother-- not onto Object. So if that is what you are > referring to you are correct. > > > This isn''t exactly how it works. The Given, When, Then methods (and a > few others) are defined in the Cucumber::StepMother module. This > module is extended by the Ruby top level object, which is a single > instance. Object is not altered. Here is an interesting discussion > about it: > http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/7b023b23385241c7?pli=1Interesting.. I knew that the methods started out in Cucumber::StepMother but I thought they had to be added to every instance of Object to exhibit the behaviour that they do. That makes even more sense now-- and it is a very nice technique to know about! Thanks for clearing up that misunderstanding. -Ben> > > > > However, if you want to create a ruby helper method then you will > need to wrap it in a module to prevent to from being added to > every object instance. In my example I had something like: > > def login_as(user) > visit ''/login'' > fill_in ''Email'', :with => user.email > fill_in ''Password'', :with => ''password'' > click_button > end > > If you place that method in the top-level in either your env.rb or > any step files it is going to be living on Object since Cucumber > will load up these files as any other ruby file. So you could > call #login_as on an Array or any other object! Definitely not > what we want. So, you need to wrap it in a module and use the > World hook to make the helper methods available only in your World > (which you get a new one for every scenario). With the new World > syntax (as of 0.2.3 I believe) it would be: > > module UserHelpers > def login_as(user) > visit ''/login'' > fill_in ''Email'', :with => user.email > fill_in ''Password'', :with => ''password'' > click_button > end > end > > World(UserHelpers) > > I feel like I may of just repeated what I said in the > presentation... so you still may be just as confused. :/ Let me > know if that helps to clarify things or what part of it is confusing. > > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org <mailto: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