Rubymine不能找到一个步骤定义,位于一个宝石内 [英] Rubymine is not able to find a step definition, located inside a gem
问题描述
Rubymine针对此场景的两个步骤返回未定义步骤参考的警报。这个黄瓜测试是这样的:
@smoke
场景:更新profile Smoke test。
考虑到我浏览这个测试网页
在测试中,我点击test_link的元素
b $ b
这两个步骤位于gem内,遵循以下结构:
gemname / lib / features / step_definitions / web_shared_steps.rb
和(/ ^我导航到这个(。*?)$ /)do | web |
web ='$'+ web.downcase.gsub('','_')
@ browser.goto eval(web)
end
然后/ In(。*?),我点击(。*?)$ /)do | page,element |的元素
on_page(page +'Page')。click_element(element)
end
方法也在gem中,遵循以下结构:
gemname / lib / basic_methods.rb
模块BasicMethods
包括PageObject
包括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
,如果我使用命令行bundle exec cucumber执行,测试能够找到gem中的步骤定义,以及gem中的方法,一切正确执行。
但是,Rubymine仍然给出场景的两个步骤的未定义步骤参考的警报,并且我无法在这些步骤中命令点击,以便导航到步骤定义。 p>
问题:由于测试在工作,如何可以告诉Rubymine的文件夹/位置,它必须搜索的步骤定义?
尝试将gem源放在您的机器上,然后将其添加到您的gemfile
,:path => 'path / to / gem-source'
我有一个类似的问题,试图使用我自己的fork一个gem
当我做 gem'my-gem',:git => 'my-repo.git'
我有同样的问题,但通过使用:path
我得到了rubyMine识别我的步骤定义。
我需要在生产中切换回:git
,但至少我有一个解决方案, / p>
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?
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
这篇关于Rubymine不能找到一个步骤定义,位于一个宝石内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!