RSpec.describe 'Book', :type => :request do describe 'List Books' do let(:book) { FactoryGirl.create :book } before(:each) do visit root_path end context 'when book is created' do let(:book) { FactoryGirl.create :book, title: 'My Book Title' } it 'should list books' do post books_path({book: book}) expect(page).to have_content 'My Book Title' end end context 'when no book is created' do it 'should not list books' do expect(page).to have_content 'No books found' end end end end
失敗/錯誤:params.require(:book).permit(:title,:abstract,:author,:pages,:price,:image_file_name,:genre,:published_on)Rspec rails routes錯誤參數丟失
ActionController::ParameterMissing:
param is missing or the value is empty: book
它顯示未定義的方法'許可證」的「424」:字符串 – jerrytom
它將它重定向到書籍詳細信息頁面而不是列出書籍 – jerrytom
您可以添加您的控制器 –