きゅうりを使わずにレールで簡単なアプリをやっています
このユーザーストーリーがあります:
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"
開発モードでは、同じ手順に従って期待どおりの結果が得られましたが、キュウリでこれを実行すると、このエラー メッセージが表示されます
(::) 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