Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cucumber claims its support files are broken?

Using cucumber for ruby on rails, I ran a test that failed for a silly reason (I'd made a typo). I fixed the problem, and suddenly, Cucumber won't run anymore. I didn't change any of the files it refers to:

/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/js_support/js_dsl.js:3: 
syntax error, unexpected '{', expecting keyword_then or ';' or '\n'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/js_support/js_dsl.js:6: syntax error, unexpected keyword_else, expecting '}'
    else {
        ^
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/js_support/js_dsl.js:7: syntax error, unexpected ';', expecting tASSOC
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-

1.1.8/lib/cucumber/js_support/js_dsl.js:13: syntax error, unexpected ',', expecting $end (SyntaxError)
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `block in load'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:225:in `load_dependency'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/js_support/js_language.rb:114:in `initialize'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/runtime/support_code.rb:74:in `new'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/runtime/support_code.rb:74:in `load_programming_language'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/runtime/support_code.rb:185:in `programming_language_for'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/runtime/support_code.rb:169:in `load_file'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/runtime/support_code.rb:82:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/runtime.rb:175:in `load_step_definitions'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/runtime.rb:40:in `run!'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/cli/main.rb:43:in `execute!'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/lib/cucumber/cli/main.rb:20:in `execute'
/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-1.1.8/bin/cucumber:14:in `<top (required)>'
/usr/local/bin/cucumber:19:in `load'
/usr/local/bin/cucumber:19:in `<main>'

Obviously something has gone terribly terribly wrong. My question is simply, how do I go about fixing this? Is this a known bug? Can/should I re-install cucumber? The whole stack? I have very little experience with Rails and Cucumber, and the obvious solutions are failing me (the file it complains about is fine, actually fairly readable, nothing odd about it; running it again reveals it wasn't just a fluke; breaking the feature I fixed changes nothing).

Lines 3-7 of js_dsl are:

 if (func == null) {
      jsLanguage.execute_step_definition(regexp);
    }
    else {
      jsLanguage.add_step_definition(regexp, func);
    }
  },

So I checked the step definition file and that also looks fine. Usually a step definition being wrong gives an error message, not a complete failure like this.

like image 434
Yamikuronue Avatar asked Mar 25 '12 19:03

Yamikuronue


People also ask

Why are my Cucumber tests cases getting skipped?

Cucumber skips all steps after a failed step by design. Once a step has failed, the test has failed and there should be no reason to perform the next steps. If you have a need to run the additional steps, likely your scenario is testing too many different things at once.

What is glue file in Cucumber?

The glue is a part of Cucumber options that describes the location and path of the step definition file.

How do you fix step defined detection works when the project is configured as Cucumber project?

This issue will be resolved if you convert the project as a cucumber project. Right-click on your project from the Project Explorer > Configure > Convert as Cucumber Project.


3 Answers

I don't even...

My classmates discovered the problem here and the solution here

Apparently something called "theRubyRacer" which was part of the image I was told to use is now "obsolete", which apparently means "breaks cucumber despite it working fine ten minutes ago". Somehow, "simplecov" is involved, meaning I now have no idea how I'm supposed to get the coverage figures required for the assignment but I don't care anymore because I'm frusturated and confused and it works now. This just started today, so I'm thinking something somewhere contacted a server someplace that told it the gem was obsolete and thus refused to use it?

If anyone has further information, please do let me know.


Since apparently those links are walled off, the problem was:

So I have identified the problem:

The coverage folder.

I can run and pass my cucumber and rspec tests without any sort of problem if I don't put require 'simplecov' SimpleCov.start 'rails' in the top of env.rb.

All my steps are green, but If I add these two lines, I got the error above. If I delete de /coverage folder, I can run once the test, but the next time the error is reproduced again.

Any help please?

and then the solution mentioned was

Comment this line out of Gemfile and run bundle install again:

# gem 'therubyracer'

This is now obsolete. See:

http://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar#therubyracer

Which says:

If you were previously using therubyracer or therubyracer-heroku, these gems are no longer required and strongly discouraged as these gems use a very large amount of memory.

like image 84
Yamikuronue Avatar answered Oct 25 '22 04:10

Yamikuronue


For clarity: bec == bundle exec cucumber

It forces the exec'd directive to use the gems as specified in Gemfile.lock

These two work: bec && bec features/foo.feature

This one doesn't, complaining about syntax errors in js_dsl.js: bec foo.feature

cucumber-1.1.9 (and very likely other versions too) assumes features/

like image 29
paul.belt Avatar answered Oct 25 '22 03:10

paul.belt


I was getting the same syntax error from the same bit of correctly syntaxed javascript.

It might seem completely unrelated, but if you have

Feature: xyz

  @some-tag
  Scenario Outline
  When I "<foo>"

  @some-tag # TRY REMOVING THIS LINE
  Examples: 
  |foo|
  |bar|

then it caused that error in my case. Try removing the second tag. Tags are for scenarios.

like image 34
user1158559 Avatar answered Oct 25 '22 02:10

user1158559