Sha256: 55d88940ab67fc2ebedb936bc2de2a042bd9862ee967b442506a2eba2a826c28

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require "active_record"
require "with_model"

RSpec.configure do |config|
  config.extend WithModel
end

jruby = RUBY_PLATFORM =~ /\bjava\b/
adapter = jruby ? "jdbcsqlite3" : "sqlite3"

# WithModel requires ActiveRecord::Base.connection to be established.
# If ActiveRecord already has a connection, as in a Rails app, this is unnecessary.
ActiveRecord::Base.establish_connection(:adapter => adapter, :database => ":memory:")

# For readme_spec.rb
module SomeModule; end

if defined?(ActiveModel)
  shared_examples_for "ActiveModel" do
    require 'test/unit/assertions'
    require 'active_model/lint'
    include Test::Unit::Assertions
    include ActiveModel::Lint::Tests

    # to_s is to support ruby-1.9
    ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m|
      example m.gsub('_',' ') do
        begin
          send m
        rescue
          puts $!.message
        end
      end
    end

    before { @model = subject }
  end
end

if ENV["LOGGER"]
  require "logger"
  ActiveRecord::Base.logger = Logger.new(STDOUT)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
with_model-0.3.1 spec/spec_helper.rb
with_model-0.3 spec/spec_helper.rb