Sha256: 88ad617153142e0e60f418513806155e2f454dc8bf3ced8526c87d03ad461d4f

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'
require 'activity_engine'

describe ActivityEngine do
  class Cat < PersistenceLayer
    def initialize(name)
      super()
      @name = name
    end
    attr_reader :name
    def eat(food); food; end
  end
  Food = Struct.new(:name)

  describe '.register' do
    let(:cat) { Cat.new('Beautiful Steve') }
    let(:food) { Food.new('catsup') }
    let(:receiver) { ActivityEngine::Activity }

    it 'reports when the method is called' do
      ActivityEngine.register(Cat, :eat, receiver) do |config, context|
        config.subject = context
        config.activity_type = 'Cat#eat'
      end
      cat.eat(food)
      expect(receiver.last.subject).to eq(cat)
    end
  end

  describe '.extract_subject_id' do
    it 'with multi-values' do
      obj = double(to_key: ['a','b'] )
      expect(ActivityEngine.extract_subject_id(obj)).to eq('a:b')
    end
    it 'with single value' do
      obj = double(to_key: ['a'] )
      expect(ActivityEngine.extract_subject_id(obj)).to eq('a')
    end
    it 'with string' do
      obj = double(to_key: 'a' )
      expect(ActivityEngine.extract_subject_id(obj)).to eq('a')
    end
  end

  describe 'entry creation' do
    it 'creates an entry for a persisted object'
    it 'requires an object to be persisted'
    it 'extracts the requesting user from the context'
    it 'extracts the entry type from the context'
  end

  describe 'entry finder scopes' do
    it 'has a scope for finding based on the persisted object'
    it 'has a scope for finding based on a user'
    it 'has a scope for finding based on an entry type'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activity_engine-0.0.9 spec/lib/activity_engine_spec.rb
activity_engine-0.0.8 spec/lib/activity_engine_spec.rb
activity_engine-0.0.7 spec/lib/activity_engine_spec.rb
activity_engine-0.0.6 spec/lib/activity_engine_spec.rb
activity_engine-0.0.5 spec/lib/activity_engine_spec.rb