Sha256: 293e59e7c543b9f9a949214866e775cdf5d31c5fcf4281faba96878befed1e04

Contents?: true

Size: 993 Bytes

Versions: 1

Compression:

Stored size: 993 Bytes

Contents

require 'user_preferences'
require 'active_record'
require 'active_record/connection_adapters/sqlite3_adapter'

RSpec.configure do |config|
  $stdout = StringIO.new # silence migrations
  ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
  if ActiveRecord::VERSION::MAJOR >= 5
    ActiveRecord::Migrator.migrations_paths = File.expand_path('../migrations', __FILE__)
    ActiveRecord::Base.connection.migration_context.migrate
  else
    ActiveRecord::Migrator.migrate(File.expand_path('../migrations', __FILE__))
  end
  $stdout = STDOUT

  # prevent deprecation warnings
  I18n.enforce_available_locales = true

  config.mock_with :rspec do |mocks|
    mocks.syntax = [:should, :expect]
  end
  config.before(:each) { stub_yml }
end

def stub_yml
  fixture = File.expand_path("../fixtures/user_preferences.yml", __FILE__)
  UserPreferences.stub(:yml_path).and_return(fixture)
end

class User < ActiveRecord::Base
  include UserPreferences::HasPreferences
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
user_preferences-1.0.2 spec/spec_helper.rb