Rspec 黄瓜奇怪路线问题
我正在rails中做一个简单的应用程序,没有使用cucumber 我有一个用户故事:Rspec 黄瓜奇怪路线问题,rspec,cucumber,bdd,ruby-on-rails-3,webrat,Rspec,Cucumber,Bdd,Ruby On Rails 3,Webrat,我正在rails中做一个简单的应用程序,没有使用cucumber 我有一个用户故事: Scenario: add new expense Given I am on the expenses page When I follow "new expense" Then I am on new expense page Then I fill in "expense_title" with "french fries" Then I fill in "expense_catego
Scenario: add new expense
Given I am on the expenses page
When I follow "new expense"
Then I am on new expense page
Then I fill in "expense_title" with "french fries"
Then I fill in "expense_category" with "Lunch"
Then I fill in "expense_amount" with "2300"
And I press "expense_submit"
And I should be on the "french fries" expense page
Then I should see "The expense was successfully created"
在开发模式中,我遵循了相同的步骤,得到了预期的结果,但使用cucumber运行此程序时,我会收到此错误消息
(::) failed steps (::)
expected: "/expenses/2",
got: "/expenses" (using ==) (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/web_steps.rb:260:in `/^(?:|I )should be on (.+)$/'
features/expenses.feature:14:in `And I should be on the "french fries" expense page'
我已经在path.rb中设置了正确的路径
when /the "(.+)" expense page/
"/expenses/#{Expense.find_by_title($1).id}"
因此,与前面代码的结果对应的预期路径是正确的,但得到的结果不是
当我在提交按钮后添加“然后显示页面”时,我得到一个包含以下消息的简单页面:
You are being redirected.
但正如我之前所说,这在开发模式下不会发生,而且我已经检查了记录是否成功存储到数据库中,所以我不知道问题出在哪里,有人能帮我吗
问候
PS:我的创建方法
回复:html
def create
@expense = Expense.new(params[:expense])
if @expense.save
flash[:notice] = "The expense was successfully created"
end
respond_with @expense
end
在我看来,它看起来像是您的
路径。rb
配置正确,但将其重定向回路径的是您的创建
操作。问题是webrat与rails 3的兼容性问题
这是同样的问题,也有解决方案,一个简单的webrat gem补丁不,它不是,一切都可以在开发模式下正常工作,正如它所预期的那样,但不是cucumber,这是我的问题problem@forellana:您在Cucumber功能中使用的费用有效吗?是的,这是一个webrat路由问题,我用我对这个问题的回答解决了这个问题,谢谢