Skip to content
Extraits de code Groupes Projets
Valider abf87889 rédigé par zaziemo's avatar zaziemo Validation de Dennis Schubert
Parcourir les fichiers

refactor test by using let instead of before block when creating instance variables

parent 9b3ff1a4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -7,25 +7,25 @@ require 'spec_helper'
describe AspectMembership, :type => :model do
describe '#before_destroy' do
before do
@aspect = alice.aspects.create(:name => "two")
@contact = alice.contact_for(bob.person)
let(:aspect) { alice.aspects.create(:name => "two") }
let(:contact) { alice.contact_for(bob.person) }
let(:am) { alice.aspects.where(:name => "generic").first.aspect_memberships.first }
@am = alice.aspects.where(:name => "generic").first.aspect_memberships.first
allow(@am).to receive(:user).and_return(alice)
before do
allow(am).to receive(:user).and_return(alice)
end
it 'calls disconnect if its the last aspect for the contact' do
expect(alice).to receive(:disconnect).with(@contact)
expect(alice).to receive(:disconnect).with(contact)
@am.destroy
am.destroy
end
it 'does not call disconnect if its not the last aspect for the contact' do
expect(alice).not_to receive(:disconnect)
alice.add_contact_to_aspect(@contact, @aspect)
@am.destroy
alice.add_contact_to_aspect(contact, aspect)
am.destroy
end
end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter