Cucumber Issue - Exception message: undefined method 'Given' for main:Object

I'm brand new to Rubymine and I was expecting there to be a fairly comprehensive guide on how to set Rubymine up for Cucumber testing. So far, all I've found was http://www.jetbrains.com/ruby/webhelp/cucumber.html
And that page seems to suggest that as long as you have the cucumber gem installed in your project, it will run just fine. I do have the cucumber gem installed, and my .feature files have the little green comment bubble icon next to them. But when I attempt to run my project, I get the following errors:


C:\Ruby193\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) "C:\Users\Bmcgillis\AppData\Roaming\JetBrains\RubyMine 6.3.3\rb\testing\runner\tunit_or_minitest_in_folder_runner.rb"
Testing started at 12:55 PM ...
Work directory: C:/Users/Bmcgillis/RubymineProjects/testProject
Loading files....
=========================================
Fail to load: C:/Users/Bmcgillis/RubymineProjects/testProject/features/step_definitions/test_cis_steps.rb:1
      Exception message: undefined method `Given' for main:Object
["C:/Users/Bmcgillis/RubymineProjects/testProject/features/step_definitions/test_cis_steps.rb:1:in `<top (required)>'", "C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'", "C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'", "C:/Users/Bmcgillis/AppData/Roaming/JetBrains/RubyMine 6.3.3/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb:51:in `block in require_all_test_scripts'", "C:/Users/Bmcgillis/AppData/Roaming/JetBrains/RubyMine 6.3.3/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb:44:in `each'", "C:/Users/Bmcgillis/AppData/Roaming/JetBrains/RubyMine 6.3.3/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb:44:in `require_all_test_scripts'", "C:/Users/Bmcgillis/AppData/Roaming/JetBrains/RubyMine 6.3.3/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb:140:in `<top (required)>'", "-e:1:in `load'", "-e:1:in `<main>'"]

Fail to load: C:/Users/Bmcgillis/RubymineProjects/testProject/lib/pages/test_cis_landing_page.rb:1
      Exception message: uninitialized constant TestCISLandingPage::PageBase
["C:/Users/Bmcgillis/RubymineProjects/testProject/lib/pages/test_cis_landing_page.rb:2:in `<class:TestCISLandingPage>'", "C:/Users/Bmcgillis/RubymineProjects/testProject/lib/pages/test_cis_landing_page.rb:1:in `<top (required)>'", "C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'", "C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'", "C:/Users/Bmcgillis/AppData/Roaming/JetBrains/RubyMine 6.3.3/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb:51:in `block in require_all_test_scripts'", "C:/Users/Bmcgillis/AppData/Roaming/JetBrains/RubyMine 6.3.3/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb:44:in `each'", "C:/Users/Bmcgillis/AppData/Roaming/JetBrains/RubyMine 6.3.3/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb:44:in `require_all_test_scripts'", "C:/Users/Bmcgillis/AppData/Roaming/JetBrains/RubyMine 6.3.3/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb:140:in `<top (required)>'", "-e:1:in `load'", "-e:1:in `<main>'"]

0 files were loaded.
=========================================
Running tests...

Process finished with exit code 0



My main concern is that 'Given' is somehow an undefined method. I've searched around and this apparently hasn't happened to anyone else. But it makes me think that the project isn't being run as a cucumber project.


Is there something basic that I'm missing here?


Thanks

3 comments
Comment actions Permalink

Hi,

the output you provided suggests that you run cucumber features as minitest tests.
Most likely you have craeted this run configuration before Cucumber has been installed in the project (btw am I right that you are using bundler and cucumber is added to Gemfile?)
thus I'd suggest to remote the run configuration (Run|Edit Configurations...) and try to run features again (this time RubyMine should suggest you to run all features in the directory).

Hope this helps, Oleg.

P.S. one more way to verify that RubyMine detected that you are using cucumber is to find one in Externals Libraries

0
Comment actions Permalink

Hi Oleg,

Thanks for getting back to me. I was able to get my cucumber project working. I had to go into my run configurations and add a cucumber configuration manually. Then I also had to delete my old configuration that was already in there.


Thank you for your help.

0
Comment actions Permalink

Hello, I am new to learn this technology. Please help me about this error.

C:\Ruby25-x64\bin\ruby.exe C:/Users/DELL/RubymineProjects/CucumberSecondProject/Feature1/step_definitions/Multi.rb
Traceback (most recent call last):
C:/Users/DELL/RubymineProjects/CucumberSecondProject/Feature1/step_definitions/Multi.rb:1:in `<main>': undefined method `Given' for main:Object (NoMethodError)

Process finished with exit code 1

0

Please sign in to leave a comment.