Forum: RSpec Cucumber - Recommended viewing.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
James B. (Guest)
on 2009-04-11 04:07
Stephen E. (Guest)
on 2009-04-11 07:11
(Received via mailing list)
On Fri, Apr 10, 2009 at 8:07 PM, James B. <removed_email_address@domain.invalid>
wrote:
> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bd...

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!


--
Have Fun,
   Steve E. (removed_email_address@domain.invalid)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org
Ben M. (Guest)
on 2009-04-11 09:38
(Received via mailing list)
Stephen E. wrote:
> 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-develop...

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
Hector G. (Guest)
on 2009-04-12 01:00
(Received via mailing list)
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
aidy lewis (Guest)
on 2009-04-12 01:51
(Received via mailing list)
Maybe not as clear as Ben's

http://skillsmatter.com/podcast/ajax-ria/cucumber-...

Aidy

2009/4/11 James B. <removed_email_address@domain.invalid>:
Matt W. (Guest)
on 2009-04-12 16:43
(Received via mailing list)
On 11 Apr 2009, at 01:07, James B. wrote:

> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bd...

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?

cheers,
Matt W.
http://beta.songkick.com
http://blog.mattwynne.net
Ben M. (Guest)
on 2009-04-12 19:37
(Received via mailing list)
Matt W. wrote:
> 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
Matt W. (Guest)
on 2009-04-12 20:16
(Received via mailing list)
On 12 Apr 2009, at 16:35, Ben M. wrote:

>> defining methods in your env / step_definition files adds methods
> step methods will register the passed in blocks to the StepMother--
> fill_in 'Password', :with => 'password'
> 0.2.3 I believe) it would be:
> 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 W.
http://beta.songkick.com
http://blog.mattwynne.net
Ben M. (Guest)
on 2009-04-13 02:22
(Received via mailing list)
Matt W. wrote:
>>> Great job with the talk Ben, it's a really good intro to Cucumber
>> Well, the step definitions themselves don't add themselves to every
>> def login_as(user)
>> want.  So, you need to wrap it in a module and use the World hook to
>> end
> 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 H. (Guest)
on 2009-04-13 09:58
(Received via mailing list)
On Sun, Apr 12, 2009 at 5:35 PM, Ben M. <removed_email_address@domain.invalid> 
wrote:

>> will be pointing anyone who asks towards it.
> 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/brow...
Ben M. (Guest)
on 2009-04-13 10:36
(Received via mailing list)
aslak hellesoy wrote:
> 
http://mwrc2009.confreaks.com/14-mar-2009-15-00-bd...
>         to create the World.
>
>
> 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/brow...

Interesting.. 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
This topic is locked and can not be replied to.