[rspec-users] cucumber - mark a step as pending

10 views
Skip to first unread message

Matt Wynne

unread,
Sep 9, 2008, 1:01:09 PM9/9/08
to rspec-users
I love the way I can throw a call to pending() in the top of an unfinished RSpec example and stop it from failing the build.

Is there a similar way to do such a thing with good ole' cucumber?

cheers,
Matt
----

In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine.



David Chelimsky

unread,
Sep 9, 2008, 1:05:08 PM9/9/08
to rspec-users
Have you tried?

> _______________________________________________
> rspec-users mailing list
> rspec...@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec...@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Aslak Hellesøy

unread,
Sep 9, 2008, 1:09:48 PM9/9/08
to rspec-users, rspec-users
A plain text step with no matching step definition is pending.

Sent from my iPhone

On 9. sep.. 2008, at 19.05, "David Chelimsky" <dchel...@gmail.com>
wrote:

David Chelimsky

unread,
Sep 9, 2008, 1:16:34 PM9/9/08
to rspec-users
Aslak - I think Matt is looking for this:

Given /blah/ do
pending
end

Matt - I'm pretty sure that will work - give it a shot, OK?

aslak hellesoy

unread,
Sep 9, 2008, 1:47:34 PM9/9/08
to rspec-users
On Tue, Sep 9, 2008 at 7:16 PM, David Chelimsky <dchel...@gmail.com> wrote:
> Aslak - I think Matt is looking for this:
>
> Given /blah/ do
> pending
> end
>

I'm not crazy about this "feature". We already have a pending
mechanism for steps (not defining them). What does this bring to the
table over just not defining a step?

> Matt - I'm pretty sure that will work - give it a shot, OK?
>

That won't work. It will raise a "undefined local variable or method `pending'"

Aslak

Matt Wynne

unread,
Sep 9, 2008, 1:52:06 PM9/9/08
to rspec-users
Yeah the trouble is it fails with the following error:

Spec::Example::ExamplePendingError

Which cucumber doesn't understand as anything other than a complete
fail.

Our workaround we've arrived at (thanks Aslak for pointing out the
obvious that we'd missed!) is to just write PENDING at the end of the
regex for the step matcher so it doesn't match on the step in the
feature file.

@Aslak - Interestingly, when we do this and make the Given step
pending, cuc still tries to run the When / Then steps for that
scenario. Sounds like a bug to me - should we raise a ticket on
lighthouse or did I miss something?

aslak hellesoy

unread,
Sep 9, 2008, 1:56:23 PM9/9/08
to rspec-users
On Tue, Sep 9, 2008 at 7:52 PM, Matt Wynne <ma...@mattwynne.net> wrote:
> Yeah the trouble is it fails with the following error:
>
> Spec::Example::ExamplePendingError
>
> Which cucumber doesn't understand as anything other than a complete fail.
>
> Our workaround we've arrived at (thanks Aslak for pointing out the obvious
> that we'd missed!) is to just write PENDING at the end of the regex for the
> step matcher so it doesn't match on the step in the feature file.
>
> @Aslak - Interestingly, when we do this and make the Given step pending, cuc
> still tries to run the When / Then steps for that scenario. Sounds like a
> bug to me - should we raise a ticket on lighthouse or did I miss something?
>

It's by design, but I'm open for suggestions. David created a similar
ticket yesterday:
http://rspec.lighthouseapp.com/projects/16211/tickets/8-all-steps-after-a-failure-are-listed-as-skipped#ticket-8-1

Currently, only a failure (red) will cause subsequent steps to be skipped.

Aslak

Matt Wynne

unread,
Sep 9, 2008, 2:06:48 PM9/9/08
to rspec-users
> It's by design, but I'm open for suggestions. David created a similar
> ticket yesterday:
> http://rspec.lighthouseapp.com/projects/16211/tickets/8-all-steps-
> after-a-failure-are-listed-as-skipped#ticket-8-1
>
> Currently, only a failure (red) will cause subsequent steps to be
> skipped.

In case I've missed something, would you mind elaborating on the
intent of that design? Under what circumstances would you want it to
carry on running the scenario if some of the context (Given...)
wasn't set up?

David Chelimsky

unread,
Sep 9, 2008, 2:46:28 PM9/9/08
to rspec-users
On Tue, Sep 9, 2008 at 12:47 PM, aslak hellesoy
<aslak.h...@gmail.com> wrote:
> On Tue, Sep 9, 2008 at 7:16 PM, David Chelimsky <dchel...@gmail.com> wrote:
>> Aslak - I think Matt is looking for this:
>>
>> Given /blah/ do
>> pending
>> end
>>
>
> I'm not crazy about this "feature". We already have a pending
> mechanism for steps (not defining them). What does this bring to the
> table over just not defining a step?
>
>> Matt - I'm pretty sure that will work - give it a shot, OK?
>>
>
> That won't work. It will raise a "undefined local variable or method `pending'"

I get this:

Given I am logged in as a registered member
TODO (Spec::Example::ExamplePendingError)

for this:

Given /I am logged in as a registered member/ do
pending
end

aslak hellesoy

unread,
Sep 9, 2008, 4:34:16 PM9/9/08
to rspec-users
On Tue, Sep 9, 2008 at 8:46 PM, David Chelimsky <dchel...@gmail.com> wrote:
> On Tue, Sep 9, 2008 at 12:47 PM, aslak hellesoy
> <aslak.h...@gmail.com> wrote:
>> On Tue, Sep 9, 2008 at 7:16 PM, David Chelimsky <dchel...@gmail.com> wrote:
>>> Aslak - I think Matt is looking for this:
>>>
>>> Given /blah/ do
>>> pending
>>> end
>>>
>>
>> I'm not crazy about this "feature". We already have a pending
>> mechanism for steps (not defining them). What does this bring to the
>> table over just not defining a step?
>>
>>> Matt - I'm pretty sure that will work - give it a shot, OK?
>>>
>>
>> That won't work. It will raise a "undefined local variable or method `pending'"
>
> I get this:
>
> Given I am logged in as a registered member
> TODO (Spec::Example::ExamplePendingError)
>
> for this:
>
> Given /I am logged in as a registered member/ do
> pending
> end
>

That's really odd - I don't get that if I add it to this step:
http://github.com/aslakhellesoy/cucumber/tree/master/examples/tickets/features/steps/tickets_steps.rb

And run "rake features" from examples/tickets

I haven't added any knowledge about
pending/Spec::Example::ExamplePendingError to Cucumber so I'm
puzzled...

Aslak

Matt Wynne

unread,
Sep 9, 2008, 4:46:15 PM9/9/08
to rspec-users

Doesn't work for us, either. I think David must have some funky rspec
requirey stuff going on.

We see this:

Scenario: Can see the profile page for a user who has a great amount
of details specified
Given there is a user with all conceivable attributes and
attachments
implementation of attachments for users
(Spec::Example::ExamplePendingError)
/home/nfelger/dev/skweb/vendor/plugins/rspec/lib/spec/example/
pending.rb:13:in
`pending'
./features/steps/profile_steps.rb:14:in `Given "there is a user
with all conceivable attributes and attachments"'
features/visitor/profile.feature:13:in `Given there is a user
with all conceivable attributes and attachments'


Which is what Aslak expected, I think.

Pat Maddox

unread,
Sep 10, 2008, 12:16:42 AM9/10/08
to rspec-users
"aslak hellesoy" <aslak.h...@gmail.com> writes:

> On Tue, Sep 9, 2008 at 7:16 PM, David Chelimsky <dchel...@gmail.com> wrote:
>> Aslak - I think Matt is looking for this:
>>
>> Given /blah/ do
>> pending
>> end
>>
>
> I'm not crazy about this "feature". We already have a pending
> mechanism for steps (not defining them). What does this bring to the
> table over just not defining a step?

The main reason is that you can have meaningful messages. Those are
just good in general. And I'll admit that when you're sitting down to
write a feature narrative, it may not seem to have value writing a
particular message vs seeing the default pending one...but for
maintenance it can be very helpful.

In fact, here's an example that happened to me just today (example
framework, not cucumber, but I rarely use pending ever so when I do, I
find it's because it's exceptionally handy):

describe "book" do
before(:each) do
@book = Book.new :isbn => "12345678"
end

it "should know its amazon url" do
@book.amazon_url.should == "http://amazon.com/ub/12345678"
pending "need to figure out affiliate url format"
end

it "should know its borders url" do
@book.borders_url.should == "http://search.borders.com?isbn=12345678"
pending "need to figure out affiliate url format"
end
end

Our initial story was to link to books using an affiliate code. But for
all providers other than amazon, it was tough finding the right format.
We're better off waiting a couple days until our accounts are available,
then we can look at the internal docs for 2 minutes and figure it out.
We got immediate business value today by just linking directly to these
books from within the site. And now we've got these pending statements
to remind us in a couple days when we come back to this story.

Anyway, I have a feeling I could have implemented this feature in the
time it took to write this message. But I hope it's clear that it's
something that would be valuable to some people, and harmless to the
rest.

Pat

p.s. I believe a more correct action would be to split the story into
two - the first which is to provide a UI for linking to books, and the
second which is for adding the affiliate URLs. Finish the first story,
and put the second one at the top of the queue, finishing it when the
required information becomes available. But that's another discussion.

dchel...@gmail.com

unread,
Sep 17, 2008, 11:13:02 PM9/17/08
to rspec...@rubyforge.org

On Sep 9, 11:16 pm, Pat Maddox <perg...@gmail.com> wrote:
> "aslak hellesoy" <aslak.helle...@gmail.com> writes:


> > On Tue, Sep 9, 2008 at 7:16 PM, David Chelimsky <dchelim...@gmail.com> wrote:
> >> Aslak - I think Matt is looking for this:
>
> >> Given /blah/ do
> >>  pending
> >> end
>
> > I'm not crazy about this "feature". We already have apending
> > mechanism for steps (not defining them). What does this bring to the
> > table over just not defining a step?
>
> The main reason is that you can have meaningful messages.  Those are
> just good in general.  And I'll admit that when you're sitting down to

> write afeaturenarrative, it may not seem to have value writing a
> particular message vs seeing the defaultpendingone...but for


> maintenance it can be very helpful.
>
> In fact, here's an example that happened to me just today (example

> framework, not cucumber, but I rarely usependingever so when I do, I


> find it's because it's exceptionally handy):
>
>   describe "book" do
>     before(:each) do
>       @book = Book.new :isbn => "12345678"
>     end
>
>     it "should know its amazon url" do
>       @book.amazon_url.should == "http://amazon.com/ub/12345678"
>      pending"need to figure out affiliate url format"
>     end
>
>     it "should know its borders url" do
>       @book.borders_url.should == "http://search.borders.com?isbn=12345678"
>      pending"need to figure out affiliate url format"
>     end
>   end
>
> Our initial story was to link to books using an affiliate code.  But for
> all providers other than amazon, it was tough finding the right format.
> We're better off waiting a couple days until our accounts are available,
> then we can look at the internal docs for 2 minutes and figure it out.
> We got immediate business value today by just linking directly to these
> books from within the site.  And now we've got thesependingstatements
> to remind us in a couple days when we come back to this story.

Is the idea that the steps still run but you get a TODO reminder?
That's a bit different from how we use pending in code examples.

I think that could be useful:

Then /the isbn should be (.*)/ do |isbn|
@book.borders_url.should == "http://search.borders.com?isbn=#{isbn}"
todo "need to figure out affiliate url format"
end

....
TODO:


need to figure out affiliate url format

./features/steps/books.rb:3:in `Given /the isbn should be (.*)/

As for the "pending" feature, let's say you have a new scenario with 5
new steps. As a matter of process, I'd like to see the output w/ the
snippets once, copy them all in to a ruby file, add pending to each of
them (maybe even have that already in the output) and now I'm just
working w/ code.

I think it makes the process easier.

More thoughts on that?

> Anyway, I have a feeling I could have implemented thisfeaturein the


> time it took to write this message.  But I hope it's clear that it's
> something that would be valuable to some people, and harmless to the
> rest.
>
> Pat
>
> p.s. I believe a more correct action would be to split the story into
> two - the first which is to provide a UI for linking to books, and the
> second which is for adding the affiliate URLs.  Finish the first story,
> and put the second one at the top of the queue, finishing it when the
> required information becomes available.  But that's another discussion.
> _______________________________________________
> rspec-users mailing list

> rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users

Reply all
Reply to author
Forward
0 new messages