Sha256: c3ce02ee77e1050f9573523b726f20b6385644da163779d3dda39266459c1d12

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

###
# Shared examples for FollowSystem::Followee
###
shared_examples_for FollowSystem::Followee do
  ###
  # Let followee be DummyFollowee.create
  ###
  let(:followee) { DummyFollowee.create }

  ###
  # Let follower be DummyFollower.create
  ###
  let(:follower) { DummyFollower.create }

  ###
  # Describes associations
  ###
  describe "associations" do
    ###
    # Should have many followers
    ###
    it "should have many followers" do
      should have_many(:followers)
    end
  end

  ###
  # Describes class methods
  ###
  describe "class methods" do
    ###
    # Should be a followee
    ###
    it "should be a followee" do
      expect(followee.is_followee?).to equal(true)
    end

    ###
    # Should be followed by a follower
    ###
    it "should specify if is followed by a follower" do
      expect(FollowSystem::Follow).to receive(:follows?).with(follower, followee) { true }

      expect(followee.followed_by?(follower)).to equal(true)
    end

    ###
    # Should scope followers filtered by follower type
    ###
    it "should scope followers filtered by follower type" do
      scope = FollowSystem::Follow.scope_by_followee(followee).scope_by_follower_type(DummyFollower)

      expect(followee.followers_by(DummyFollower)).to eq(scope)
    end
  end
end

###
# Describes DummyFollowee
###
describe DummyFollowee, type: :model do
  ###
  # It behaves like FollowSystem::Followee
  ###
  it_behaves_like FollowSystem::Followee
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
follow_system-0.1.1 spec/follow_system/followee_spec.rb
follow_system-0.1.0 spec/follow_system/followee_spec.rb
follow_system-0.0.9 spec/follow_system/followee_spec.rb
follow_system-0.0.8 spec/follow_system/followee_spec.rb