mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-24 09:43:24 -04:00
25 lines
823 B
Ruby
25 lines
823 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 = FactoryGirl.create(described_class.to_s.underscore.to_sym)
|
|
@member1 = FactoryGirl.create(:member)
|
|
@member2 = FactoryGirl.create(:member)
|
|
@like1 = FactoryGirl.create(:like, member: @member1, likeable: @likeable)
|
|
@like2 = FactoryGirl.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
|