1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/cases/arel/helper.rb

46 lines
1 KiB
Ruby
Raw Normal View History

2018-02-24 01:34:15 -05:00
# frozen_string_literal: true
require "active_support"
2018-02-24 01:45:50 -05:00
require "minitest/autorun"
require "arel"
require_relative "support/fake_record"
2018-02-24 01:34:15 -05:00
Minitest::Expectation.class_eval do
2018-02-24 01:45:50 -05:00
def must_be_like(other)
self.class.new(target.gsub(/\s+/, " ").strip, ctx).must_equal other.gsub(/\s+/, " ").strip
2018-02-24 01:34:15 -05:00
end
end
module Arel
class Test < ActiveSupport::TestCase
2018-02-24 01:34:15 -05:00
def setup
super
@arel_engine = Arel::Table.engine
Arel::Table.engine = FakeRecord::Base.new
end
def teardown
Arel::Table.engine = @arel_engine if defined? @arel_engine
super
end
end
class Spec < Minitest::Spec
before do
@arel_engine = Arel::Table.engine
Arel::Table.engine = FakeRecord::Base.new
end
after do
Arel::Table.engine = @arel_engine if defined? @arel_engine
end
include ActiveSupport::Testing::Assertions
# test/unit backwards compatibility methods
alias :assert_no_match :refute_match
alias :assert_not_equal :refute_equal
alias :assert_not_same :refute_same
2018-02-24 01:34:15 -05:00
end
end