diff --git a/spec/controllers/mappings_controller_spec.rb b/spec/controllers/mappings_controller_spec.rb index 371d0418..1fc3e181 100644 --- a/spec/controllers/mappings_controller_spec.rb +++ b/spec/controllers/mappings_controller_spec.rb @@ -18,135 +18,133 @@ require 'rails_helper' # Message expectations are only used when there is no simpler way to specify # that an instance is receiving a specific message. -RSpec.describe MappingsController, :type => :controller do - +RSpec.describe MappingsController, type: :controller do # This should return the minimal set of attributes required to create a valid # Mapping. As you add validations to Mapping, be sure to # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } + let(:valid_attributes) do + skip('Add a hash of attributes valid for your model') + end - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } + let(:invalid_attributes) do + skip('Add a hash of attributes invalid for your model') + end # 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 # MappingsController. Be sure to keep this updated too. let(:valid_session) { {} } - describe "GET #index" do - it "assigns all mappings as @mappings" do + describe 'GET #index' do + it 'assigns all mappings as @mappings' do mapping = Mapping.create! valid_attributes get :index, {}, valid_session expect(assigns(:mappings)).to eq([mapping]) end end - describe "GET #show" do - it "assigns the requested mapping as @mapping" do + describe 'GET #show' do + it 'assigns the requested mapping as @mapping' do mapping = Mapping.create! valid_attributes - get :show, {:id => mapping.to_param}, valid_session + get :show, { id: mapping.to_param }, valid_session expect(assigns(:mapping)).to eq(mapping) end end - describe "GET #edit" do - it "assigns the requested mapping as @mapping" do + describe 'GET #edit' do + it 'assigns the requested mapping as @mapping' do mapping = Mapping.create! valid_attributes - get :edit, {:id => mapping.to_param}, valid_session + get :edit, { id: mapping.to_param }, valid_session expect(assigns(:mapping)).to eq(mapping) end end - describe "POST #create" do - context "with valid params" do - it "creates a new Mapping" do - expect { - post :create, {:mapping => valid_attributes}, valid_session - }.to change(Mapping, :count).by(1) + describe 'POST #create' do + context 'with valid params' do + it 'creates a new Mapping' do + expect do + post :create, { mapping: valid_attributes }, valid_session + end.to change(Mapping, :count).by(1) end - it "assigns a newly created mapping as @mapping" do - post :create, {:mapping => valid_attributes}, valid_session + it 'assigns a newly created mapping as @mapping' do + post :create, { mapping: valid_attributes }, valid_session expect(assigns(:mapping)).to be_a(Mapping) expect(assigns(:mapping)).to be_persisted end - it "redirects to the created mapping" do - post :create, {:mapping => valid_attributes}, valid_session + it 'redirects to the created mapping' do + post :create, { mapping: valid_attributes }, valid_session expect(response).to redirect_to(Mapping.last) end end - context "with invalid params" do - it "assigns a newly created but unsaved mapping as @mapping" do - post :create, {:mapping => invalid_attributes}, valid_session + context 'with invalid params' do + it 'assigns a newly created but unsaved mapping as @mapping' do + post :create, { mapping: invalid_attributes }, valid_session expect(assigns(:mapping)).to be_a_new(Mapping) end it "re-renders the 'new' template" do - post :create, {:mapping => invalid_attributes}, valid_session - expect(response).to render_template("new") + post :create, { mapping: 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 mapping" do - mapping = Mapping.create! valid_attributes - put :update, {:id => mapping.to_param, :mapping => new_attributes}, valid_session - mapping.reload - skip("Add assertions for updated state") + describe 'PUT #update' do + context 'with valid params' do + let(:new_attributes) do + skip('Add a hash of attributes valid for your model') end - it "assigns the requested mapping as @mapping" do + it 'updates the requested mapping' do mapping = Mapping.create! valid_attributes - put :update, {:id => mapping.to_param, :mapping => valid_attributes}, valid_session + put :update, { id: mapping.to_param, mapping: new_attributes }, valid_session + mapping.reload + skip('Add assertions for updated state') + end + + it 'assigns the requested mapping as @mapping' do + mapping = Mapping.create! valid_attributes + put :update, { id: mapping.to_param, mapping: valid_attributes }, valid_session expect(assigns(:mapping)).to eq(mapping) end - it "redirects to the mapping" do + it 'redirects to the mapping' do mapping = Mapping.create! valid_attributes - put :update, {:id => mapping.to_param, :mapping => valid_attributes}, valid_session + put :update, { id: mapping.to_param, mapping: valid_attributes }, valid_session expect(response).to redirect_to(mapping) end end - context "with invalid params" do - it "assigns the mapping as @mapping" do + context 'with invalid params' do + it 'assigns the mapping as @mapping' do mapping = Mapping.create! valid_attributes - put :update, {:id => mapping.to_param, :mapping => invalid_attributes}, valid_session + put :update, { id: mapping.to_param, mapping: invalid_attributes }, valid_session expect(assigns(:mapping)).to eq(mapping) end it "re-renders the 'edit' template" do mapping = Mapping.create! valid_attributes - put :update, {:id => mapping.to_param, :mapping => invalid_attributes}, valid_session - expect(response).to render_template("edit") + put :update, { id: mapping.to_param, mapping: invalid_attributes }, valid_session + expect(response).to render_template('edit') end end end - describe "DELETE #destroy" do - it "destroys the requested mapping" do + describe 'DELETE #destroy' do + it 'destroys the requested mapping' do mapping = Mapping.create! valid_attributes - expect { - delete :destroy, {:id => mapping.to_param}, valid_session - }.to change(Mapping, :count).by(-1) + expect do + delete :destroy, { id: mapping.to_param }, valid_session + end.to change(Mapping, :count).by(-1) end - it "redirects to the mappings list" do + it 'redirects to the mappings list' do mapping = Mapping.create! valid_attributes - delete :destroy, {:id => mapping.to_param}, valid_session + delete :destroy, { id: mapping.to_param }, valid_session expect(response).to redirect_to(mappings_url) end end - end diff --git a/spec/controllers/maps_controller_spec.rb b/spec/controllers/maps_controller_spec.rb index 9f66424e..ff16c87b 100644 --- a/spec/controllers/maps_controller_spec.rb +++ b/spec/controllers/maps_controller_spec.rb @@ -18,135 +18,133 @@ require 'rails_helper' # Message expectations are only used when there is no simpler way to specify # that an instance is receiving a specific message. -RSpec.describe MapsController, :type => :controller do - +RSpec.describe MapsController, type: :controller do # This should return the minimal set of attributes required to create a valid # Map. As you add validations to Map, be sure to # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } + let(:valid_attributes) do + skip('Add a hash of attributes valid for your model') + end - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } + let(:invalid_attributes) do + skip('Add a hash of attributes invalid for your model') + end # 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 # MapsController. Be sure to keep this updated too. let(:valid_session) { {} } - describe "GET #index" do - it "assigns all maps as @maps" do + describe 'GET #index' do + it 'assigns all maps as @maps' do map = Map.create! valid_attributes get :index, {}, valid_session expect(assigns(:maps)).to eq([map]) end end - describe "GET #show" do - it "assigns the requested map as @map" do + describe 'GET #show' do + it 'assigns the requested map as @map' do map = Map.create! valid_attributes - get :show, {:id => map.to_param}, valid_session + get :show, { id: map.to_param }, valid_session expect(assigns(:map)).to eq(map) end end - describe "GET #edit" do - it "assigns the requested map as @map" do + describe 'GET #edit' do + it 'assigns the requested map as @map' do map = Map.create! valid_attributes - get :edit, {:id => map.to_param}, valid_session + get :edit, { id: map.to_param }, valid_session expect(assigns(:map)).to eq(map) end end - describe "POST #create" do - context "with valid params" do - it "creates a new Map" do - expect { - post :create, {:map => valid_attributes}, valid_session - }.to change(Map, :count).by(1) + describe 'POST #create' do + context 'with valid params' do + it 'creates a new Map' do + expect do + post :create, { map: valid_attributes }, valid_session + end.to change(Map, :count).by(1) end - it "assigns a newly created map as @map" do - post :create, {:map => valid_attributes}, valid_session + it 'assigns a newly created map as @map' do + post :create, { map: valid_attributes }, valid_session expect(assigns(:map)).to be_a(Map) expect(assigns(:map)).to be_persisted end - it "redirects to the created map" do - post :create, {:map => valid_attributes}, valid_session + it 'redirects to the created map' do + post :create, { map: valid_attributes }, valid_session expect(response).to redirect_to(Map.last) end end - context "with invalid params" do - it "assigns a newly created but unsaved map as @map" do - post :create, {:map => invalid_attributes}, valid_session + context 'with invalid params' do + it 'assigns a newly created but unsaved map as @map' do + post :create, { map: invalid_attributes }, valid_session expect(assigns(:map)).to be_a_new(Map) end it "re-renders the 'new' template" do - post :create, {:map => invalid_attributes}, valid_session - expect(response).to render_template("new") + post :create, { map: 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 map" do - map = Map.create! valid_attributes - put :update, {:id => map.to_param, :map => new_attributes}, valid_session - map.reload - skip("Add assertions for updated state") + describe 'PUT #update' do + context 'with valid params' do + let(:new_attributes) do + skip('Add a hash of attributes valid for your model') end - it "assigns the requested map as @map" do + it 'updates the requested map' do map = Map.create! valid_attributes - put :update, {:id => map.to_param, :map => valid_attributes}, valid_session + put :update, { id: map.to_param, map: new_attributes }, valid_session + map.reload + skip('Add assertions for updated state') + end + + it 'assigns the requested map as @map' do + map = Map.create! valid_attributes + put :update, { id: map.to_param, map: valid_attributes }, valid_session expect(assigns(:map)).to eq(map) end - it "redirects to the map" do + it 'redirects to the map' do map = Map.create! valid_attributes - put :update, {:id => map.to_param, :map => valid_attributes}, valid_session + put :update, { id: map.to_param, map: valid_attributes }, valid_session expect(response).to redirect_to(map) end end - context "with invalid params" do - it "assigns the map as @map" do + context 'with invalid params' do + it 'assigns the map as @map' do map = Map.create! valid_attributes - put :update, {:id => map.to_param, :map => invalid_attributes}, valid_session + put :update, { id: map.to_param, map: invalid_attributes }, valid_session expect(assigns(:map)).to eq(map) end it "re-renders the 'edit' template" do map = Map.create! valid_attributes - put :update, {:id => map.to_param, :map => invalid_attributes}, valid_session - expect(response).to render_template("edit") + put :update, { id: map.to_param, map: invalid_attributes }, valid_session + expect(response).to render_template('edit') end end end - describe "DELETE #destroy" do - it "destroys the requested map" do + describe 'DELETE #destroy' do + it 'destroys the requested map' do map = Map.create! valid_attributes - expect { - delete :destroy, {:id => map.to_param}, valid_session - }.to change(Map, :count).by(-1) + expect do + delete :destroy, { id: map.to_param }, valid_session + end.to change(Map, :count).by(-1) end - it "redirects to the maps list" do + it 'redirects to the maps list' do map = Map.create! valid_attributes - delete :destroy, {:id => map.to_param}, valid_session + delete :destroy, { id: map.to_param }, valid_session expect(response).to redirect_to(maps_url) end end - end diff --git a/spec/controllers/metacodes_controller_spec.rb b/spec/controllers/metacodes_controller_spec.rb index a2f2738f..6f307cb6 100644 --- a/spec/controllers/metacodes_controller_spec.rb +++ b/spec/controllers/metacodes_controller_spec.rb @@ -18,7 +18,7 @@ require 'rails_helper' # Message expectations are only used when there is no simpler way to specify # that an instance is receiving a specific message. -RSpec.describe MetacodesController, :type => :controller do +RSpec.describe MetacodesController, type: :controller do before :each do @user = create(:user, admin: true) sign_in @user @@ -27,137 +27,136 @@ RSpec.describe MetacodesController, :type => :controller do # This should return the minimal set of attributes required to create a valid # Metacode. As you add validations to Metacode, be sure to # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } + let(:valid_attributes) do + skip('Add a hash of attributes valid for your model') + end - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } + let(:invalid_attributes) do + skip('Add a hash of attributes invalid for your model') + end # 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 # MetacodesController. Be sure to keep this updated too. let(:valid_session) { {} } - describe "GET #index" do - it "assigns all metacodes as @metacodes" do + describe 'GET #index' do + it 'assigns all metacodes as @metacodes' do metacode = Metacode.create! valid_attributes get :index, {}, valid_session expect(assigns(:metacodes)).to eq([metacode]) end end - describe "GET #show" do - it "assigns the requested metacode as @metacode" do + describe 'GET #show' do + it 'assigns the requested metacode as @metacode' do metacode = Metacode.create! valid_attributes - get :show, {:id => metacode.to_param}, valid_session + get :show, { id: metacode.to_param }, valid_session expect(assigns(:metacode)).to eq(metacode) end end - describe "GET #new" do - it "assigns a new metacode as @metacode" do + describe 'GET #new' do + it 'assigns a new metacode as @metacode' do get :new, {}, valid_session expect(assigns(:metacode)).to be_a_new(Metacode) end end - describe "GET #edit" do - it "assigns the requested metacode as @metacode" do + describe 'GET #edit' do + it 'assigns the requested metacode as @metacode' do metacode = Metacode.create! valid_attributes - get :edit, {:id => metacode.to_param}, valid_session + get :edit, { id: metacode.to_param }, valid_session expect(assigns(:metacode)).to eq(metacode) end end - describe "POST #create" do - context "with valid params" do - it "creates a new Metacode" do - expect { - post :create, {:metacode => valid_attributes}, valid_session - }.to change(Metacode, :count).by(1) + describe 'POST #create' do + context 'with valid params' do + it 'creates a new Metacode' do + expect do + post :create, { metacode: valid_attributes }, valid_session + end.to change(Metacode, :count).by(1) end - it "assigns a newly created metacode as @metacode" do - post :create, {:metacode => valid_attributes}, valid_session + it 'assigns a newly created metacode as @metacode' do + post :create, { metacode: valid_attributes }, valid_session expect(assigns(:metacode)).to be_a(Metacode) expect(assigns(:metacode)).to be_persisted end - it "redirects to the created metacode" do - post :create, {:metacode => valid_attributes}, valid_session + it 'redirects to the created metacode' do + post :create, { metacode: valid_attributes }, valid_session expect(response).to redirect_to(Metacode.last) end end - context "with invalid params" do - it "assigns a newly created but unsaved metacode as @metacode" do - post :create, {:metacode => invalid_attributes}, valid_session + context 'with invalid params' do + it 'assigns a newly created but unsaved metacode as @metacode' do + post :create, { metacode: invalid_attributes }, valid_session expect(assigns(:metacode)).to be_a_new(Metacode) end it "re-renders the 'new' template" do - post :create, {:metacode => invalid_attributes}, valid_session - expect(response).to render_template("new") + post :create, { metacode: 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 metacode" do - metacode = Metacode.create! valid_attributes - put :update, {:id => metacode.to_param, :metacode => new_attributes}, valid_session - metacode.reload - skip("Add assertions for updated state") + describe 'PUT #update' do + context 'with valid params' do + let(:new_attributes) do + skip('Add a hash of attributes valid for your model') end - it "assigns the requested metacode as @metacode" do + it 'updates the requested metacode' do metacode = Metacode.create! valid_attributes - put :update, {:id => metacode.to_param, :metacode => valid_attributes}, valid_session + put :update, { id: metacode.to_param, metacode: new_attributes }, valid_session + metacode.reload + skip('Add assertions for updated state') + end + + it 'assigns the requested metacode as @metacode' do + metacode = Metacode.create! valid_attributes + put :update, { id: metacode.to_param, metacode: valid_attributes }, valid_session expect(assigns(:metacode)).to eq(metacode) end - it "redirects to the metacode" do + it 'redirects to the metacode' do metacode = Metacode.create! valid_attributes - put :update, {:id => metacode.to_param, :metacode => valid_attributes}, valid_session + put :update, { id: metacode.to_param, metacode: valid_attributes }, valid_session expect(response).to redirect_to(metacode) end end - context "with invalid params" do - it "assigns the metacode as @metacode" do + context 'with invalid params' do + it 'assigns the metacode as @metacode' do metacode = Metacode.create! valid_attributes - put :update, {:id => metacode.to_param, :metacode => invalid_attributes}, valid_session + put :update, { id: metacode.to_param, metacode: invalid_attributes }, valid_session expect(assigns(:metacode)).to eq(metacode) end it "re-renders the 'edit' template" do metacode = Metacode.create! valid_attributes - put :update, {:id => metacode.to_param, :metacode => invalid_attributes}, valid_session - expect(response).to render_template("edit") + put :update, { id: metacode.to_param, metacode: invalid_attributes }, valid_session + expect(response).to render_template('edit') end end end - describe "DELETE #destroy" do - it "destroys the requested metacode" do + describe 'DELETE #destroy' do + it 'destroys the requested metacode' do metacode = Metacode.create! valid_attributes - expect { - delete :destroy, {:id => metacode.to_param}, valid_session - }.to change(Metacode, :count).by(-1) + expect do + delete :destroy, { id: metacode.to_param }, valid_session + end.to change(Metacode, :count).by(-1) end - it "redirects to the metacodes list" do + it 'redirects to the metacodes list' do metacode = Metacode.create! valid_attributes - delete :destroy, {:id => metacode.to_param}, valid_session + delete :destroy, { id: metacode.to_param }, valid_session expect(response).to redirect_to(metacodes_url) end end - end diff --git a/spec/controllers/synapses_controller_spec.rb b/spec/controllers/synapses_controller_spec.rb index 8f8d5187..62f9c6ac 100644 --- a/spec/controllers/synapses_controller_spec.rb +++ b/spec/controllers/synapses_controller_spec.rb @@ -18,135 +18,133 @@ require 'rails_helper' # Message expectations are only used when there is no simpler way to specify # that an instance is receiving a specific message. -RSpec.describe SynapsesController, :type => :controller do - +RSpec.describe SynapsesController, type: :controller do # This should return the minimal set of attributes required to create a valid # Synapse. As you add validations to Synapse, be sure to # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } + let(:valid_attributes) do + skip('Add a hash of attributes valid for your model') + end - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } + let(:invalid_attributes) do + skip('Add a hash of attributes invalid for your model') + end # 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 # SynapsesController. Be sure to keep this updated too. let(:valid_session) { {} } - describe "GET #index" do - it "assigns all synapses as @synapses" do + describe 'GET #index' do + it 'assigns all synapses as @synapses' do synapse = Synapse.create! valid_attributes get :index, {}, valid_session expect(assigns(:synapses)).to eq([synapse]) end end - describe "GET #show" do - it "assigns the requested synapse as @synapse" do + describe 'GET #show' do + it 'assigns the requested synapse as @synapse' do synapse = Synapse.create! valid_attributes - get :show, {:id => synapse.to_param}, valid_session + get :show, { id: synapse.to_param }, valid_session expect(assigns(:synapse)).to eq(synapse) end end - describe "GET #edit" do - it "assigns the requested synapse as @synapse" do + describe 'GET #edit' do + it 'assigns the requested synapse as @synapse' do synapse = Synapse.create! valid_attributes - get :edit, {:id => synapse.to_param}, valid_session + get :edit, { id: synapse.to_param }, valid_session expect(assigns(:synapse)).to eq(synapse) end end - describe "POST #create" do - context "with valid params" do - it "creates a new Synapse" do - expect { - post :create, {:synapse => valid_attributes}, valid_session - }.to change(Synapse, :count).by(1) + describe 'POST #create' do + context 'with valid params' do + it 'creates a new Synapse' do + expect do + post :create, { synapse: valid_attributes }, valid_session + end.to change(Synapse, :count).by(1) end - it "assigns a newly created synapse as @synapse" do - post :create, {:synapse => valid_attributes}, valid_session + it 'assigns a newly created synapse as @synapse' do + post :create, { synapse: valid_attributes }, valid_session expect(assigns(:synapse)).to be_a(Synapse) expect(assigns(:synapse)).to be_persisted end - it "redirects to the created synapse" do - post :create, {:synapse => valid_attributes}, valid_session + it 'redirects to the created synapse' do + post :create, { synapse: valid_attributes }, valid_session expect(response).to redirect_to(Synapse.last) end end - context "with invalid params" do - it "assigns a newly created but unsaved synapse as @synapse" do - post :create, {:synapse => invalid_attributes}, valid_session + context 'with invalid params' do + it 'assigns a newly created but unsaved synapse as @synapse' do + post :create, { synapse: invalid_attributes }, valid_session expect(assigns(:synapse)).to be_a_new(Synapse) end it "re-renders the 'new' template" do - post :create, {:synapse => invalid_attributes}, valid_session - expect(response).to render_template("new") + post :create, { synapse: 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 synapse" do - synapse = Synapse.create! valid_attributes - put :update, {:id => synapse.to_param, :synapse => new_attributes}, valid_session - synapse.reload - skip("Add assertions for updated state") + describe 'PUT #update' do + context 'with valid params' do + let(:new_attributes) do + skip('Add a hash of attributes valid for your model') end - it "assigns the requested synapse as @synapse" do + it 'updates the requested synapse' do synapse = Synapse.create! valid_attributes - put :update, {:id => synapse.to_param, :synapse => valid_attributes}, valid_session + put :update, { id: synapse.to_param, synapse: new_attributes }, valid_session + synapse.reload + skip('Add assertions for updated state') + end + + it 'assigns the requested synapse as @synapse' do + synapse = Synapse.create! valid_attributes + put :update, { id: synapse.to_param, synapse: valid_attributes }, valid_session expect(assigns(:synapse)).to eq(synapse) end - it "redirects to the synapse" do + it 'redirects to the synapse' do synapse = Synapse.create! valid_attributes - put :update, {:id => synapse.to_param, :synapse => valid_attributes}, valid_session + put :update, { id: synapse.to_param, synapse: valid_attributes }, valid_session expect(response).to redirect_to(synapse) end end - context "with invalid params" do - it "assigns the synapse as @synapse" do + context 'with invalid params' do + it 'assigns the synapse as @synapse' do synapse = Synapse.create! valid_attributes - put :update, {:id => synapse.to_param, :synapse => invalid_attributes}, valid_session + put :update, { id: synapse.to_param, synapse: invalid_attributes }, valid_session expect(assigns(:synapse)).to eq(synapse) end it "re-renders the 'edit' template" do synapse = Synapse.create! valid_attributes - put :update, {:id => synapse.to_param, :synapse => invalid_attributes}, valid_session - expect(response).to render_template("edit") + put :update, { id: synapse.to_param, synapse: invalid_attributes }, valid_session + expect(response).to render_template('edit') end end end - describe "DELETE #destroy" do - it "destroys the requested synapse" do + describe 'DELETE #destroy' do + it 'destroys the requested synapse' do synapse = Synapse.create! valid_attributes - expect { - delete :destroy, {:id => synapse.to_param}, valid_session - }.to change(Synapse, :count).by(-1) + expect do + delete :destroy, { id: synapse.to_param }, valid_session + end.to change(Synapse, :count).by(-1) end - it "redirects to the synapses list" do + it 'redirects to the synapses list' do synapse = Synapse.create! valid_attributes - delete :destroy, {:id => synapse.to_param}, valid_session + delete :destroy, { id: synapse.to_param }, valid_session expect(response).to redirect_to(synapses_url) end end - end diff --git a/spec/controllers/topics_controller_spec.rb b/spec/controllers/topics_controller_spec.rb index 15c52e16..8fefd0b2 100644 --- a/spec/controllers/topics_controller_spec.rb +++ b/spec/controllers/topics_controller_spec.rb @@ -18,135 +18,133 @@ require 'rails_helper' # Message expectations are only used when there is no simpler way to specify # that an instance is receiving a specific message. -RSpec.describe TopicsController, :type => :controller do - +RSpec.describe TopicsController, type: :controller do # This should return the minimal set of attributes required to create a valid # Topic. As you add validations to Topic, be sure to # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } + let(:valid_attributes) do + skip('Add a hash of attributes valid for your model') + end - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } + let(:invalid_attributes) do + skip('Add a hash of attributes invalid for your model') + end # 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 # TopicsController. Be sure to keep this updated too. let(:valid_session) { {} } - describe "GET #index" do - it "assigns all topics as @topics" do + describe 'GET #index' do + it 'assigns all topics as @topics' do topic = Topic.create! valid_attributes get :index, {}, valid_session expect(assigns(:topics)).to eq([topic]) end end - describe "GET #show" do - it "assigns the requested topic as @topic" do + describe 'GET #show' do + it 'assigns the requested topic as @topic' do topic = Topic.create! valid_attributes - get :show, {:id => topic.to_param}, valid_session + get :show, { id: topic.to_param }, valid_session expect(assigns(:topic)).to eq(topic) end end - describe "GET #edit" do - it "assigns the requested topic as @topic" do + describe 'GET #edit' do + it 'assigns the requested topic as @topic' do topic = Topic.create! valid_attributes - get :edit, {:id => topic.to_param}, valid_session + get :edit, { id: topic.to_param }, valid_session expect(assigns(:topic)).to eq(topic) end end - describe "POST #create" do - context "with valid params" do - it "creates a new Topic" do - expect { - post :create, {:topic => valid_attributes}, valid_session - }.to change(Topic, :count).by(1) + describe 'POST #create' do + context 'with valid params' do + it 'creates a new Topic' do + expect do + post :create, { topic: valid_attributes }, valid_session + end.to change(Topic, :count).by(1) end - it "assigns a newly created topic as @topic" do - post :create, {:topic => valid_attributes}, valid_session + it 'assigns a newly created topic as @topic' do + post :create, { topic: valid_attributes }, valid_session expect(assigns(:topic)).to be_a(Topic) expect(assigns(:topic)).to be_persisted end - it "redirects to the created topic" do - post :create, {:topic => valid_attributes}, valid_session + it 'redirects to the created topic' do + post :create, { topic: valid_attributes }, valid_session expect(response).to redirect_to(Topic.last) end end - context "with invalid params" do - it "assigns a newly created but unsaved topic as @topic" do - post :create, {:topic => invalid_attributes}, valid_session + context 'with invalid params' do + it 'assigns a newly created but unsaved topic as @topic' do + post :create, { topic: invalid_attributes }, valid_session expect(assigns(:topic)).to be_a_new(Topic) end it "re-renders the 'new' template" do - post :create, {:topic => invalid_attributes}, valid_session - expect(response).to render_template("new") + post :create, { topic: 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 topic" do - topic = Topic.create! valid_attributes - put :update, {:id => topic.to_param, :topic => new_attributes}, valid_session - topic.reload - skip("Add assertions for updated state") + describe 'PUT #update' do + context 'with valid params' do + let(:new_attributes) do + skip('Add a hash of attributes valid for your model') end - it "assigns the requested topic as @topic" do + it 'updates the requested topic' do topic = Topic.create! valid_attributes - put :update, {:id => topic.to_param, :topic => valid_attributes}, valid_session + put :update, { id: topic.to_param, topic: new_attributes }, valid_session + topic.reload + skip('Add assertions for updated state') + end + + it 'assigns the requested topic as @topic' do + topic = Topic.create! valid_attributes + put :update, { id: topic.to_param, topic: valid_attributes }, valid_session expect(assigns(:topic)).to eq(topic) end - it "redirects to the topic" do + it 'redirects to the topic' do topic = Topic.create! valid_attributes - put :update, {:id => topic.to_param, :topic => valid_attributes}, valid_session + put :update, { id: topic.to_param, topic: valid_attributes }, valid_session expect(response).to redirect_to(topic) end end - context "with invalid params" do - it "assigns the topic as @topic" do + context 'with invalid params' do + it 'assigns the topic as @topic' do topic = Topic.create! valid_attributes - put :update, {:id => topic.to_param, :topic => invalid_attributes}, valid_session + put :update, { id: topic.to_param, topic: invalid_attributes }, valid_session expect(assigns(:topic)).to eq(topic) end it "re-renders the 'edit' template" do topic = Topic.create! valid_attributes - put :update, {:id => topic.to_param, :topic => invalid_attributes}, valid_session - expect(response).to render_template("edit") + put :update, { id: topic.to_param, topic: invalid_attributes }, valid_session + expect(response).to render_template('edit') end end end - describe "DELETE #destroy" do - it "destroys the requested topic" do + describe 'DELETE #destroy' do + it 'destroys the requested topic' do topic = Topic.create! valid_attributes - expect { - delete :destroy, {:id => topic.to_param}, valid_session - }.to change(Topic, :count).by(-1) + expect do + delete :destroy, { id: topic.to_param }, valid_session + end.to change(Topic, :count).by(-1) end - it "redirects to the topics list" do + it 'redirects to the topics list' do topic = Topic.create! valid_attributes - delete :destroy, {:id => topic.to_param}, valid_session + delete :destroy, { id: topic.to_param }, valid_session expect(response).to redirect_to(topics_url) end end - end diff --git a/spec/factories/synapses.rb b/spec/factories/synapses.rb index 47ed5c04..f39a7dd6 100644 --- a/spec/factories/synapses.rb +++ b/spec/factories/synapses.rb @@ -2,8 +2,8 @@ FactoryGirl.define do factory :synapse do desc { random_string(10) } category :to - permission :commons - association :node1, factory: :topic + permission :commons + association :node1, factory: :topic association :node2, factory: :topic end end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 48edb0c1..c645aa6b 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -5,6 +5,6 @@ FactoryGirl.define do code { random_string(8) } joinedwithcode { code } password 'omgwtfbbq' - to_create {|instance| instance.save(validate: false) } # bypass validation of the joinedwithcode + to_create { |instance| instance.save(validate: false) } # bypass validation of the joinedwithcode end end diff --git a/spec/models/map_spec.rb b/spec/models/map_spec.rb index dc475ba3..8a83947e 100644 --- a/spec/models/map_spec.rb +++ b/spec/models/map_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe Map, :type => :model do +RSpec.describe Map, type: :model do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/mapping_spec.rb b/spec/models/mapping_spec.rb index e00c5074..32d34796 100644 --- a/spec/models/mapping_spec.rb +++ b/spec/models/mapping_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe Mapping, :type => :model do +RSpec.describe Mapping, type: :model do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/metacode_spec.rb b/spec/models/metacode_spec.rb index a548118a..de0e79a1 100644 --- a/spec/models/metacode_spec.rb +++ b/spec/models/metacode_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe Metacode, :type => :model do +RSpec.describe Metacode, type: :model do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/synapse_spec.rb b/spec/models/synapse_spec.rb index d1faf2c8..dd03e0a0 100644 --- a/spec/models/synapse_spec.rb +++ b/spec/models/synapse_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe Synapse, :type => :model do +RSpec.describe Synapse, type: :model do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index a52bb072..b8c5a8e0 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe Topic, :type => :model do +RSpec.describe Topic, type: :model do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index f6d8fd0b..c109fae8 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -2,7 +2,7 @@ ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) # Prevent database truncation if the environment is production -abort("The Rails environment is running in production mode!") if Rails.env.production? +abort('The Rails environment is running in production mode!') if Rails.env.production? require 'spec_helper' require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! diff --git a/spec/routing/mappings_routing_spec.rb b/spec/routing/mappings_routing_spec.rb index d8266398..6b6d75dc 100644 --- a/spec/routing/mappings_routing_spec.rb +++ b/spec/routing/mappings_routing_spec.rb @@ -1,23 +1,21 @@ -require "rails_helper" +require 'rails_helper' -RSpec.describe MappingsController, :type => :routing do - describe "routing" do - - it "routes to #show" do - expect(:get => "/mappings/1").to route_to("mappings#show", :id => "1") +RSpec.describe MappingsController, type: :routing do + describe 'routing' do + it 'routes to #show' do + expect(get: '/mappings/1').to route_to('mappings#show', id: '1') end - it "routes to #create" do - expect(:post => "/mappings").to route_to("mappings#create") + it 'routes to #create' do + expect(post: '/mappings').to route_to('mappings#create') end - it "routes to #update via PUT" do - expect(:put => "/mappings/1").to route_to("mappings#update", :id => "1") + it 'routes to #update via PUT' do + expect(put: '/mappings/1').to route_to('mappings#update', id: '1') end - it "routes to #destroy" do - expect(:delete => "/mappings/1").to route_to("mappings#destroy", :id => "1") + it 'routes to #destroy' do + expect(delete: '/mappings/1').to route_to('mappings#destroy', id: '1') end - end end diff --git a/spec/routing/maps_routing_spec.rb b/spec/routing/maps_routing_spec.rb index 1e77be48..9d0dcaee 100644 --- a/spec/routing/maps_routing_spec.rb +++ b/spec/routing/maps_routing_spec.rb @@ -1,27 +1,25 @@ -require "rails_helper" +require 'rails_helper' -RSpec.describe MapsController, :type => :routing do - describe "routing" do - - it "routes to #index" do - expect(:get => "/maps").to route_to("maps#index") +RSpec.describe MapsController, type: :routing do + describe 'routing' do + it 'routes to #index' do + expect(get: '/maps').to route_to('maps#index') end - it "routes to #show" do - expect(:get => "/maps/1").to route_to("maps#show", :id => "1") + it 'routes to #show' do + expect(get: '/maps/1').to route_to('maps#show', id: '1') end - it "routes to #create" do - expect(:post => "/maps").to route_to("maps#create") + it 'routes to #create' do + expect(post: '/maps').to route_to('maps#create') end - it "routes to #update via PUT" do - expect(:put => "/maps/1").to route_to("maps#update", :id => "1") + it 'routes to #update via PUT' do + expect(put: '/maps/1').to route_to('maps#update', id: '1') end - it "routes to #destroy" do - expect(:delete => "/maps/1").to route_to("maps#destroy", :id => "1") + it 'routes to #destroy' do + expect(delete: '/maps/1').to route_to('maps#destroy', id: '1') end - end end diff --git a/spec/routing/metacodes_routing_spec.rb b/spec/routing/metacodes_routing_spec.rb index 2bc39be7..1f129448 100644 --- a/spec/routing/metacodes_routing_spec.rb +++ b/spec/routing/metacodes_routing_spec.rb @@ -1,30 +1,29 @@ -require "rails_helper" +require 'rails_helper' -RSpec.describe MetacodesController, :type => :routing do - describe "routing" do - - it "routes to #index" do - expect(:get => "/metacodes").to route_to("metacodes#index") +RSpec.describe MetacodesController, type: :routing do + describe 'routing' do + it 'routes to #index' do + expect(get: '/metacodes').to route_to('metacodes#index') end - it "routes to #new" do - expect(:get => "/metacodes/new").to route_to("metacodes#new") + it 'routes to #new' do + expect(get: '/metacodes/new').to route_to('metacodes#new') end - it "routes to #edit" do - expect(:get => "/metacodes/1/edit").to route_to("metacodes#edit", :id => "1") + it 'routes to #edit' do + expect(get: '/metacodes/1/edit').to route_to('metacodes#edit', id: '1') end - it "routes to #create" do - expect(:post => "/metacodes").to route_to("metacodes#create") + it 'routes to #create' do + expect(post: '/metacodes').to route_to('metacodes#create') end - it "routes to #update via PUT" do - expect(:put => "/metacodes/1").to route_to("metacodes#update", :id => "1") + it 'routes to #update via PUT' do + expect(put: '/metacodes/1').to route_to('metacodes#update', id: '1') end - #it "routes to #destroy" do + # it "routes to #destroy" do # expect(:delete => "/metacodes/1").to route_to("metacodes#destroy", :id => "1") - #end + # end end end diff --git a/spec/routing/synapses_routing_spec.rb b/spec/routing/synapses_routing_spec.rb index e0639bd0..4fd4861f 100644 --- a/spec/routing/synapses_routing_spec.rb +++ b/spec/routing/synapses_routing_spec.rb @@ -1,23 +1,21 @@ -require "rails_helper" +require 'rails_helper' -RSpec.describe SynapsesController, :type => :routing do - describe "routing" do - - it "routes to #show" do - expect(:get => "/synapses/1").to route_to("synapses#show", :id => "1") +RSpec.describe SynapsesController, type: :routing do + describe 'routing' do + it 'routes to #show' do + expect(get: '/synapses/1').to route_to('synapses#show', id: '1') end - it "routes to #create" do - expect(:post => "/synapses").to route_to("synapses#create") + it 'routes to #create' do + expect(post: '/synapses').to route_to('synapses#create') end - it "routes to #update via PUT" do - expect(:put => "/synapses/1").to route_to("synapses#update", :id => "1") + it 'routes to #update via PUT' do + expect(put: '/synapses/1').to route_to('synapses#update', id: '1') end - it "routes to #destroy" do - expect(:delete => "/synapses/1").to route_to("synapses#destroy", :id => "1") + it 'routes to #destroy' do + expect(delete: '/synapses/1').to route_to('synapses#destroy', id: '1') end - end end diff --git a/spec/routing/topics_routing_spec.rb b/spec/routing/topics_routing_spec.rb index 515e15bf..66778404 100644 --- a/spec/routing/topics_routing_spec.rb +++ b/spec/routing/topics_routing_spec.rb @@ -1,23 +1,21 @@ -require "rails_helper" +require 'rails_helper' -RSpec.describe TopicsController, :type => :routing do - describe "routing" do - - it "routes to #show" do - expect(:get => "/topics/1").to route_to("topics#show", :id => "1") +RSpec.describe TopicsController, type: :routing do + describe 'routing' do + it 'routes to #show' do + expect(get: '/topics/1').to route_to('topics#show', id: '1') end - it "routes to #create" do - expect(:post => "/topics").to route_to("topics#create") + it 'routes to #create' do + expect(post: '/topics').to route_to('topics#create') end - it "routes to #update via PUT" do - expect(:put => "/topics/1").to route_to("topics#update", :id => "1") + it 'routes to #update via PUT' do + expect(put: '/topics/1').to route_to('topics#update', id: '1') end - it "routes to #destroy" do - expect(:delete => "/topics/1").to route_to("topics#destroy", :id => "1") + it 'routes to #destroy' do + expect(delete: '/topics/1').to route_to('topics#destroy', id: '1') end - end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index be9f0d88..c72432be 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -41,58 +41,56 @@ RSpec.configure do |config| mocks.verify_partial_doubles = true end -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # These two settings work together to allow you to limit a spec run - # to individual examples or groups you care about by tagging them with - # `:focus` metadata. When nothing is tagged with `:focus`, all examples - # get run. - config.filter_run :focus - config.run_all_when_everything_filtered = true - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax - # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching - config.disable_monkey_patching! - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = 'doc' - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. + # # These two settings work together to allow you to limit a spec run + # # to individual examples or groups you care about by tagging them with + # # `:focus` metadata. When nothing is tagged with `:focus`, all examples + # # get run. + # config.filter_run :focus + # config.run_all_when_everything_filtered = true + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax + # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching + # config.disable_monkey_patching! + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = 'doc' + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # + # # Run specs in random order to surface order dependencies. If you find an + # # order dependency and want to debug it, you can fix the order by providing + # # the seed, which is printed after each run. + # # --seed 1234 + # config.order = :random + # + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed end def random_string(length = 10) - o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten + o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten string = (0...length).map { o[rand(o.length)] }.join end diff --git a/spec/support/controller_helpers.rb b/spec/support/controller_helpers.rb index e8435ba7..b148ff6e 100644 --- a/spec/support/controller_helpers.rb +++ b/spec/support/controller_helpers.rb @@ -3,7 +3,7 @@ module ControllerHelpers def sign_in(user = create(:user)) if user.nil? # simulate unauthenticated - allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, {:scope => :user}) + allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, scope: :user) allow(controller).to receive(:current_user).and_return(nil) else # simulate authenticated diff --git a/spec/support/factory_girl.rb b/spec/support/factory_girl.rb index de2a780d..afae617a 100644 --- a/spec/support/factory_girl.rb +++ b/spec/support/factory_girl.rb @@ -1,4 +1,4 @@ # lets you type create(:user) instead of FactoryGirl.create(:user) RSpec.configure do |config| - config.include FactoryGirl::Syntax::Methods + config.include FactoryGirl::Syntax::Methods end