# How to debug using rspec stories

**URL:** <https://www.ruby-forum.com/t/how-to-debug-using-rspec-stories/142766>\
**Category:** Rails\
**Created:** [July 11, 2008, 6:09am UTC](https://www.ruby-forum.com/t/how-to-debug-using-rspec-stories/142766 "2008-07-11T06:09:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppjunty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/aeb1de/32.png) [@ppjunty](https://www.ruby-forum.com/u/ppjunty)\
**Post date:** [July 11, 2008, 6:09am UTC](https://www.ruby-forum.com/t/how-to-debug-using-rspec-stories/142766/1 "2008-07-11T06:09:04Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![ppjunty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/aeb1de/32.png) [@ppjunty](https://www.ruby-forum.com/u/ppjunty)\
**Post date:** [July 11, 2008, 11:45am UTC](https://www.ruby-forum.com/t/how-to-debug-using-rspec-stories/142766/2 "2008-07-11T11:45:37Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![ppjunty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/aeb1de/32.png) [@ppjunty](https://www.ruby-forum.com/u/ppjunty)\
**Post date:** [July 11, 2008, 7:52pm UTC](https://www.ruby-forum.com/t/how-to-debug-using-rspec-stories/142766/3 "2008-07-11T19:52:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ppjunty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/aeb1de/32.png) [@ppjunty](https://www.ruby-forum.com/u/ppjunty)\
**Post date:** [July 12, 2008, 1:21pm UTC](https://www.ruby-forum.com/t/how-to-debug-using-rspec-stories/142766/4 "2008-07-12T13:21:49Z")

</div>

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](http://pastie.org/221205)

---

<div class="post-metadata">

**Author:** ![ppjunty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/aeb1de/32.png) [@ppjunty](https://www.ruby-forum.com/u/ppjunty)\
**Post date:** [July 14, 2008, 4:40am UTC](https://www.ruby-forum.com/t/how-to-debug-using-rspec-stories/142766/5 "2008-07-14T04:40:46Z")

</div>

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](http://pastie.org/221205)
