Rubymine is not able to find a step definition, lo

2019-07-16 01:04发布

Rubymine returns an alert of "Undefined step reference" for the two steps of this scenario. This cucumber test is like this:

 @smoke
  Scenario: Update profile Smoke test.
    Given I navigate to this test webpage
      And In Test, I click the element of "test_link"

This 2 steps are located inside a gem, following this structure: gemname/lib/features/step_definitions/web_shared_steps.rb

And (/^I navigate to this (.*?)$/) do |web|
  web = '$' + web.downcase.gsub(' ', '_')
  @browser.goto eval(web)
end

Then (/In (.*?), I click the element of "(.*?)"$/) do |page, element|
  on_page(page + 'Page').click_element(element)
end

And the methods are also in the gem, following this structure: gemname/lib/basic_methods.rb

module BasicMethods

  include PageObject
  include PageObject::PageFactory


  def click_element (element)
    element = element.downcase.gsub(' ', '_')
    wait_until{send("#{element}?")}

    select = send("#{element}_element")
    wait_until{select.visible?}

    select.click
  end

So, If I execute with the command line "bundle exec cucumber", the test is able to find the step definitions in the gem, and the methods in the gem, and everything is executed correctly.

But, Rubymine is still giving an alert of "Undefined Step reference" for the two steps of the scenario, and I am unable to "command click" in those steps in order to navigate to the step definition.

QUESTION: Since the test in working, how is possible to "tell" Rubymine the folder/location where it has to search for the step definitions?

2条回答
SAY GOODBYE
2楼-- · 2019-07-16 01:47

I don't have Rubymine so I can't verify this answer but it sounds very similar to a problem I had with Syntastic under Vim.

Try creating a file called features/support/external.rb containing:

require "lib/features/step_definitions/web_shared_steps.rb"

Actually it doesn't have to be called external.rb, it can be called anything except env.rb.

I'm guessing that Rubymine is calling cucumber with the --dry-run option to generate its warnings. See this answer for details.

查看更多
仙女界的扛把子
3楼-- · 2019-07-16 01:56

try putting the gem source on your machine and then add this to your gemfile
gem 'gem', :path => 'path/to/gem-source'

I've had a similar problem with trying to use my own fork of a gem
When i did gem 'my-gem', :git => 'my-repo.git' i had the same problem as you, but by using :path I got rubyMine to recognise my step definitions.

I need to switch back to :git in production but at least i have a solution for my dev environment

查看更多
登录 后发表回答