0
我使用,我想用RSpec的測試軌道4,5和RSpec 3. 我有一個控制器,但我收到以下錯誤rspec的得到錯誤故障/錯誤:response.should render_template
Failure/Error: response.should render_template :show
expecting <"show"> but rendering with <[]>
該controller_spec是這樣
describe "GET #show" do
it "renders the #show view" do
get :show, id: FactoryGirl.create(:product)
response.should render_template :show
end
end
_show.html
的局部是這樣
<h2><%= @product.name %></h2>
<div class="product-price"> <h3><%= number_to_currency @product.price %> </h3></div>
<div class="product-description well"><%= @product.description %> </div>
</div>
<%= link_to "Edit", edit_product_path , remote: true, class: "btn btn-primary" %>
<%= link_to "Delete", product_delete_path(@product), remote: true, class: "btn btn-danger" %>
show.js.erb就像product_controller這個
$("#product-details").html("<%= escape_javascript(render 'show') %>")
和播放功能,
def show
@product = Product.find(params[:id])
respond_to do |f|
f.html { render nothing: true } # prevents rendering a nonexistent template file
f.js # still renders the JavaScript template
end
end