[rspec-users] Story runner rake task

David Chelimsky dchelimsky at gmail.com
Thu Dec 20 01:16:00 EST 2007


On Dec 19, 2007 11:50 PM, James Deville <james.deville at gmail.com> wrote:
>
>
> On Dec 19, 2007, at 9:44 PM, David Chelimsky wrote:
>
> > On Dec 19, 2007 11:40 PM, James Deville <james.deville at gmail.com>
> > wrote:
> >>
> >>
> >> On Dec 19, 2007, at 9:38 PM, David Chelimsky wrote:
> >>
> >>> On Dec 19, 2007 11:34 PM, James Deville <james.deville at gmail.com>
> >>> wrote:
> >>>> Yeah, had a slight email conversation with David C about that in
> >>>> regards to bug #188. I am wondering why we don't standardize it, ya
> >>>> know convention over configuration and all.
> >>>
> >>> Because I think it's premature to call anything related to story
> >>> runner a convention. I actually organize them differently from what
> >>> many are calling convention, and my way is not necessarily "right"
> >>> or
> >>> "better." Let's wait a while on this. We'll get there.
> >>> _______________________________________________
> >>> rspec-users mailing list
> >>> rspec-users at rubyforge.org
> >>> http://rubyforge.org/mailman/listinfo/rspec-users
> >>
> >>
> >> Good enough for me. I just wanted a reason. May I ask how you set
> >> them
> >> up?
> >
> > Sure.
> >
> > stories/
> > stories/helper.rb
> > stories/steps/ (steps go in here - that seems to be the "convention")
> > stories/stuff_related_to_one_feature
> > stories/stuff_related_to_another_feature
> > stories/stuff_related_to_yet_another_feature
> >
> > So in this case, the only thing that would be consistent across
> > projects would be helper.rb and the steps directory. Even that should
> > probably be called step_definitions or something. I'm not sure.
> >
> > Anyhow - that's where I'm at. How about you?
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
>
> I've been doing a feature per file. So I have:
>
> stories/
> stories/helper.rb
> stories/steps/
> stories/stories/
>
> So in stories/stories I have my stories with multiple scenarios per
> story.
>
> I'm definitely seeing your point, and the reason for leaving it as is.
>
> Do you use selenium or anything like that via the stories? If not,
> what kinds of things do you test with stories?

I've got a bunch of selenium tests being driven by spec/ui. I haven't
converted them to stories yet.

Mostly I've been using webrat, Bryan Helmkamp's awesome
Hpricot-wrapping goodness. It doesn't cover javascript, but the apps
I've been working on have been very vanilla with respect to ajax, so
I've been satisfied with have_rjs.

Anyhow, webrat does something really cool - it ties your form
submissions to the html of the rendered form. So you make steps like
this:

=====================
When "I go to log in" do
  visits "/session/new"
end

When "I enter $label: $value" do |label, value|
  fills_in label, :with => value
end

When "I submit my credentials" do
  clicks_button
end

Then "I should see $message" do |message|
  response.should have_text(/#{message}/)
end
=====================

And a scenario like this:

=====================
When I go to log in
And I enter Username: david
And I enter Password: webrat rules
And I submit my credentials
Then I should see Welcome david
=====================

And what webrat does is grabs the html from the response in the visits
method, modifies that html with your data in the fills_in method, and
then yanks the data from the html and submits it with the
clicks_button method. What this means is that if the form isn't
aligned with the fields you're submitting, you'll get a failure.

How clean is that?


More information about the rspec-users mailing list