spec/spec_helper.rb in with_model-0.3.2 vs spec/spec_helper.rb in with_model-1.0.0
- old
+ new
@@ -1,49 +1,54 @@
-require "active_record"
-require "with_model"
+require 'bundler'
+Bundler.setup
begin
require 'coveralls'
Coveralls.wear!
rescue LoadError
end
+require 'with_model'
RSpec.configure do |config|
config.extend WithModel
+
+ config.warnings = true
+
+ config.expect_with :rspec do |c|
+ c.syntax = :expect
+ end
+
+ config.mock_with :rspec do |c|
+ c.syntax = :expect
+ end
end
-jruby = RUBY_PLATFORM =~ /\bjava\b/
-adapter = jruby ? "jdbcsqlite3" : "sqlite3"
+is_jruby = RUBY_PLATFORM =~ /\bjava\b/
+adapter = is_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:")
+require 'active_record'
+ActiveRecord::Base.establish_connection(:adapter => adapter, :database => ':memory:')
-# For readme_spec.rb
-module SomeModule; end
+if defined?(I18n) && I18n.respond_to?(:enforce_available_locales=)
+ I18n.enforce_available_locales = true
+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
+if ENV['LOGGER']
+ require 'logger'
+ ActiveRecord::Base.logger = Logger.new($stdout)
+end
- # 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
+module SpecHelper
+ module RailsTestCompatability
+ if ::ActiveRecord::VERSION::STRING >= '4.1.0'
+ require 'minitest'
+ include Minitest::Assertions
+ def assertions; @assertions || 0; end
+ def assertions= value; @assertions = value; end
+ else
+ require 'test/unit/assertions'
+ include Test::Unit::Assertions
end
-
- before { @model = subject }
end
-end
-
-if ENV["LOGGER"]
- require "logger"
- ActiveRecord::Base.logger = Logger.new(STDOUT)
end