Files
growstuff/spec/support/is_likeable.rb
Logan Gingerich 10a8df47a9 Factorygirl to factorybot - fixes #1413 (#1425)
* FactoryGirl Changed to FactoryBot

file fix

changes based on comments received

Bundle Update on 2017-10-29

style update to align hash literal

added package-lock

* indentation fixes with rubocop

* name added to contributors
2017-11-01 15:03:31 +00:00

25 lines
818 B
Ruby

shared_examples "it is likeable" do
before(:each) do
# Possibly a horrible hack.
# Will fail if factory name does not match the model name..
@likeable = FactoryBot.create(described_class.to_s.underscore.to_sym)
@member1 = FactoryBot.create(:member)
@member2 = FactoryBot.create(:member)
@like1 = FactoryBot.create(:like, member: @member1, likeable: @likeable)
@like2 = FactoryBot.create(:like, member: @member2, likeable: @likeable)
end
it "has many likes" do
expect(@likeable.likes.length).to eq 2
end
it 'has many members that likes it' do
expect(@likeable.members.length).to eq 2
end
it 'should destroy the like when it is destroyed' do
like_count = -1 * @likeable.likes.count
expect { @likeable.destroy }.to change(Like, :count).by like_count
end
end