NameError:
undefined local variable or method `login_user' for RSpec::ExampleGroups::Products::POSTCreate:Class
como lo soluciono? ya cargue esto en el rails_helper
config.extend ControllerMacros, type: :controller
Clase 1
12.- Products scaffold
Clase 2
13.- Factories y pruebas unitarias a los productos
Clase 3
14.- Métodos de ayuda para las pruebas
Clase 4
15.- Finalizar products controller
Clase 5
16.- Form Builders parte 1
Clase 6
17.- Form Builders parte 2
Clase 7
18.- Form Builders parte 3
Clase 8
19.- Vista de los productos
Clase 9
20.- Subir avatar productos
Clase 10
21.- Diferentes vistas, misma acción
Clase 11
22.- Confirmar eliminación de productos
Clase 12
23.- Archivos adjuntos
Clase 13
24.- Subir archivos adjuntos
Clase 14
25.- Eliminar archivos adjuntos
Clase 15
26.- Cambiar ruta para guardar archivos
4 comentario(s)
require 'rails_helper' This spec was generated by rspec-rails when you ran the scaffold generator. It demonstrates how one might use RSpec to specify the controller code that was generated by Rails when you ran the scaffold generator. It assumes that the implementation code is generated by the rails scaffold generator. If you are using any extension libraries to generate different controller code, this generated spec may or may not pass. It only uses APIs available in rails and/or rspec-rails. There are a number of tools you can use to make these specs even more expressive, but we're sticking to rails and rspec-rails APIs to keep things simple and stable. Compared to earlier versions of this generator, there is very limited use of stubs and message expectations in this spec. Stubs are only used when there is no simpler way to get a handle on the object needed for the example. Message expectations are only used when there is no simpler way to specify that an instance is receiving a specific message.RSpec.describe ProductsController, type: :controller do
# This should return the minimal set of attributes required to create a valid # Product. As you add validations to Product, be sure to # adjust the attributes here as well. let(:valid_attributes) { { name: "Hola mundo", user: FactoryGirl.create(:user), pricing: 1.0 } }
let(:invalid_attributes) { { name: "", pricing: 0 } }
describe "GET #index" do it "assigns all products as @products" do product = Product.create! valid_attributes get :index, params: {} expect(assigns(:products)).to eq([product]) end end
describe "GET #show" do it "assigns the requested product as @product" do product = Product.create! valid_attributes get :show, params: {id: product.to_param} expect(assigns(:product)).to eq(product) end end
describe "GET #new" do it "assigns a new product as @product" do get :new, params: {} expect(assigns(:product)).to be_a_new(Product) end end
describe "GET #edit" do it "assigns the requested product as @product" do product = Product.create! valid_attributes get :edit, params: {id: product.to_param} expect(assigns(:product)).to eq(product) end end
describe "POST #create" do login_user context "with valid params" do it "creates a new Product" do expect { post :create, params: {product: valid_attributes} }.to change(Product, :count).by(1) end
it "assigns a newly created product as @product" do post :create, params: {product: valid_attributes} expect(assigns(:product)).to be_a(Product) expect(assigns(:product)).to be_persisted end it "redirects to the created product" do post :create, params: {product: valid_attributes} expect(response).to redirect_to(Product.last) end end context "with invalid params" do it "assigns a newly created but unsaved product as @product" do post :create, params: {product: invalid_attributes} expect(assigns(:product)).to be_a_new(Product) end it "re-renders the 'new' template" do post :create, params: {product: invalid_attributes} expect(response).to render_template("new") end end
end
describe "PUT #update" do context "with valid params" do let(:new_attributes) { skip("Add a hash of attributes valid for your model") }
it "updates the requested product" do product = Product.create! valid_attributes put :update, params: {id: product.to_param, product: new_attributes} product.reload skip("Add assertions for updated state") end it "assigns the requested product as @product" do product = Product.create! valid_attributes put :update, params: {id: product.to_param, product: valid_attributes} expect(assigns(:product)).to eq(product) end it "redirects to the product" do product = Product.create! valid_attributes put :update, params: {id: product.to_param, product: valid_attributes} expect(response).to redirect_to(product) end end context "with invalid params" do it "assigns the product as @product" do product = Product.create! valid_attributes put :update, params: {id: product.to_param, product: invalid_attributes} expect(assigns(:product)).to eq(product) end it "re-renders the 'edit' template" do product = Product.create! valid_attributes put :update, params: {id: product.to_param, product: invalid_attributes} expect(response).to render_template("edit") end end
end
describe "DELETE #destroy" do it "destroys the requested product" do product = Product.create! valid_attributes expect { delete :destroy, params: {id: product.to_param} end end
it "redirects to the products list" do product = Product.create! valid_attributes delete :destroy, params: {id: product.to_param} expect(response).to redirect_to(products_url) end
Gracias por su colaboracion
C:/Users/user/Documents/rails/ecommerce/spec/rails_helper.rb:51:in block in <to
p (required)>': undefined method
helpers' for Warden::Test:Module (NoMethodError)
Alguien me puede ayudar con este error?
Clase 14