cavalle / steak

DISCONTINUED - The delicious combination of RSpec and Capybara for Acceptance BDD
MIT License
763 stars 32 forks source link

Steak Breaks Cucumber #19

Closed bbhoss closed 13 years ago

bbhoss commented 13 years ago

I am trying to migrate over to Steak from my Cucumber tests, so I want to be able to run them together. The only problem is, whenever I add Steak to my gemfile, when I try to run Cucumber I get this error:

features/widget_association.feature: Parse error at :6. Found scenario when expecting one of: comment, feature, tag. (Current state: root). (Gherkin::Parser::ParseError)
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/gherkin-2.2.8/lib/gherkin/parser/parser.rb:57:in `block in event'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/gherkin-2.2.8/lib/gherkin/parser/parser.rb:99:in `event'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/gherkin-2.2.8/lib/gherkin/parser/parser.rb:55:in `event'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/gherkin-2.2.8/lib/gherkin/parser/parser.rb:105:in `event'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/gherkin-2.2.8/lib/gherkin/parser/parser.rb:55:in `event'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/gherkin-2.2.8/lib/gherkin/parser/parser.rb:45:in `method_missing'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/gherkin-2.2.8/lib/gherkin/lexer/i18n_lexer.rb:23:in `scan'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/gherkin-2.2.8/lib/gherkin/lexer/i18n_lexer.rb:23:in `scan'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/gherkin-2.2.8/lib/gherkin/parser/parser.rb:31:in `parse'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/cucumber-0.9.2/lib/cucumber/feature_file.rb:35:in `parse'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/cucumber-0.9.2/lib/cucumber/runtime/features_loader.rb:28:in `block in load'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/cucumber-0.9.2/lib/cucumber/runtime/features_loader.rb:26:in `each'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/cucumber-0.9.2/lib/cucumber/runtime/features_loader.rb:26:in `load'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/cucumber-0.9.2/lib/cucumber/runtime/features_loader.rb:14:in `features'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/cucumber-0.9.2/lib/cucumber/runtime.rb:180:in `features'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/cucumber-0.9.2/lib/cucumber/runtime.rb:32:in `run!'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/cucumber-0.9.2/lib/cucumber/cli/main.rb:54:in `execute!'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/cucumber-0.9.2/lib/cucumber/cli/main.rb:29:in `execute'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/gems/cucumber-0.9.2/bin/cucumber:8:in `<top (required)>'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/bin/cucumber:19:in `load'
/Users/bbhoss/.rvm/gems/ruby-1.9.2-p0@widgetmaker3/bin/cucumber:19:in `<main>'

The file syntax is fine, and removing the steak gem from my gemfile makes it work fine. Steak works fine when it is in the Gemfile, while cucumber is the one who has issues. Any ideas why this might be? Does Steak step on Cucumber's toes somewhere?

cavalle commented 13 years ago

Sounds weird. Could you specify which versions of steak, rspec, cucumber, rails... are you using and how you're running your features (rake task, cucumber command...)?

bbhoss commented 13 years ago

Sure, will update this tomorrow, the trouble is on my work computer but it seems to be happening everywhere. I have also found some list posts about it.

cavalle commented 13 years ago

Is this happening for every feature or only some of them?

bbhoss commented 13 years ago

Every one of them. It hits the first one and dies, if I specify a feature manually, it still dies.

bbhoss commented 13 years ago

Here is my Gemfile.lock:

GIT
  remote: http://github.com/alan/rack-test.git
  revision: 8ae89a2
  specs:
    rack-test (0.5.4)
      rack (>= 1.0)

GIT
  remote: http://github.com/mongoid/mongoid.git
  revision: b1080cd
  specs:
    mongoid (2.0.0.beta.19)
      activemodel (~> 3.0)
      mongo (~> 1.1)
      tzinfo (~> 0.3.22)
      will_paginate (~> 3.0.pre)

GIT
  remote: http://github.com/plataformatec/devise.git
  revision: 8539f5f
  specs:
    devise (1.2.rc)
      bcrypt-ruby (~> 2.1.2)
      orm_adapter (~> 0.0.2)
      warden (~> 1.0.0)

GIT
  remote: http://github.com/yelvert/carrierwave.git
  revision: d221d39
  specs:
    carrierwave (0.5.0.beta2)
      activesupport (>= 3.0.0)

GEM
  remote: http://rubygems.org/
  specs:
    abstract (1.0.0)
    actionmailer (3.0.0)
      actionpack (= 3.0.0)
      mail (~> 2.2.5)
    actionpack (3.0.0)
      activemodel (= 3.0.0)
      activesupport (= 3.0.0)
      builder (~> 2.1.2)
      erubis (~> 2.6.6)
      i18n (~> 0.4.1)
      rack (~> 1.2.1)
      rack-mount (~> 0.6.12)
      rack-test (~> 0.5.4)
      tzinfo (~> 0.3.23)
    activemodel (3.0.0)
      activesupport (= 3.0.0)
      builder (~> 2.1.2)
      i18n (~> 0.4.1)
    activerecord (3.0.0)
      activemodel (= 3.0.0)
      activesupport (= 3.0.0)
      arel (~> 1.0.0)
      tzinfo (~> 0.3.23)
    activeresource (3.0.0)
      activemodel (= 3.0.0)
      activesupport (= 3.0.0)
    activesupport (3.0.0)
    archive-tar-minitar (0.5.2)
    arel (1.0.1)
      activesupport (~> 3.0.0)
    autotest (4.4.1)
    autotest-growl (0.2.6)
    bcrypt-ruby (2.1.2)
    bson (1.1)
    bson_ext (1.1)
    builder (2.1.2)
    cancan (1.4.0)
    capybara (0.3.9)
      culerity (>= 0.2.4)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (>= 0.0.3)
    childprocess (0.0.7)
      ffi (~> 0.6.3)
    columnize (0.3.1)
    configuration (1.1.0)
    cucumber (0.9.2)
      builder (~> 2.1.2)
      diff-lcs (~> 1.1.2)
      gherkin (~> 2.2.5)
      json (~> 1.4.6)
      term-ansicolor (~> 1.0.5)
    cucumber-rails (0.3.2)
      cucumber (>= 0.8.0)
    culerity (0.2.12)
    database_cleaner (0.5.2)
    diff-lcs (1.1.2)
    erubis (2.6.6)
      abstract (>= 1.0.0)
    fabrication (0.9.0)
    ffi (0.6.3)
      rake (>= 0.8.7)
    gherkin (2.2.8)
      json (~> 1.4.6)
      term-ansicolor (~> 1.0.5)
    haml (3.0.21)
    i18n (0.4.1)
    json (1.4.6)
    json_pure (1.4.6)
    launchy (0.3.7)
      configuration (>= 0.0.5)
      rake (>= 0.8.1)
    linecache19 (0.5.11)
      ruby_core_source (>= 0.1.4)
    luhnacy (0.2.0)
    mail (2.2.7)
      activesupport (>= 2.3.6)
      mime-types
      treetop (>= 1.4.5)
    mime-types (1.16)
    mongo (1.1)
      bson (>= 1.0.5)
    nokogiri (1.4.3.1)
    orm_adapter (0.0.3)
    pg (0.9.0)
    polyglot (0.3.1)
    prawn (0.8.4)
      prawn-core (>= 0.8.4, < 0.9)
      prawn-layout (>= 0.8.4, < 0.9)
      prawn-security (>= 0.8.4, < 0.9)
    prawn-core (0.8.4)
    prawn-layout (0.8.4)
    prawn-security (0.8.4)
    rack (1.2.1)
    rack-mount (0.6.13)
      rack (>= 1.0.0)
    rails (3.0.0)
      actionmailer (= 3.0.0)
      actionpack (= 3.0.0)
      activerecord (= 3.0.0)
      activeresource (= 3.0.0)
      activesupport (= 3.0.0)
      bundler (~> 1.0.0)
      railties (= 3.0.0)
    rails3-jquery-autocomplete (0.3.6)
    railties (3.0.0)
      actionpack (= 3.0.0)
      activesupport (= 3.0.0)
      rake (>= 0.8.4)
      thor (~> 0.14.0)
    rake (0.8.7)
    remarkable (4.0.0.alpha4)
      rspec (>= 2.0.0.alpha11)
    remarkable_activemodel (4.0.0.alpha4)
      remarkable (~> 4.0.0.alpha4)
      rspec (>= 2.0.0.alpha11)
    remarkable_mongoid (0.4.0)
      remarkable_activemodel (>= 4.0.0.alpha2)
    rspec (2.0.0)
      rspec-core (= 2.0.0)
      rspec-expectations (= 2.0.0)
      rspec-mocks (= 2.0.0)
    rspec-core (2.0.0)
    rspec-expectations (2.0.0)
      diff-lcs (>= 1.1.2)
    rspec-mocks (2.0.0)
      rspec-core (= 2.0.0)
      rspec-expectations (= 2.0.0)
    rspec-rails (2.0.0)
      rspec (= 2.0.0)
    ruby-debug-base19 (0.11.24)
      columnize (>= 0.3.1)
      linecache19 (>= 0.5.11)
      ruby_core_source (>= 0.1.4)
    ruby-debug19 (0.11.6)
      columnize (>= 0.3.1)
      linecache19 (>= 0.5.11)
      ruby-debug-base19 (>= 0.11.19)
    ruby_core_source (0.1.4)
      archive-tar-minitar (>= 0.5.2)
    rubyzip (0.9.4)
    selenium-webdriver (0.0.29)
      childprocess (>= 0.0.7)
      ffi (~> 0.6.3)
      json_pure
      rubyzip
    spork (0.8.4)
    steak (1.0.0.rc.1)
      rspec
    syntax (1.0.0)
    term-ansicolor (1.0.5)
    thor (0.14.3)
    transitions (0.0.9)
    treetop (1.4.8)
      polyglot (>= 0.3.1)
    tzinfo (0.3.23)
    unicorn (1.1.4)
      rack
    warden (1.0.1)
      rack (>= 1.0.0)
    will_paginate (3.0.pre2)

PLATFORMS
  ruby

DEPENDENCIES
  autotest
  autotest-growl
  bson_ext (>= 1.0.4)
  cancan
  capybara
  carrierwave!
  cucumber
  cucumber-rails
  database_cleaner
  devise!
  fabrication
  haml
  launchy
  luhnacy
  mongoid!
  pg
  prawn
  rack-test!
  rails (= 3.0.0)
  rails3-jquery-autocomplete
  remarkable_mongoid
  rspec
  rspec-rails (>= 2.0.0)
  ruby-debug19
  spork
  steak (>= 1.0.0.rc.1)
  syntax
  transitions
  unicorn
bbhoss commented 13 years ago

I must also add that I am running cucumber by just running the "cucumber" command. I have also tested earlier versions of cucumber and they do not work.

cavalle commented 13 years ago

I've been able to reproduce the problem and found out this could be not easy to fix. The problem is that Steak's feature methods conflicts with a method also called feature in Gerkhin (Cucumber parser).

I'll try to find a fix or workaround since I consider this a very interesting use case (migrating from Cucumber to Steak)

cavalle commented 13 years ago

Ok, I still need to decide how to patch Steak, but as a quick workaround, creating a file config/initializers/cucumber_steak_fix.rb with the following content should make everything work:

if defined?(Gherkin)
  module Gherkin
    module Parser
      class Parser
        undef_method :feature
      end
    end
  end
end

Please, let me know if this works for you

cavalle commented 13 years ago

Any news on this? Did you have the chance to try the suggested workaround?

I don't have the time now to implement the solution in Steak, but patches are welcome

hassox commented 13 years ago

Hi,

I just tried this out, got the following error:

  undefined local variable or method `node' for #<Capybara::Driver::RackTest::Node:0x109e60e10> (NameError)
  ./features/step_definitions/web_steps.rb:39

That line in my web_steps file is a click_link.

I'm using:

HTH Daniel

boblin commented 13 years ago

Same issue, but it looks that cavalle fix works for me:

I am using: rspec (2.0.1) steak (1.0.0.rc.2) cucumber (0.9.3) cucumber-rails (0.3.2) capybara (0.4.0)

boblin commented 13 years ago

With file config/initializers/cucumber_steak_fix.rb, cucumber and rspec spec works. But I found that I can't start local webserver:

=> Booting WEBrick
=> Rails 3.0.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
myapp/config/initializers/cucumber_steak_fix.rb:4:in 
`undef_method': undefined method `feature' for class `Gherkin::Parser::Parser' (NameError)

So I moved content of this fix file at the end of config/environments/test.rb and It looks that it works.

cavalle commented 13 years ago

Right, I just updated the cucumber_steak_fix before in order to not be loaded unless cucumber is present.

hassox commented 13 years ago

I upgaded cucumber to 0.9.3, steak to rc2 and put

# Fix to make steak and cucumber work together
module Gherkin
  module Parser
    class Parser
      undef_method :feature
    end
  end
end

in place. I tried a conditional initializer, end of environments/test.rb and at the end of features/support/env.rb.

Ones that let it work still give me this node issue :\

undefined local variable or method `node' for #Capybara::Driver::RackTest::Node:0x1051202b8 (NameError)

hassox commented 13 years ago

I found the issue I was having: https://github.com/jnicklas/capybara/issues/issue/110

Removing require 'cucumber/rails/capybara_javascript_emulation' from the cucumber env.rb file fixes the issue for me :)

Cheers Daniel

cavalle commented 13 years ago

Don't pollute Object's namespace. Closed by 61147a9b4a72f947d55027b60aceb43b19654a97

cavalle commented 13 years ago

I've just pushed a new version of Steak including a patch for the original problem. Upgrading to 1.0.0.rc.3 should make unnecessary the cucumber_steak_fix.rb file, so please remove it.

If this new version doesn't solve the original problem for you, please reopen this issue. For other issues other than the original one, please open new issues.

Cheers!

boblin commented 13 years ago

I confirm, it works. Thanks!