Problems running features with Textmate Cucumber bundle


#1

I finally plunked down for the beta RSpec bundle and I’m working
through the initial example. Although I’m a fairly experienced RSpec
user, I’m stlll learning new tricks.

Anyway, I’m going though the mastermind example, and everything is
going well, except that I decided to also try out the Textmate bundle
for Cucumber. I decided to use Ben M.'s fork on github since it
seems to be the most evolved.

When I try to run a feature with cmd-R, instead of actually running I
see something like:

Running: cucumber
/Users/rick/mastermind/features/codebreaker_starts_game.feature
–format=html
false

Cucumber runs fine from bash.

Am I missing some setup?


Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale


#2

Rick DeNatale wrote:

see something like:

Running: cucumber
/Users/rick/mastermind/features/codebreaker_starts_game.feature --format=html
false

Cucumber runs fine from bash.

Am I missing some setup?

Hmm… that is odd. What version of Cucumber are you using? When you run
that exact command from the shell does it output the HTML report?

-Ben


#3

On Sun, Apr 26, 2009 at 11:38 PM, Ben M. removed_email_address@domain.invalid wrote:

Am I missing some setup?

Hmm… that is odd. What version of Cucumber are you using? When you run
that exact command from the shell does it output the HTML report?

I was runing 0.3.0 upgrading to 0.3.1 has the same result BUT

If I run that exact command

$ /Users/rick/mastermind/features/codebreaker_starts_game.feature
–format=html
-bash: /Users/rick/mastermind/features/codebreaker_starts_game.feature:
Permission denied

It’s trying to run the feature as an executable directly it’s not
running the cucumber executable!

Why it be doin dat?


Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale


#4

On Mon, Apr 27, 2009 at 8:13 AM, Rick DeNatale removed_email_address@domain.invalid
wrote:

seems to be the most evolved.

$ /Users/rick/mastermind/features/codebreaker_starts_game.feature --format=html
-bash: /Users/rick/mastermind/features/codebreaker_starts_game.feature:
Permission denied

It’s trying to run the feature as an executable directly it’s not
running the cucumber executable!

Why it be doin dat?

Actually, I was misreading the output in the run window, which was
wrapping.

$ cucumber
/Users/rick/mastermind/features/codebreaker_starts_game.feature
–format=html false
/Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/…/lib/cucumber/step_mother.rb:125:in
`Given’: Multiple step definitions have the same Regexp:
(Cucumber::Redundant)

features/step_definitions/mastermind.rb:13:in /^I am not yet playing$/' features/step_definitions/mastermind.rb:13:in/^I am not yet playing$/’

from
/Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/…/lib/cucumber/step_mother.rb:124:in
each' from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:124:inGiven’
from ./features/step_definitions/mastermind.rb:13
from
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inpolyglot_original_require’
from
/opt/local/lib/ruby/gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in
require' from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:79:inrequire_files’
from
/Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/…/lib/cucumber/cli/main.rb:77:in
each' from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:77:inrequire_files’
from
/Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/…/lib/cucumber/cli/main.rb:34:in
execute!' from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:20:inexecute’
from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/cucumber:6
from /opt/local/bin/cucumber:19:in `load’
from /opt/local/bin/cucumber:19

If I do this from the project directory:

$ cucumber features/codebreaker_starts_game.feature
Feature: Codebreaker starts game
As a Codebreaker
I want to start a game
So that I can break the code

Scenario: Start game #
features/codebreaker_starts_game.feature:5
Given I am not yet playing #
features/step_definitions/mastermind.rb:13
When I start a new game #
features/step_definitions/mastermind.rb:24
Then the game should say “Welcome to Mastermind!” #
features/step_definitions/mastermind.rb:28
And the game should say “Enter guess:” #
features/step_definitions/mastermind.rb:28

1 scenario
4 passed steps

Running under textmate, cucumber seems to be somehow convincing itself
that
features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/’

Duplicates itself?!?


Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale


#5

On Mon, Apr 27, 2009 at 3:47 PM, Rick DeNatale
removed_email_address@domain.invalidwrote:

going well, except that I decided to also try out the Textmate bundle

Given': Multiple step definitions have the same Regexp:Given’
from
`execute!’
Feature: Codebreaker starts game
Then the game should say “Welcome to Mastermind!” #

Duplicates itself?!?

What’s happening is that the file containing step defs is being loaded
twice, and therefore you get dupe step defs. Not sure why that’s
happening
though…

Aslak


#6

On Mon, Apr 27, 2009 at 10:07 AM, aslak hellesoy
removed_email_address@domain.invalid wrote:

I finally plunked down for the beta RSpec bundle and I’m working

-bash: /Users/rick/mastermind/features/codebreaker_starts_game.feature:
wrapping.
features/step_definitions/mastermind.rb:13:in /^I am not yet playing$/'gem_original_require’
/Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/…/lib/cucumber/cli/main.rb:77:in
from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/cucumber:6

What’s happening is that the file containing step defs is being loaded
twice, and therefore you get dupe step defs. Not sure why that’s happening
though…

Yes, I figured it was somehing like that. On a little more trial and
error, it appears that the bundle is adding false to the end of the
command string which is causing that steps def to be required
initially:

$ cucumber
/Users/rick/mastermind/features/codebreaker_starts_game.feature
–format=html false -v
Ruby files required:

  • /Users/rick/mastermind/features/support/env.rb
  • ./features/support/env.rb
  • ./lib/mastermind/game.rb
  • /Users/rick/mastermind/features/step_definitions/mastermind.rb
    /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/…/lib/cucumber/step_mother.rb:125:in
    `Given’: Multiple step definitions have the same Regexp:
    (Cucumber::Redundant)

features/step_definitions/mastermind.rb:13:in /^I am not yet playing$/' features/step_definitions/mastermind.rb:13:in/^I am not yet playing$/’

Haven’t yet figured out where that false is coming from, somewhere in
runner.rb in the bundle


Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale


#7

Rick DeNatale wrote:

Am I missing some setup?

   from

`require_files’
/Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/…/lib/cucumber/cli/main.rb:20:in
I want to start a game
And the game should say “Enter guess:” #
Duplicates itself?!?

Do you happen to be explicitly requiring any of your step definitions
from your env.rb or other files? What does your env.rb look like?

-Ben


#8

Rick DeNatale wrote:

Am I missing some setup?

   from

`require_files’
/Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/…/lib/cucumber/cli/main.rb:20:in
I want to start a game
And the game should say “Enter guess:” #
Duplicates itself?!?

features/step_definitions/mastermind.rb:13:in /^I am not yet playing$/' features/step_definitions/mastermind.rb:13:in/^I am not yet playing$/’

Haven’t yet figured out where that false is coming from, somewhere in
runner.rb in the bundle

I don’t think the ‘false’ is part of the command. That is the exit code
of the cucumber I think (well, the boolean representation of it). I’ll
take a look at it though.

-Ben


#9

On Mon, Apr 27, 2009 at 11:42 AM, Ben M. removed_email_address@domain.invalid wrote:

Do you happen to be explicitly requiring any of your step definitions from
your env.rb or other files? What does your env.rb look like?

Yes, env.rb is right out of the RSpec book B4.0 ‘printing’ p 43

$: << File.join(File.dirname(FILE), “/…/…/lib” )
require ‘spec/expectations’
require ‘mastermind’

You are right that the false is being output by running the command,
not the command line. I hacked the runner.rb file in the bundle to
insert a <br> between outputting and running the command.

The mystery is why the same command running in Textmate reloads the
spec definition, but not when invoked by bash? And when I add false
to the end of the command in bash it does.

Having just typed that I realize that I wasn’t really sure that the
reload WAS the problem running under textmate. So I hacked the run
method in runner.rb in the bundle to show stderr as well as stdout:

    in_project_dir do
      @output << %Q{Running: #{full_command = "bash \"2>&1

#{command} #{@file.rake_task} #{argv.join(’ ')}""} \n}
@output << “<br>”
@output << Kernel.system(full_command)
end

And this outputs:

Running: bash “2>&1 cucumber
/Users/rick/mastermind/features/codebreaker_starts_game.feature
–format=html”
bash: 2>&1 cucumber
/Users/rick/mastermind/features/codebreaker_starts_game.feature
–format=html: No such file or directory false

I’m guessing that the file it isn’t finding is cucumber? Is there an
environment variable I need to set in textmate?


Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale


#10

Rick DeNatale wrote:

require ‘spec/expectations’
Having just typed that I realize that I wasn’t really sure that the
And this outputs:

Ahh, I’ve had similar issues with RSpec’s bundle before. Basically,
your PATH is not being used for all of your OSX applications. From the
rspec site[1]:

You may need to adjust the PATH in your ~/.MacOSX/environment.plist file
to point to the directory
where your ruby and spec executables live. For example:

PATH
/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/opt/local/bin:/usr/local/mysql/bin

I will also add a TM_CUCUMBER_BIN constant option so if that is set it
will use that instead of assuming ‘cucumber’ is in your path. I’ll let
you know when that is done.

-Ben

1.http://rspec.info/documentation/tools/extensions/editors/textmate.html


#11

Ben M. wrote:

to the end of the command in bash it does.
end
I’m guessing that the file it isn’t finding is cucumber? Is there an
You may need to adjust the PATH in your ~/.MacOSX/environment.plist
will use that instead of assuming ‘cucumber’ is in your path. I’ll
let you know when that is done.
http://github.com/bmabey/cucumber-tmbundle/commit/8516e1c40cf6181e35d45db943de374d7516fcc1

Try updating the bundle and defining a TM_CUCUMBER_BIN in Textmate
(Textmate -> Preferences -> Advanced -> Shell Variables).

Let me know how it goes.

Thanks,
Ben