require 'rails_helper' module Logistics module Core RSpec.describe WeightRangesController, type: :controller do let(:valid_attributes) { skip("Add a hash of attributes valid for your model") } let(:invalid_attributes) { skip("Add a hash of attributes invalid for your model") } # This should return the minimal set of values that should be in the session # in order to pass any filters (e.g. authentication) defined in # WeightRangesController. Be sure to keep this updated too. let(:valid_session) { {} } describe "GET #index" do it "assigns all weight_ranges as @weight_ranges" do weight_range = WeightRange.create! valid_attributes get :index, {}, valid_session expect(assigns(:weight_ranges)).to eq([weight_range]) end end describe "GET #show" do it "assigns the requested weight_range as @weight_range" do weight_range = WeightRange.create! valid_attributes get :show, {:id => weight_range.to_param}, valid_session expect(assigns(:weight_range)).to eq(weight_range) end end describe "GET #edit" do it "assigns the requested weight_range as @weight_range" do weight_range = WeightRange.create! valid_attributes get :edit, {:id => weight_range.to_param}, valid_session expect(assigns(:weight_range)).to eq(weight_range) end end describe "POST #create" do context "with valid params" do it "creates a new WeightRange" do expect { post :create, {:weight_range => valid_attributes}, valid_session }.to change(WeightRange, :count).by(1) end it "assigns a newly created weight_range as @weight_range" do post :create, {:weight_range => valid_attributes}, valid_session expect(assigns(:weight_range)).to be_a(WeightRange) expect(assigns(:weight_range)).to be_persisted end it "redirects to the created weight_range" do post :create, {:weight_range => valid_attributes}, valid_session expect(response).to redirect_to(WeightRange.last) end end context "with invalid params" do it "assigns a newly created but unsaved weight_range as @weight_range" do post :create, {:weight_range => invalid_attributes}, valid_session expect(assigns(:weight_range)).to be_a_new(WeightRange) end it "re-renders the 'new' template" do post :create, {:weight_range => invalid_attributes}, valid_session 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 weight_range" do weight_range = WeightRange.create! valid_attributes put :update, {:id => weight_range.to_param, :weight_range => new_attributes}, valid_session weight_range.reload skip("Add assertions for updated state") end it "assigns the requested weight_range as @weight_range" do weight_range = WeightRange.create! valid_attributes put :update, {:id => weight_range.to_param, :weight_range => valid_attributes}, valid_session expect(assigns(:weight_range)).to eq(weight_range) end it "redirects to the weight_range" do weight_range = WeightRange.create! valid_attributes put :update, {:id => weight_range.to_param, :weight_range => valid_attributes}, valid_session expect(response).to redirect_to(weight_range) end end context "with invalid params" do it "assigns the weight_range as @weight_range" do weight_range = WeightRange.create! valid_attributes put :update, {:id => weight_range.to_param, :weight_range => invalid_attributes}, valid_session expect(assigns(:weight_range)).to eq(weight_range) end it "re-renders the 'edit' template" do weight_range = WeightRange.create! valid_attributes put :update, {:id => weight_range.to_param, :weight_range => invalid_attributes}, valid_session expect(response).to render_template("edit") end end end describe "DELETE #destroy" do it "destroys the requested weight_range" do weight_range = WeightRange.create! valid_attributes expect { delete :destroy, {:id => weight_range.to_param}, valid_session }.to change(WeightRange, :count).by(-1) end it "redirects to the weight_ranges list" do weight_range = WeightRange.create! valid_attributes delete :destroy, {:id => weight_range.to_param}, valid_session expect(response).to redirect_to(weight_ranges_url) end end end end end