How to debug using rspec stories

Hello. I just started to use rspec stories. I followed the following
tutorial:

http://www.tomtenthij.co.uk/2008/1/25/rspec-plain-text-story-runner-on-a-fresh-rails-app

So I implemented my story and some of the steps are:

(…)
When “user creates a product” do
post “products/new”, :name => @name
end

Then “there should be a product named ‘$name’” do |name|
Product.find_by_name(name).should_not be_nil
end

When I run the story i get:
(…)
When user creates a product
Then there should be a product named ‘Book’ (PENDING)
1 scenarios: 0 succeeded, 0 failed, 1 pending
Pending Steps:

  1. Creating a product (success): there should be a product named ‘Book’

The problem is that there is no message for why the step is pending,
so how can i know how to fix that? I included “require ‘ruby-debug’” in
my helper.rb, but it didn’t help. Any ideas? Thanks.

PP Junty wrote:

Hello. I just started to use rspec stories. I followed the following
tutorial:

http://www.tomtenthij.co.uk/2008/1/25/rspec-plain-text-story-runner-on-a-fresh-rails-app

So I implemented my story and some of the steps are:

(…)
When “user creates a product” do
post “products/new”, :name => @name
end

Then “there should be a product named ‘$name’” do |name|
Product.find_by_name(name).should_not be_nil
end

When I run the story i get:
(…)
When user creates a product
Then there should be a product named ‘Book’ (PENDING)
1 scenarios: 0 succeeded, 0 failed, 1 pending
Pending Steps:

  1. Creating a product (success): there should be a product named ‘Book’

The problem is that there is no message for why the step is pending,
so how can i know how to fix that? I included “require ‘ruby-debug’” in
my helper.rb, but it didn’t help. Any ideas? Thanks.

Have you tried removing the 's?

Then “there should be a product named $name” do |name|

Then there should be a product named Book

thanks for your reply, Matthew. i tried and the
result is the same. the tutorial even refers to
that: “It is good practice to put quotes around
your values so that there are less cases where
the regexp matcher will get confused and split
things up in a way you did not expect.”

i tried to manually debug the calls and apparently
the command

post “products/new”, :name => @name

is not invoking the controller’s method, but i can’t
say why. i even tried post_via_redirect, but it
didn’t help either.

PP Junty wrote:

thanks for your reply, Matthew. i tried and the
result is the same. the tutorial even refers to
that: “It is good practice to put quotes around
your values so that there are less cases where
the regexp matcher will get confused and split
things up in a way you did not expect.”

i tried to manually debug the calls and apparently
the command

post “products/new”, :name => @name

is not invoking the controller’s method, but i can’t
say why. i even tried post_via_redirect, but it
didn’t help either.

what about importing the same steps into a ruby defined story…

eg.

When “blahblahblahblah”
And “blahblahblah”
Then “blahblahblah”

I mean…
the fact that it was raising a “not implemented”
implies that it’s too do with the parsing,
it’s nothing to do with the content of the step…

here’s an example I made earlier of a story.rb rather than a
story.plaintext
http://pastie.org/221205

you are totally right, Matthew, i had a parsing
problem and was missing the point of “pending”.
thanks for your help.

When “blahblahblahblah”
And “blahblahblah”
Then “blahblahblah”

I mean…
the fact that it was raising a “not implemented”
implies that it’s too do with the parsing,
it’s nothing to do with the content of the step…

here’s an example I made earlier of a story.rb rather than a
story.plaintext
http://pastie.org/221205