Ruby on Rails でWebサイトを作成しており
app/controllers/products_controller.rbのテストを書いています。
ruby
1class ProductsController < ApplicationController 2 def show 3 @product = product.find(params[:id]) 4 @product_properties = @product.product_properties.includes(:property) 5 end 6end
テストは下記のspec/controllers/products_controller_spec.rbです
ruby
1require 'rails_helper' 2 3RSpec.describe ProductsController, type: :controller do 4 let(:product) { create(:product) } 5 6 describe "show Action successfull" do 7 before do 8 get :show, params: { id: product.id } 9 end 10 11 it "@productが期待される値を持つこと" do 12 expect(assigns(:product)).to eq(product) 13 end 14 end 15end
propertyのテストを書きたいのですが、どう書けばいいかわかりません。教えて頂けないでしょうか。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。