Sha256: 720f2d87906e991e86853f6bfa67e7581ac42febe1f73d91227d1725b96d466b

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

shared_examples 'a friendship model' do

  describe 'custom data' do
    it 'allows for a one-to-one mapping between friendship and a friendship_profile' do
      friendship = custom_popular_model.befriend another_custom_popular_model

      expect( friendship.friendship_profile ).to_not be_nil
    end

    it 'model does not get created unless explicitly opted in' do
      friendship = popular_model.befriend another_popular_model

      expect( friendship.friendship_profile ).to be_nil
    end
  end

  it 'ensures the friend is not the same as the popular_model' do
    invalid_model = described_class.new(
      friend: popular_model,
      popular_model: popular_model
    )

    expect( invalid_model ).to_not be_valid
  end

  it 'validates presence of popular_model' do
    invalid_model = described_class.new friend: popular_model

    expect( invalid_model ).to_not be_valid
  end

  it 'validates presence of friend' do
    invalid_model = described_class.new popular_model: popular_model

    expect( invalid_model ).to_not be_valid
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
popular-0.7.1 spec/popular/friendship_model_spec.rb
popular-0.7.0 spec/popular/friendship_model_spec.rb