Sha256: 68a36d9d78f6bef974344d225eddce53e6a3824f0f53f7629f88da5f446e42e2

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

require 'activity_feed'
require 'timecop'
require 'database_cleaner'
require 'support/mongoid'
require 'support/active_record'

RSpec.configure do |config|
  config.mock_with :rspec
  
  config.before(:all) do
    DatabaseCleaner.strategy = :truncation
    DatabaseCleaner.clean_with(:truncation)
  end

  config.before(:each) do
    DatabaseCleaner.start
    DatabaseCleaner.clean

    ActivityFeed.configure do |configuration|
      configuration.item_loader = nil
      configuration.redis = Redis.new(:db => 15)
    end

    ActivityFeed.redis.flushdb
  end

  config.after(:each) do
    DatabaseCleaner.clean    

    ActivityFeed.redis.quit
  end

  # Helper method to add items to a given feed.
  # 
  # @param items_to_add [int] Number of items to add to the feed.
  def add_items_to_feed(user_id, items_to_add = 5, aggregate = ActivityFeed.aggregate)
    1.upto(items_to_add) do |index|
      ActivityFeed.update_item(user_id, index, DateTime.now.to_i, aggregate)
      Timecop.travel(DateTime.now + 10)
    end

    Timecop.return
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activity_feed-2.2.2 spec/spec_helper.rb
activity_feed-2.2.0 spec/spec_helper.rb
activity_feed-2.1.0 spec/spec_helper.rb
activity_feed-2.0.0 spec/spec_helper.rb
activity_feed-2.0.0.rc1 spec/spec_helper.rb