Sha256: 2e0e34bc0e77ab3105f47f87ba25f2c83d18a1ec84026114c4cda35ba5467e9d

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require "active_record"
require "with_model"

begin
  require 'coveralls'
  Coveralls.wear!
rescue LoadError
end

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

1 entries across 1 versions & 1 rubygems

Version Path
with_model-0.3.2 spec/spec_helper.rb