I've got these both files and I'd like to test it in Rails 4.2 (using RSpec 3.2) But when running I get the exception.
Does anyone has an idea to fix this?
new.html.erb_spec.rb:
require 'rails_helper'
RSpec.describe "products/new", type: :view do
before(:each) do
assign(:product, Product.new())
end
it "renders new product form" do
render
# assert_select "form[action=?][method=?]", products_path, "post" do
# end
end
end
new.html.erb:
<h1>New Product</h1>
<%= link_to 'Back', products_path %>
Exception:
1) products/new renders new product form
Failure/Error: render
ActionView::Template::Error:
undefined local variable or method `products_path' for #<#<Class:0x007fc7da6d6240>:0x007fc7da6cf3a0>
# ./app/views/products/new.html.erb:4:in `_app_views_products_new_html_erb__2726879035604323536_70248169634620'
# /Users/endem/.rvm/gems/ruby-2.2.1/gems/actionview-4.2.4/lib/action_view/template.rb:145:in `block in render'
# /Users/endem/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/notifications.rb:164:in `block in instrument'
# /Users/endem/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /Users/endem/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/notifications.rb:164:in `instrument'
Aucun commentaire:
Enregistrer un commentaire