チュートリアルのMichaelHartlのユーザーモデルに基づいて、注文を受け取るための注文モデルを作成しようとしています。
ViewのOrdersディレクトリに、基本的なOrderページとConfirmationページを作成しました。コンテンツのテストを作成しました。テストを実行すると、あらゆる種類のエラーが表示されますが、ほとんどの場合、これに関係しています。
Failure/Error: before { visit root_path }
ActionView::Template::Error:
No route matches {:action=>"show", :controller=>"orders"}
私が考えたのは、ビューの欠落(「テンプレート」が原因)と関係がありましたが、私が言ったように、私はそれらのファイルを持っています。私のroutes.rbファイルには、次のものがあります。
resources :orders
root to: 'alpha#welcome'
match '/order', to: 'orders#new'
match '/about', to: 'alpha#about'
match '/contact', to: 'alpha#contact'
match '/confirmation', to: 'orders#show'
そして私の注文コントローラーはこれを言います:
class OrdersController < ApplicationController
def show
@order = Order.find(params[:id])
end
def new
@order = Order.new
end
end
私は彼のチュートリアルをくまなく調べて、自分が間違っていることを理解しようとしていますが、まだ何も機能していません。ヘルプ?私はこれにとても慣れていません。
おー。さらに紛らわしいのは、rspecが、これらのルートのいずれかをまったくたどろうとしないスペックドキュメントでこの問題が発生していると主張していることです。(静的ページ用、注文モデル用、注文ページ用の3つの仕様があります。静的ページの1つは、注文モデルコントローラーのアクションについて不平を言っています。)
ありがとう、リクエストに応じて、これが私の注文ページの仕様です:
require 'spec_helper'
describe "Order Pages" do
subject { page }
describe "order page" do
before {visit order_path}
it { should have_selector('h1', text: 'Order Below') }
it { should have_selector('title', text: 'Order') }
end
describe "confirmation page" do
let(:order) { FactoryGirl.create(:order) }
before { visit confirmation_path(order) }
it { should have_selector('h1', text: 'Your order:') }
it { should have_selector('title', text: 'Order') }
end
end