我正在设置我的Authlogic用户会话功能。 而且我有些困惑。 我跑的时候:
cucumber features
我收到一些红色错误
Scenario: User signs in successfully # features/user_sessions.feature:21
Given a user exists with login: "sachin", password: "secret" # features/step_definitions/pickle_steps.rb:4
When I go to the login page # features/step_definitions/webrat_steps.rb:15
And I login as "sachin" with password "secret" # features/step_definitions/user_session_setps.rb:5
Then I should see "Login successful" # features/step_definitions/webrat_steps.rb:123
And I should be logged in # features/user_sessions.feature:26
Ambiguous match of "I should be logged in":
features/step_definitions/pickle_steps.rb:55:in `/^((?:(?:I|myself|me|my)|(?:(?:a|an|another|the|that) )?(?:(?:(?:(?:first|last|(?:\d+(?:st|nd|rd|th))) )?(?:user))|(?:(?:user)(?::? "(?:[^\"]|\.)*"))))) should (?:be|have) (?:an? )?((?:duplicable|readonly|nil|store[_ ]full[_ ]sti[_ ]class|new[_ ]record|equal|present|eql|marked[_ ]for[_ ]destruction|valid[_ ]password|valid[_ ]with[_ ]callbacks|logged[_ ]in|valid[_ ]without[_ ]callbacks|respond[_ ]to[_ ]without[_ ]attributes|valid|logged[_ ]out|respond[_ ]to|instance[_ ]variable[_ ]defined|admin|blank|changed|tainted|unserializable[_ ]attribute|locking[_ ]enabled|has[_ ]role|instance[_ ]of|partial[_ ]updates|kind[_ ]of|attribute[_ ]present|is[_ ]a|frozen|invalid|acts[_ ]like|method[_ ]exists|has[_ ]attribute|disable[_ ]perishable[_ ]token[_ ]maintenance|is[_ ]haml|id|created[_ ]at|updated[_ ]at|login|crypted[_ ]password|password[_ ]salt|persistence[_ ]token|login[_ ]count|last[_ ]request[_ ]at|last[_ ]login[_ ]at|current[_ ]login[_ ]at|last[_ ]login[_ ]ip|current[_ ]login[_ ]ip|roles|first[_ ]name|last[_ ]name|perishable[_ ]token|email))$/'
features/step_definitions/user_session_setps.rb:13:in `/^I should be logged in$/'
You can run again with --guess to make Cucumber be more smart about it
(Cucumber::Ambiguous)
features/user_sessions.feature:26:in `And I should be logged in'
Failing Scenarios:
cucumber features/user_sessions.feature:7 # Scenario: User is not signed up
cucumber features/user_sessions.feature:14 # Scenario: User enters wrong password
cucumber features/user_sessions.feature:21 # Scenario: User signs in successfully
正如黄瓜建议的那样,当我和--guess选项一起运行时:
cucumber features --guess
所有人都变绿了并且过世了。 这是预期的行为还是错误?
答案 0 :(得分:6)
AFAIK,如果您有两个相同的步骤定义,Cucumber不知道要运行哪一个。使用--guess标志迫使Cucumber挑选最可能的一个。黄瓜耙子任务使用--strict标志,如果你有狡猾的步骤将失败。
基本上,您需要考虑冲突的2个步骤(一个在pickle步骤中,一个在user_session_steps中)并决定使用哪个步骤,然后删除另一个步骤。
答案 1 :(得分:0)
要使$ rake
正常工作,请指定cucumber's guess mode
,请指定lib/tasks/cucumber.rake
:
t.cucumber_opts = "--guess"
答案 2 :(得分:0)
请考虑以下步骤定义:
alpha_b.owner
=> A
明文步骤:
Given /Three (.*) mice/ do |disability|
# some code
end
Given /Three blind (.*)/ do |animal|
# some other code..
end
Cucumber无法决定执行什么步骤定义,并会引发Given Three blind mice
错误,告诉您修复歧义。
猜模式
运行纯文本步骤将匹配两个步骤定义的正则表达式并引发Cucumber::Ambiguous
。然而,
如果您使用Cucumber::Ambiguous
运行Cucumber,则会猜测您的目标是使用2个匹配组进行步骤定义。
打开选项时会调用排名逻辑:
所以,如果你尝试用上面的老鼠 - 黄瓜会选择/三个盲(。*)/,因为“老鼠”比“盲”短。
<小时/> 更多详情here