require 'rails_helper' module Logistics module Core RSpec.describe CarCarrierRatesController, type: :controller do routes { Logistics::Core::Engine.routes } 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 # CarCarrierRatesController. Be sure to keep this updated too. let(:valid_session) { {} } describe "GET #index" do it "assigns all car_carrier_rates as @car_carrier_rates" do car_carrier_rate = CarCarrierRate.create! valid_attributes get :index, {}, valid_session expect(assigns(:car_carrier_rates)).to eq([car_carrier_rate]) end end describe "GET #show" do it "assigns the requested car_carrier_rate as @car_carrier_rate" do car_carrier_rate = CarCarrierRate.create! valid_attributes get :show, {:id => car_carrier_rate.to_param}, valid_session expect(assigns(:car_carrier_rate)).to eq(car_carrier_rate) end end describe "GET #edit" do it "assigns the requested car_carrier_rate as @car_carrier_rate" do car_carrier_rate = CarCarrierRate.create! valid_attributes get :edit, {:id => car_carrier_rate.to_param}, valid_session expect(assigns(:car_carrier_rate)).to eq(car_carrier_rate) end end describe "POST #create" do context "with valid params" do it "creates a new CarCarrierRate" do expect { post :create, {:car_carrier_rate => valid_attributes}, valid_session }.to change(CarCarrierRate, :count).by(1) end it "assigns a newly created car_carrier_rate as @car_carrier_rate" do post :create, {:car_carrier_rate => valid_attributes}, valid_session expect(assigns(:car_carrier_rate)).to be_a(CarCarrierRate) expect(assigns(:car_carrier_rate)).to be_persisted end it "redirects to the created car_carrier_rate" do post :create, {:car_carrier_rate => valid_attributes}, valid_session expect(response).to redirect_to(CarCarrierRate.last) end end context "with invalid params" do it "assigns a newly created but unsaved car_carrier_rate as @car_carrier_rate" do post :create, {:car_carrier_rate => invalid_attributes}, valid_session expect(assigns(:car_carrier_rate)).to be_a_new(CarCarrierRate) end it "re-renders the 'new' template" do post :create, {:car_carrier_rate => 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 car_carrier_rate" do car_carrier_rate = CarCarrierRate.create! valid_attributes put :update, {:id => car_carrier_rate.to_param, :car_carrier_rate => new_attributes}, valid_session car_carrier_rate.reload skip("Add assertions for updated state") end it "assigns the requested car_carrier_rate as @car_carrier_rate" do car_carrier_rate = CarCarrierRate.create! valid_attributes put :update, {:id => car_carrier_rate.to_param, :car_carrier_rate => valid_attributes}, valid_session expect(assigns(:car_carrier_rate)).to eq(car_carrier_rate) end it "redirects to the car_carrier_rate" do car_carrier_rate = CarCarrierRate.create! valid_attributes put :update, {:id => car_carrier_rate.to_param, :car_carrier_rate => valid_attributes}, valid_session expect(response).to redirect_to(car_carrier_rate) end end context "with invalid params" do it "assigns the car_carrier_rate as @car_carrier_rate" do car_carrier_rate = CarCarrierRate.create! valid_attributes put :update, {:id => car_carrier_rate.to_param, :car_carrier_rate => invalid_attributes}, valid_session expect(assigns(:car_carrier_rate)).to eq(car_carrier_rate) end it "re-renders the 'edit' template" do car_carrier_rate = CarCarrierRate.create! valid_attributes put :update, {:id => car_carrier_rate.to_param, :car_carrier_rate => invalid_attributes}, valid_session expect(response).to render_template("edit") end end end describe "DELETE #destroy" do it "destroys the requested car_carrier_rate" do car_carrier_rate = CarCarrierRate.create! valid_attributes expect { delete :destroy, {:id => car_carrier_rate.to_param}, valid_session }.to change(CarCarrierRate, :count).by(-1) end it "redirects to the car_carrier_rates list" do car_carrier_rate = CarCarrierRate.create! valid_attributes delete :destroy, {:id => car_carrier_rate.to_param}, valid_session expect(response).to redirect_to(car_carrier_rates_url) end end end end end