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