Sha256: f5499ac433c9ceab26e01cff74ece7c1ddeb1a275133a799664f4b295e2081f4

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 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 do
  ###
  # It behaves like FollowSystem::Followee
  ###
  it_behaves_like FollowSystem::Followee
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
follow_system-0.0.7 spec/follow_system/followee_spec.rb
follow_system-0.0.6 spec/follow_system/followee_spec.rb