Sha256: 9dab98ec64a77492770112bb7ea875f3f4e47d4daef6c98d8a43fb66abf9fe7f

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

require "hstore_accessor"
require "database_cleaner"
require "shoulda-matchers"

DatabaseCleaner.strategy = :truncation

RSpec.configure do |config|
  config.mock_with :rspec
  config.order = :random

  config.before :suite do
    create_database
  end

  config.before do
    DatabaseCleaner.clean
  end
end

def create_database
  ActiveRecord::Base.establish_connection(
    adapter: "postgresql",
    database: "hstore_accessor",
    username: "postgres"
  )

  ActiveRecord::Base.connection.execute("CREATE EXTENSION hstore;") rescue ActiveRecord::StatementInvalid
  ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS products;")

  ActiveRecord::Base.connection.create_table(:products) do |t|
    t.hstore :options
    t.hstore :data

    t.string :string_type
    t.integer :integer_type
    t.boolean :boolean_type
    t.float :float_type
    t.time :time_type
    t.string :array_type, array: true
    t.date :date_type
    t.datetime :datetime_type
    t.decimal :decimal_type
    t.hstore :hash_type
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hstore_accessor-0.9.1 spec/spec_helper.rb
hstore_accessor-0.9.0 spec/spec_helper.rb