Cucumber - mark a step as pending

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

http://blog.mattwynne.net

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.

Have you tried?

A plain text step with no matching step definition is pending.

Sent from my iPhone

On 9. sep… 2008, at 19.05, “David C.” [email protected]

On Tue, Sep 9, 2008 at 7:16 PM, David C. [email protected]
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

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?

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?

On 9 Sep 2008, at 18:16, David C. wrote:

I love the way I can throw a call to pending() in the top of an
my own and
http://rubyforge.org/mailman/listinfo/rspec-users


rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

cheers,
Matt

http://blog.mattwynne.net

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.

On Tue, Sep 9, 2008 at 7:52 PM, Matt W. [email protected] wrote:

@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

On Tue, Sep 9, 2008 at 12:47 PM, aslak hellesoy
[email protected] wrote:

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

It’s by design, but I’m open for suggestions. David created a similar
ticket yesterday:
Lighthouse - Beautifully Simple Issue Tracking
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?

Matt

http://blog.mattwynne.net

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.

On 9 Sep 2008, at 21:34, aslak hellesoy wrote:

end
method `pending’"
end
puzzled…

Aslak

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.

cheers,
Matt

http://blog.mattwynne.net

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.

On Tue, Sep 9, 2008 at 8:46 PM, David C. [email protected]
wrote:

I’m not crazy about this “feature”. We already have a pending
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

“aslak hellesoy” [email protected] writes:

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.

On Sep 9, 11:16 pm, Pat M. [email protected] wrote:

table over just not defining a step?

it "should know its borders url" do

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?