rubocop style updates

This commit is contained in:
Devin Howard 2015-12-16 22:19:58 +08:00
parent ae1117338a
commit 846d04dd0d
21 changed files with 407 additions and 427 deletions

View file

@ -18,135 +18,133 @@ require 'rails_helper'
# Message expectations are only used when there is no simpler way to specify # Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message. # 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 # This should return the minimal set of attributes required to create a valid
# Mapping. As you add validations to Mapping, be sure to # Mapping. As you add validations to Mapping, be sure to
# adjust the attributes here as well. # adjust the attributes here as well.
let(:valid_attributes) { let(:valid_attributes) do
skip("Add a hash of attributes valid for your model") skip('Add a hash of attributes valid for your model')
} end
let(:invalid_attributes) { let(:invalid_attributes) do
skip("Add a hash of attributes invalid for your model") 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 # 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 # in order to pass any filters (e.g. authentication) defined in
# MappingsController. Be sure to keep this updated too. # MappingsController. Be sure to keep this updated too.
let(:valid_session) { {} } let(:valid_session) { {} }
describe "GET #index" do describe 'GET #index' do
it "assigns all mappings as @mappings" do it 'assigns all mappings as @mappings' do
mapping = Mapping.create! valid_attributes mapping = Mapping.create! valid_attributes
get :index, {}, valid_session get :index, {}, valid_session
expect(assigns(:mappings)).to eq([mapping]) expect(assigns(:mappings)).to eq([mapping])
end end
end end
describe "GET #show" do describe 'GET #show' do
it "assigns the requested mapping as @mapping" do it 'assigns the requested mapping as @mapping' do
mapping = Mapping.create! valid_attributes 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) expect(assigns(:mapping)).to eq(mapping)
end end
end end
describe "GET #edit" do describe 'GET #edit' do
it "assigns the requested mapping as @mapping" do it 'assigns the requested mapping as @mapping' do
mapping = Mapping.create! valid_attributes 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) expect(assigns(:mapping)).to eq(mapping)
end end
end end
describe "POST #create" do describe 'POST #create' do
context "with valid params" do context 'with valid params' do
it "creates a new Mapping" do it 'creates a new Mapping' do
expect { expect do
post :create, {:mapping => valid_attributes}, valid_session post :create, { mapping: valid_attributes }, valid_session
}.to change(Mapping, :count).by(1) end.to change(Mapping, :count).by(1)
end end
it "assigns a newly created mapping as @mapping" do it 'assigns a newly created mapping as @mapping' do
post :create, {:mapping => valid_attributes}, valid_session post :create, { mapping: valid_attributes }, valid_session
expect(assigns(:mapping)).to be_a(Mapping) expect(assigns(:mapping)).to be_a(Mapping)
expect(assigns(:mapping)).to be_persisted expect(assigns(:mapping)).to be_persisted
end end
it "redirects to the created mapping" do it 'redirects to the created mapping' do
post :create, {:mapping => valid_attributes}, valid_session post :create, { mapping: valid_attributes }, valid_session
expect(response).to redirect_to(Mapping.last) expect(response).to redirect_to(Mapping.last)
end end
end end
context "with invalid params" do context 'with invalid params' do
it "assigns a newly created but unsaved mapping as @mapping" do it 'assigns a newly created but unsaved mapping as @mapping' do
post :create, {:mapping => invalid_attributes}, valid_session post :create, { mapping: invalid_attributes }, valid_session
expect(assigns(:mapping)).to be_a_new(Mapping) expect(assigns(:mapping)).to be_a_new(Mapping)
end end
it "re-renders the 'new' template" do it "re-renders the 'new' template" do
post :create, {:mapping => invalid_attributes}, valid_session post :create, { mapping: invalid_attributes }, valid_session
expect(response).to render_template("new") expect(response).to render_template('new')
end end
end end
end end
describe "PUT #update" do describe 'PUT #update' do
context "with valid params" do context 'with valid params' do
let(:new_attributes) { let(:new_attributes) do
skip("Add a hash of attributes valid for your model") 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")
end end
it "assigns the requested mapping as @mapping" do it 'updates the requested mapping' do
mapping = Mapping.create! valid_attributes 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) expect(assigns(:mapping)).to eq(mapping)
end end
it "redirects to the mapping" do it 'redirects to the mapping' do
mapping = Mapping.create! valid_attributes 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) expect(response).to redirect_to(mapping)
end end
end end
context "with invalid params" do context 'with invalid params' do
it "assigns the mapping as @mapping" do it 'assigns the mapping as @mapping' do
mapping = Mapping.create! valid_attributes 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) expect(assigns(:mapping)).to eq(mapping)
end end
it "re-renders the 'edit' template" do it "re-renders the 'edit' template" do
mapping = Mapping.create! valid_attributes 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(response).to render_template("edit") expect(response).to render_template('edit')
end end
end end
end end
describe "DELETE #destroy" do describe 'DELETE #destroy' do
it "destroys the requested mapping" do it 'destroys the requested mapping' do
mapping = Mapping.create! valid_attributes mapping = Mapping.create! valid_attributes
expect { expect do
delete :destroy, {:id => mapping.to_param}, valid_session delete :destroy, { id: mapping.to_param }, valid_session
}.to change(Mapping, :count).by(-1) end.to change(Mapping, :count).by(-1)
end end
it "redirects to the mappings list" do it 'redirects to the mappings list' do
mapping = Mapping.create! valid_attributes 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) expect(response).to redirect_to(mappings_url)
end end
end end
end end

View file

@ -18,135 +18,133 @@ require 'rails_helper'
# Message expectations are only used when there is no simpler way to specify # Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message. # 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 # This should return the minimal set of attributes required to create a valid
# Map. As you add validations to Map, be sure to # Map. As you add validations to Map, be sure to
# adjust the attributes here as well. # adjust the attributes here as well.
let(:valid_attributes) { let(:valid_attributes) do
skip("Add a hash of attributes valid for your model") skip('Add a hash of attributes valid for your model')
} end
let(:invalid_attributes) { let(:invalid_attributes) do
skip("Add a hash of attributes invalid for your model") 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 # 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 # in order to pass any filters (e.g. authentication) defined in
# MapsController. Be sure to keep this updated too. # MapsController. Be sure to keep this updated too.
let(:valid_session) { {} } let(:valid_session) { {} }
describe "GET #index" do describe 'GET #index' do
it "assigns all maps as @maps" do it 'assigns all maps as @maps' do
map = Map.create! valid_attributes map = Map.create! valid_attributes
get :index, {}, valid_session get :index, {}, valid_session
expect(assigns(:maps)).to eq([map]) expect(assigns(:maps)).to eq([map])
end end
end end
describe "GET #show" do describe 'GET #show' do
it "assigns the requested map as @map" do it 'assigns the requested map as @map' do
map = Map.create! valid_attributes 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) expect(assigns(:map)).to eq(map)
end end
end end
describe "GET #edit" do describe 'GET #edit' do
it "assigns the requested map as @map" do it 'assigns the requested map as @map' do
map = Map.create! valid_attributes 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) expect(assigns(:map)).to eq(map)
end end
end end
describe "POST #create" do describe 'POST #create' do
context "with valid params" do context 'with valid params' do
it "creates a new Map" do it 'creates a new Map' do
expect { expect do
post :create, {:map => valid_attributes}, valid_session post :create, { map: valid_attributes }, valid_session
}.to change(Map, :count).by(1) end.to change(Map, :count).by(1)
end end
it "assigns a newly created map as @map" do it 'assigns a newly created map as @map' do
post :create, {:map => valid_attributes}, valid_session post :create, { map: valid_attributes }, valid_session
expect(assigns(:map)).to be_a(Map) expect(assigns(:map)).to be_a(Map)
expect(assigns(:map)).to be_persisted expect(assigns(:map)).to be_persisted
end end
it "redirects to the created map" do it 'redirects to the created map' do
post :create, {:map => valid_attributes}, valid_session post :create, { map: valid_attributes }, valid_session
expect(response).to redirect_to(Map.last) expect(response).to redirect_to(Map.last)
end end
end end
context "with invalid params" do context 'with invalid params' do
it "assigns a newly created but unsaved map as @map" do it 'assigns a newly created but unsaved map as @map' do
post :create, {:map => invalid_attributes}, valid_session post :create, { map: invalid_attributes }, valid_session
expect(assigns(:map)).to be_a_new(Map) expect(assigns(:map)).to be_a_new(Map)
end end
it "re-renders the 'new' template" do it "re-renders the 'new' template" do
post :create, {:map => invalid_attributes}, valid_session post :create, { map: invalid_attributes }, valid_session
expect(response).to render_template("new") expect(response).to render_template('new')
end end
end end
end end
describe "PUT #update" do describe 'PUT #update' do
context "with valid params" do context 'with valid params' do
let(:new_attributes) { let(:new_attributes) do
skip("Add a hash of attributes valid for your model") 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")
end end
it "assigns the requested map as @map" do it 'updates the requested map' do
map = Map.create! valid_attributes 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) expect(assigns(:map)).to eq(map)
end end
it "redirects to the map" do it 'redirects to the map' do
map = Map.create! valid_attributes 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) expect(response).to redirect_to(map)
end end
end end
context "with invalid params" do context 'with invalid params' do
it "assigns the map as @map" do it 'assigns the map as @map' do
map = Map.create! valid_attributes 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) expect(assigns(:map)).to eq(map)
end end
it "re-renders the 'edit' template" do it "re-renders the 'edit' template" do
map = Map.create! valid_attributes 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(response).to render_template("edit") expect(response).to render_template('edit')
end end
end end
end end
describe "DELETE #destroy" do describe 'DELETE #destroy' do
it "destroys the requested map" do it 'destroys the requested map' do
map = Map.create! valid_attributes map = Map.create! valid_attributes
expect { expect do
delete :destroy, {:id => map.to_param}, valid_session delete :destroy, { id: map.to_param }, valid_session
}.to change(Map, :count).by(-1) end.to change(Map, :count).by(-1)
end end
it "redirects to the maps list" do it 'redirects to the maps list' do
map = Map.create! valid_attributes 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) expect(response).to redirect_to(maps_url)
end end
end end
end end

View file

@ -18,7 +18,7 @@ require 'rails_helper'
# Message expectations are only used when there is no simpler way to specify # Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message. # that an instance is receiving a specific message.
RSpec.describe MetacodesController, :type => :controller do RSpec.describe MetacodesController, type: :controller do
before :each do before :each do
@user = create(:user, admin: true) @user = create(:user, admin: true)
sign_in @user 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 # This should return the minimal set of attributes required to create a valid
# Metacode. As you add validations to Metacode, be sure to # Metacode. As you add validations to Metacode, be sure to
# adjust the attributes here as well. # adjust the attributes here as well.
let(:valid_attributes) { let(:valid_attributes) do
skip("Add a hash of attributes valid for your model") skip('Add a hash of attributes valid for your model')
} end
let(:invalid_attributes) { let(:invalid_attributes) do
skip("Add a hash of attributes invalid for your model") 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 # 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 # in order to pass any filters (e.g. authentication) defined in
# MetacodesController. Be sure to keep this updated too. # MetacodesController. Be sure to keep this updated too.
let(:valid_session) { {} } let(:valid_session) { {} }
describe "GET #index" do describe 'GET #index' do
it "assigns all metacodes as @metacodes" do it 'assigns all metacodes as @metacodes' do
metacode = Metacode.create! valid_attributes metacode = Metacode.create! valid_attributes
get :index, {}, valid_session get :index, {}, valid_session
expect(assigns(:metacodes)).to eq([metacode]) expect(assigns(:metacodes)).to eq([metacode])
end end
end end
describe "GET #show" do describe 'GET #show' do
it "assigns the requested metacode as @metacode" do it 'assigns the requested metacode as @metacode' do
metacode = Metacode.create! valid_attributes 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) expect(assigns(:metacode)).to eq(metacode)
end end
end end
describe "GET #new" do describe 'GET #new' do
it "assigns a new metacode as @metacode" do it 'assigns a new metacode as @metacode' do
get :new, {}, valid_session get :new, {}, valid_session
expect(assigns(:metacode)).to be_a_new(Metacode) expect(assigns(:metacode)).to be_a_new(Metacode)
end end
end end
describe "GET #edit" do describe 'GET #edit' do
it "assigns the requested metacode as @metacode" do it 'assigns the requested metacode as @metacode' do
metacode = Metacode.create! valid_attributes 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) expect(assigns(:metacode)).to eq(metacode)
end end
end end
describe "POST #create" do describe 'POST #create' do
context "with valid params" do context 'with valid params' do
it "creates a new Metacode" do it 'creates a new Metacode' do
expect { expect do
post :create, {:metacode => valid_attributes}, valid_session post :create, { metacode: valid_attributes }, valid_session
}.to change(Metacode, :count).by(1) end.to change(Metacode, :count).by(1)
end end
it "assigns a newly created metacode as @metacode" do it 'assigns a newly created metacode as @metacode' do
post :create, {:metacode => valid_attributes}, valid_session post :create, { metacode: valid_attributes }, valid_session
expect(assigns(:metacode)).to be_a(Metacode) expect(assigns(:metacode)).to be_a(Metacode)
expect(assigns(:metacode)).to be_persisted expect(assigns(:metacode)).to be_persisted
end end
it "redirects to the created metacode" do it 'redirects to the created metacode' do
post :create, {:metacode => valid_attributes}, valid_session post :create, { metacode: valid_attributes }, valid_session
expect(response).to redirect_to(Metacode.last) expect(response).to redirect_to(Metacode.last)
end end
end end
context "with invalid params" do context 'with invalid params' do
it "assigns a newly created but unsaved metacode as @metacode" do it 'assigns a newly created but unsaved metacode as @metacode' do
post :create, {:metacode => invalid_attributes}, valid_session post :create, { metacode: invalid_attributes }, valid_session
expect(assigns(:metacode)).to be_a_new(Metacode) expect(assigns(:metacode)).to be_a_new(Metacode)
end end
it "re-renders the 'new' template" do it "re-renders the 'new' template" do
post :create, {:metacode => invalid_attributes}, valid_session post :create, { metacode: invalid_attributes }, valid_session
expect(response).to render_template("new") expect(response).to render_template('new')
end end
end end
end end
describe "PUT #update" do describe 'PUT #update' do
context "with valid params" do context 'with valid params' do
let(:new_attributes) { let(:new_attributes) do
skip("Add a hash of attributes valid for your model") 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")
end end
it "assigns the requested metacode as @metacode" do it 'updates the requested metacode' do
metacode = Metacode.create! valid_attributes 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) expect(assigns(:metacode)).to eq(metacode)
end end
it "redirects to the metacode" do it 'redirects to the metacode' do
metacode = Metacode.create! valid_attributes 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) expect(response).to redirect_to(metacode)
end end
end end
context "with invalid params" do context 'with invalid params' do
it "assigns the metacode as @metacode" do it 'assigns the metacode as @metacode' do
metacode = Metacode.create! valid_attributes 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) expect(assigns(:metacode)).to eq(metacode)
end end
it "re-renders the 'edit' template" do it "re-renders the 'edit' template" do
metacode = Metacode.create! valid_attributes 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(response).to render_template("edit") expect(response).to render_template('edit')
end end
end end
end end
describe "DELETE #destroy" do describe 'DELETE #destroy' do
it "destroys the requested metacode" do it 'destroys the requested metacode' do
metacode = Metacode.create! valid_attributes metacode = Metacode.create! valid_attributes
expect { expect do
delete :destroy, {:id => metacode.to_param}, valid_session delete :destroy, { id: metacode.to_param }, valid_session
}.to change(Metacode, :count).by(-1) end.to change(Metacode, :count).by(-1)
end end
it "redirects to the metacodes list" do it 'redirects to the metacodes list' do
metacode = Metacode.create! valid_attributes 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) expect(response).to redirect_to(metacodes_url)
end end
end end
end end

View file

@ -18,135 +18,133 @@ require 'rails_helper'
# Message expectations are only used when there is no simpler way to specify # Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message. # 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 # This should return the minimal set of attributes required to create a valid
# Synapse. As you add validations to Synapse, be sure to # Synapse. As you add validations to Synapse, be sure to
# adjust the attributes here as well. # adjust the attributes here as well.
let(:valid_attributes) { let(:valid_attributes) do
skip("Add a hash of attributes valid for your model") skip('Add a hash of attributes valid for your model')
} end
let(:invalid_attributes) { let(:invalid_attributes) do
skip("Add a hash of attributes invalid for your model") 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 # 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 # in order to pass any filters (e.g. authentication) defined in
# SynapsesController. Be sure to keep this updated too. # SynapsesController. Be sure to keep this updated too.
let(:valid_session) { {} } let(:valid_session) { {} }
describe "GET #index" do describe 'GET #index' do
it "assigns all synapses as @synapses" do it 'assigns all synapses as @synapses' do
synapse = Synapse.create! valid_attributes synapse = Synapse.create! valid_attributes
get :index, {}, valid_session get :index, {}, valid_session
expect(assigns(:synapses)).to eq([synapse]) expect(assigns(:synapses)).to eq([synapse])
end end
end end
describe "GET #show" do describe 'GET #show' do
it "assigns the requested synapse as @synapse" do it 'assigns the requested synapse as @synapse' do
synapse = Synapse.create! valid_attributes 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) expect(assigns(:synapse)).to eq(synapse)
end end
end end
describe "GET #edit" do describe 'GET #edit' do
it "assigns the requested synapse as @synapse" do it 'assigns the requested synapse as @synapse' do
synapse = Synapse.create! valid_attributes 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) expect(assigns(:synapse)).to eq(synapse)
end end
end end
describe "POST #create" do describe 'POST #create' do
context "with valid params" do context 'with valid params' do
it "creates a new Synapse" do it 'creates a new Synapse' do
expect { expect do
post :create, {:synapse => valid_attributes}, valid_session post :create, { synapse: valid_attributes }, valid_session
}.to change(Synapse, :count).by(1) end.to change(Synapse, :count).by(1)
end end
it "assigns a newly created synapse as @synapse" do it 'assigns a newly created synapse as @synapse' do
post :create, {:synapse => valid_attributes}, valid_session post :create, { synapse: valid_attributes }, valid_session
expect(assigns(:synapse)).to be_a(Synapse) expect(assigns(:synapse)).to be_a(Synapse)
expect(assigns(:synapse)).to be_persisted expect(assigns(:synapse)).to be_persisted
end end
it "redirects to the created synapse" do it 'redirects to the created synapse' do
post :create, {:synapse => valid_attributes}, valid_session post :create, { synapse: valid_attributes }, valid_session
expect(response).to redirect_to(Synapse.last) expect(response).to redirect_to(Synapse.last)
end end
end end
context "with invalid params" do context 'with invalid params' do
it "assigns a newly created but unsaved synapse as @synapse" do it 'assigns a newly created but unsaved synapse as @synapse' do
post :create, {:synapse => invalid_attributes}, valid_session post :create, { synapse: invalid_attributes }, valid_session
expect(assigns(:synapse)).to be_a_new(Synapse) expect(assigns(:synapse)).to be_a_new(Synapse)
end end
it "re-renders the 'new' template" do it "re-renders the 'new' template" do
post :create, {:synapse => invalid_attributes}, valid_session post :create, { synapse: invalid_attributes }, valid_session
expect(response).to render_template("new") expect(response).to render_template('new')
end end
end end
end end
describe "PUT #update" do describe 'PUT #update' do
context "with valid params" do context 'with valid params' do
let(:new_attributes) { let(:new_attributes) do
skip("Add a hash of attributes valid for your model") 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")
end end
it "assigns the requested synapse as @synapse" do it 'updates the requested synapse' do
synapse = Synapse.create! valid_attributes 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) expect(assigns(:synapse)).to eq(synapse)
end end
it "redirects to the synapse" do it 'redirects to the synapse' do
synapse = Synapse.create! valid_attributes 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) expect(response).to redirect_to(synapse)
end end
end end
context "with invalid params" do context 'with invalid params' do
it "assigns the synapse as @synapse" do it 'assigns the synapse as @synapse' do
synapse = Synapse.create! valid_attributes 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) expect(assigns(:synapse)).to eq(synapse)
end end
it "re-renders the 'edit' template" do it "re-renders the 'edit' template" do
synapse = Synapse.create! valid_attributes 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(response).to render_template("edit") expect(response).to render_template('edit')
end end
end end
end end
describe "DELETE #destroy" do describe 'DELETE #destroy' do
it "destroys the requested synapse" do it 'destroys the requested synapse' do
synapse = Synapse.create! valid_attributes synapse = Synapse.create! valid_attributes
expect { expect do
delete :destroy, {:id => synapse.to_param}, valid_session delete :destroy, { id: synapse.to_param }, valid_session
}.to change(Synapse, :count).by(-1) end.to change(Synapse, :count).by(-1)
end end
it "redirects to the synapses list" do it 'redirects to the synapses list' do
synapse = Synapse.create! valid_attributes 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) expect(response).to redirect_to(synapses_url)
end end
end end
end end

View file

@ -18,135 +18,133 @@ require 'rails_helper'
# Message expectations are only used when there is no simpler way to specify # Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message. # 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 # This should return the minimal set of attributes required to create a valid
# Topic. As you add validations to Topic, be sure to # Topic. As you add validations to Topic, be sure to
# adjust the attributes here as well. # adjust the attributes here as well.
let(:valid_attributes) { let(:valid_attributes) do
skip("Add a hash of attributes valid for your model") skip('Add a hash of attributes valid for your model')
} end
let(:invalid_attributes) { let(:invalid_attributes) do
skip("Add a hash of attributes invalid for your model") 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 # 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 # in order to pass any filters (e.g. authentication) defined in
# TopicsController. Be sure to keep this updated too. # TopicsController. Be sure to keep this updated too.
let(:valid_session) { {} } let(:valid_session) { {} }
describe "GET #index" do describe 'GET #index' do
it "assigns all topics as @topics" do it 'assigns all topics as @topics' do
topic = Topic.create! valid_attributes topic = Topic.create! valid_attributes
get :index, {}, valid_session get :index, {}, valid_session
expect(assigns(:topics)).to eq([topic]) expect(assigns(:topics)).to eq([topic])
end end
end end
describe "GET #show" do describe 'GET #show' do
it "assigns the requested topic as @topic" do it 'assigns the requested topic as @topic' do
topic = Topic.create! valid_attributes 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) expect(assigns(:topic)).to eq(topic)
end end
end end
describe "GET #edit" do describe 'GET #edit' do
it "assigns the requested topic as @topic" do it 'assigns the requested topic as @topic' do
topic = Topic.create! valid_attributes 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) expect(assigns(:topic)).to eq(topic)
end end
end end
describe "POST #create" do describe 'POST #create' do
context "with valid params" do context 'with valid params' do
it "creates a new Topic" do it 'creates a new Topic' do
expect { expect do
post :create, {:topic => valid_attributes}, valid_session post :create, { topic: valid_attributes }, valid_session
}.to change(Topic, :count).by(1) end.to change(Topic, :count).by(1)
end end
it "assigns a newly created topic as @topic" do it 'assigns a newly created topic as @topic' do
post :create, {:topic => valid_attributes}, valid_session post :create, { topic: valid_attributes }, valid_session
expect(assigns(:topic)).to be_a(Topic) expect(assigns(:topic)).to be_a(Topic)
expect(assigns(:topic)).to be_persisted expect(assigns(:topic)).to be_persisted
end end
it "redirects to the created topic" do it 'redirects to the created topic' do
post :create, {:topic => valid_attributes}, valid_session post :create, { topic: valid_attributes }, valid_session
expect(response).to redirect_to(Topic.last) expect(response).to redirect_to(Topic.last)
end end
end end
context "with invalid params" do context 'with invalid params' do
it "assigns a newly created but unsaved topic as @topic" do it 'assigns a newly created but unsaved topic as @topic' do
post :create, {:topic => invalid_attributes}, valid_session post :create, { topic: invalid_attributes }, valid_session
expect(assigns(:topic)).to be_a_new(Topic) expect(assigns(:topic)).to be_a_new(Topic)
end end
it "re-renders the 'new' template" do it "re-renders the 'new' template" do
post :create, {:topic => invalid_attributes}, valid_session post :create, { topic: invalid_attributes }, valid_session
expect(response).to render_template("new") expect(response).to render_template('new')
end end
end end
end end
describe "PUT #update" do describe 'PUT #update' do
context "with valid params" do context 'with valid params' do
let(:new_attributes) { let(:new_attributes) do
skip("Add a hash of attributes valid for your model") 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")
end end
it "assigns the requested topic as @topic" do it 'updates the requested topic' do
topic = Topic.create! valid_attributes 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) expect(assigns(:topic)).to eq(topic)
end end
it "redirects to the topic" do it 'redirects to the topic' do
topic = Topic.create! valid_attributes 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) expect(response).to redirect_to(topic)
end end
end end
context "with invalid params" do context 'with invalid params' do
it "assigns the topic as @topic" do it 'assigns the topic as @topic' do
topic = Topic.create! valid_attributes 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) expect(assigns(:topic)).to eq(topic)
end end
it "re-renders the 'edit' template" do it "re-renders the 'edit' template" do
topic = Topic.create! valid_attributes 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(response).to render_template("edit") expect(response).to render_template('edit')
end end
end end
end end
describe "DELETE #destroy" do describe 'DELETE #destroy' do
it "destroys the requested topic" do it 'destroys the requested topic' do
topic = Topic.create! valid_attributes topic = Topic.create! valid_attributes
expect { expect do
delete :destroy, {:id => topic.to_param}, valid_session delete :destroy, { id: topic.to_param }, valid_session
}.to change(Topic, :count).by(-1) end.to change(Topic, :count).by(-1)
end end
it "redirects to the topics list" do it 'redirects to the topics list' do
topic = Topic.create! valid_attributes 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) expect(response).to redirect_to(topics_url)
end end
end end
end end

View file

@ -2,8 +2,8 @@ FactoryGirl.define do
factory :synapse do factory :synapse do
desc { random_string(10) } desc { random_string(10) }
category :to category :to
permission :commons permission :commons
association :node1, factory: :topic association :node1, factory: :topic
association :node2, factory: :topic association :node2, factory: :topic
end end
end end

View file

@ -5,6 +5,6 @@ FactoryGirl.define do
code { random_string(8) } code { random_string(8) }
joinedwithcode { code } joinedwithcode { code }
password 'omgwtfbbq' 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
end end

View file

@ -1,5 +1,5 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Map, :type => :model do RSpec.describe Map, type: :model do
pending "add some examples to (or delete) #{__FILE__}" pending "add some examples to (or delete) #{__FILE__}"
end end

View file

@ -1,5 +1,5 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Mapping, :type => :model do RSpec.describe Mapping, type: :model do
pending "add some examples to (or delete) #{__FILE__}" pending "add some examples to (or delete) #{__FILE__}"
end end

View file

@ -1,5 +1,5 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Metacode, :type => :model do RSpec.describe Metacode, type: :model do
pending "add some examples to (or delete) #{__FILE__}" pending "add some examples to (or delete) #{__FILE__}"
end end

View file

@ -1,5 +1,5 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Synapse, :type => :model do RSpec.describe Synapse, type: :model do
pending "add some examples to (or delete) #{__FILE__}" pending "add some examples to (or delete) #{__FILE__}"
end end

View file

@ -1,5 +1,5 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Topic, :type => :model do RSpec.describe Topic, type: :model do
pending "add some examples to (or delete) #{__FILE__}" pending "add some examples to (or delete) #{__FILE__}"
end end

View file

@ -2,7 +2,7 @@
ENV['RAILS_ENV'] ||= 'test' ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__) require File.expand_path('../../config/environment', __FILE__)
# Prevent database truncation if the environment is production # 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 'spec_helper'
require 'rspec/rails' require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point! # Add additional requires below this line. Rails is not loaded until this point!

View file

@ -1,23 +1,21 @@
require "rails_helper" require 'rails_helper'
RSpec.describe MappingsController, :type => :routing do RSpec.describe MappingsController, type: :routing do
describe "routing" do describe 'routing' do
it 'routes to #show' do
it "routes to #show" do expect(get: '/mappings/1').to route_to('mappings#show', id: '1')
expect(:get => "/mappings/1").to route_to("mappings#show", :id => "1")
end end
it "routes to #create" do it 'routes to #create' do
expect(:post => "/mappings").to route_to("mappings#create") expect(post: '/mappings').to route_to('mappings#create')
end end
it "routes to #update via PUT" do it 'routes to #update via PUT' do
expect(:put => "/mappings/1").to route_to("mappings#update", :id => "1") expect(put: '/mappings/1').to route_to('mappings#update', id: '1')
end end
it "routes to #destroy" do it 'routes to #destroy' do
expect(:delete => "/mappings/1").to route_to("mappings#destroy", :id => "1") expect(delete: '/mappings/1').to route_to('mappings#destroy', id: '1')
end end
end end
end end

View file

@ -1,27 +1,25 @@
require "rails_helper" require 'rails_helper'
RSpec.describe MapsController, :type => :routing do RSpec.describe MapsController, type: :routing do
describe "routing" do describe 'routing' do
it 'routes to #index' do
it "routes to #index" do expect(get: '/maps').to route_to('maps#index')
expect(:get => "/maps").to route_to("maps#index")
end end
it "routes to #show" do it 'routes to #show' do
expect(:get => "/maps/1").to route_to("maps#show", :id => "1") expect(get: '/maps/1').to route_to('maps#show', id: '1')
end end
it "routes to #create" do it 'routes to #create' do
expect(:post => "/maps").to route_to("maps#create") expect(post: '/maps').to route_to('maps#create')
end end
it "routes to #update via PUT" do it 'routes to #update via PUT' do
expect(:put => "/maps/1").to route_to("maps#update", :id => "1") expect(put: '/maps/1').to route_to('maps#update', id: '1')
end end
it "routes to #destroy" do it 'routes to #destroy' do
expect(:delete => "/maps/1").to route_to("maps#destroy", :id => "1") expect(delete: '/maps/1').to route_to('maps#destroy', id: '1')
end end
end end
end end

View file

@ -1,30 +1,29 @@
require "rails_helper" require 'rails_helper'
RSpec.describe MetacodesController, :type => :routing do RSpec.describe MetacodesController, type: :routing do
describe "routing" do describe 'routing' do
it 'routes to #index' do
it "routes to #index" do expect(get: '/metacodes').to route_to('metacodes#index')
expect(:get => "/metacodes").to route_to("metacodes#index")
end end
it "routes to #new" do it 'routes to #new' do
expect(:get => "/metacodes/new").to route_to("metacodes#new") expect(get: '/metacodes/new').to route_to('metacodes#new')
end end
it "routes to #edit" do it 'routes to #edit' do
expect(:get => "/metacodes/1/edit").to route_to("metacodes#edit", :id => "1") expect(get: '/metacodes/1/edit').to route_to('metacodes#edit', id: '1')
end end
it "routes to #create" do it 'routes to #create' do
expect(:post => "/metacodes").to route_to("metacodes#create") expect(post: '/metacodes').to route_to('metacodes#create')
end end
it "routes to #update via PUT" do it 'routes to #update via PUT' do
expect(:put => "/metacodes/1").to route_to("metacodes#update", :id => "1") expect(put: '/metacodes/1').to route_to('metacodes#update', id: '1')
end end
#it "routes to #destroy" do # it "routes to #destroy" do
# expect(:delete => "/metacodes/1").to route_to("metacodes#destroy", :id => "1") # expect(:delete => "/metacodes/1").to route_to("metacodes#destroy", :id => "1")
#end # end
end end
end end

View file

@ -1,23 +1,21 @@
require "rails_helper" require 'rails_helper'
RSpec.describe SynapsesController, :type => :routing do RSpec.describe SynapsesController, type: :routing do
describe "routing" do describe 'routing' do
it 'routes to #show' do
it "routes to #show" do expect(get: '/synapses/1').to route_to('synapses#show', id: '1')
expect(:get => "/synapses/1").to route_to("synapses#show", :id => "1")
end end
it "routes to #create" do it 'routes to #create' do
expect(:post => "/synapses").to route_to("synapses#create") expect(post: '/synapses').to route_to('synapses#create')
end end
it "routes to #update via PUT" do it 'routes to #update via PUT' do
expect(:put => "/synapses/1").to route_to("synapses#update", :id => "1") expect(put: '/synapses/1').to route_to('synapses#update', id: '1')
end end
it "routes to #destroy" do it 'routes to #destroy' do
expect(:delete => "/synapses/1").to route_to("synapses#destroy", :id => "1") expect(delete: '/synapses/1').to route_to('synapses#destroy', id: '1')
end end
end end
end end

View file

@ -1,23 +1,21 @@
require "rails_helper" require 'rails_helper'
RSpec.describe TopicsController, :type => :routing do RSpec.describe TopicsController, type: :routing do
describe "routing" do describe 'routing' do
it 'routes to #show' do
it "routes to #show" do expect(get: '/topics/1').to route_to('topics#show', id: '1')
expect(:get => "/topics/1").to route_to("topics#show", :id => "1")
end end
it "routes to #create" do it 'routes to #create' do
expect(:post => "/topics").to route_to("topics#create") expect(post: '/topics').to route_to('topics#create')
end end
it "routes to #update via PUT" do it 'routes to #update via PUT' do
expect(:put => "/topics/1").to route_to("topics#update", :id => "1") expect(put: '/topics/1').to route_to('topics#update', id: '1')
end end
it "routes to #destroy" do it 'routes to #destroy' do
expect(:delete => "/topics/1").to route_to("topics#destroy", :id => "1") expect(delete: '/topics/1').to route_to('topics#destroy', id: '1')
end end
end end
end end

View file

@ -41,58 +41,56 @@ RSpec.configure do |config|
mocks.verify_partial_doubles = true mocks.verify_partial_doubles = true
end end
# The settings below are suggested to provide a good initial experience # The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content. # 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
# 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
# to individual examples or groups you care about by tagging them with # # `:focus` metadata. When nothing is tagged with `:focus`, all examples
# `:focus` metadata. When nothing is tagged with `:focus`, all examples # # get run.
# get run. # config.filter_run :focus
config.filter_run :focus # config.run_all_when_everything_filtered = true
config.run_all_when_everything_filtered = true #
# # Allows RSpec to persist some state between runs in order to support
# Allows RSpec to persist some state between runs in order to support # # the `--only-failures` and `--next-failure` CLI options. We recommend
# the `--only-failures` and `--next-failure` CLI options. We recommend # # you configure your source control system to ignore this file.
# you configure your source control system to ignore this file. # config.example_status_persistence_file_path = "spec/examples.txt"
config.example_status_persistence_file_path = "spec/examples.txt" #
# # Limits the available syntax to the non-monkey patched syntax that is
# Limits the available syntax to the non-monkey patched syntax that is # # recommended. For more details, see:
# recommended. For more details, see: # # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
# - 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://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
# - 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!
config.disable_monkey_patching! #
# # Many RSpec users commonly either run the entire suite or an individual
# 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
# file, and it's useful to allow more verbose output when running an # # individual spec file.
# individual spec file. # if config.files_to_run.one?
if config.files_to_run.one? # # Use the documentation formatter for detailed output,
# Use the documentation formatter for detailed output, # # unless a formatter has already been configured
# unless a formatter has already been configured # # (e.g. via a command-line flag).
# (e.g. via a command-line flag). # config.default_formatter = 'doc'
config.default_formatter = 'doc' # end
end #
# # Print the 10 slowest examples and example groups at the
# Print the 10 slowest examples and example groups at the # # end of the spec run, to help surface which specs are running
# end of the spec run, to help surface which specs are running # # particularly slow.
# particularly slow. # config.profile_examples = 10
config.profile_examples = 10 #
# # Run specs in random order to surface order dependencies. If you find an
# 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
# order dependency and want to debug it, you can fix the order by providing # # the seed, which is printed after each run.
# the seed, which is printed after each run. # # --seed 1234
# --seed 1234 # config.order = :random
config.order = :random #
# # Seed global randomization in this process using the `--seed` CLI option.
# Seed global randomization in this process using the `--seed` CLI option. # # Setting this allows you to use `--seed` to deterministically reproduce
# Setting this allows you to use `--seed` to deterministically reproduce # # test failures related to randomization by passing the same `--seed` value
# test failures related to randomization by passing the same `--seed` value # # as the one that triggered the failure.
# as the one that triggered the failure. # Kernel.srand config.seed
Kernel.srand config.seed
=end
end end
def random_string(length = 10) 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 string = (0...length).map { o[rand(o.length)] }.join
end end

View file

@ -3,7 +3,7 @@ module ControllerHelpers
def sign_in(user = create(:user)) def sign_in(user = create(:user))
if user.nil? if user.nil?
# simulate unauthenticated # 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) allow(controller).to receive(:current_user).and_return(nil)
else else
# simulate authenticated # simulate authenticated

View file

@ -1,4 +1,4 @@
# lets you type create(:user) instead of FactoryGirl.create(:user) # lets you type create(:user) instead of FactoryGirl.create(:user)
RSpec.configure do |config| RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods config.include FactoryGirl::Syntax::Methods
end end