Sha256: 83d868b6084a334e026fdc3c75f13a24fa9528749a975503e881618d4e7014e9

Contents?: true

Size: 1.44 KB

Versions: 5

Compression:

Stored size: 1.44 KB

Contents

require 'rubygems'
require 'rspec'
require 'redis'
require 'mongo_mapper'
require 'database_cleaner'
require 'fabrication'
require 'json'

$redis = Redis.new(:host => '127.0.0.1', :port => 6379)

# TODO: Move to spec/mongo_mapper
MongoMapper.connection = Mongo::Connection.new('localhost', 27017)
MongoMapper.database = 'activity_feed_gem_test'

# TODO: Move to spec/active_record
require 'active_record'

ActiveRecord::Base.establish_connection(
  :adapter => "sqlite3",
  :database => ":memory:"
)

ActiveRecord::Migration.verbose = false

ActiveRecord::Schema.define do
  create_table :activity_feed_items, :force => true do |t|
    t.integer :user_id
    t.string :nickname
    t.string :type
    t.string :title
    t.text :text
    t.string :url
    t.string :icon
    t.boolean :sticky
    
    t.timestamps
  end

  add_index :activity_feed_items, :user_id
end

DatabaseCleaner[:active_record].strategy = :transaction
DatabaseCleaner[:mongo_mapper].strategy = :truncation

require 'activity_feed'

ActivityFeed.redis = $redis

require 'activity_feed/custom/item'

RSpec.configure do |config|
  config.mock_with :rspec
  
  config.before(:suite) do
    DatabaseCleaner.strategy = :truncation
    DatabaseCleaner.clean_with(:truncation)
    $redis.flushdb
  end

  config.before(:each) do
    ActivityFeed.persistence = :memory
    DatabaseCleaner.start
    DatabaseCleaner.clean
  end

  config.after(:each) do
    DatabaseCleaner.clean
    $redis.flushdb
  end  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activity_feed-1.2.1 spec/spec_helper.rb
activity_feed-1.2 spec/spec_helper.rb
activity_feed-1.1.1 spec/spec_helper.rb
activity_feed-1.1.0 spec/spec_helper.rb
activity_feed-1.0.0 spec/spec_helper.rb