Skip to content
This repository

Cucumber's step function has a namespace collision with pry-nav #285

Closed
daveroberts opened this Issue May 24, 2012 · 6 comments

2 participants

Dave Roberts Matt Wynne
Dave Roberts

If I put a binding.pry in a cucumber step definition, it allows me to manually run steps from the interactive debugger. I find this very helpful.

If I install the pry-nav gem, I can no-longer run "step" from this context as it will trigger, pry-nav's step function.

Can the cucumber step function be renamed (not aliased) to not cause a collision?

Matt Wynne
Owner

Are you suggesting we rename Cucumber's #step method for all users, or are you asking whether it's possible to do some meta-programming magic to rename it in your specific use case?

For your specific case, you could try calling this instead to invoke Cucumber's #step method:

@__cucumber_step_mother.invoke(name)

That obviously isn't guaranteed to work in the future.

See https://github.com/cucumber/cucumber/blob/master/lib/cucumber/rb_support/rb_world.rb#L30 for details.

Dave Roberts

Both the pry project and cucumber are very highly used. It's not usual that other people will run into this problem. I would recommend changing the step method name in Cucumber, as the current behavior causes an infinite loop when calling step that crashes the system.

Matt Wynne
Owner

I think we'd only be able to do that on a major release - lots of people's code depends on the #step method.

Can you think of another work-around? Is it worth bringing this up with the pry people to see if they have any ideas?

Dave Roberts

I've brought it up with the pry team via this issue: nixme/pry-nav#14

I happen to use the step function of pry manually more often than the step function of Cucumber, simply because when debugging cucumber code using pry, I'd like to be able to step. This is probably the behavior of other developers who use both projects.

Keep in mind that cucumber runs fine using step during normal execution, it's only when binding.pry is placed that there exists a problem.

This problem of namespace collision isn't unique to pry and cucumber, and it's a bigger problem that the Ruby community needs to solve as a whole, but perhaps a good band-aid would be to create a function called cucumber_step, and have step call cucumber step, and have a parameter passed to Cucumber somehow to optionally not define the step function. For users who don't pass the option, Cucumber operates the same way. Otherwise, step wouldn't be defined and there would be no collision.

Matt Wynne
Owner

It seems from the pry ticket like this is resolved by features in pry-nav. Please do re-open this ticket if you think there's something else we should do in Cucumber, and thanks for letting us know about this clash.

Matt Wynne mattwynne closed this June 04, 2012
Dave Roberts

Thanks. I'm sorry I can't recreate the issue for you. It's difficult because I use Rails at work, and can't share my source code. If I am able to reproduce it in a smaller environment I'll let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.