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