Sha256: 4dfac0196015cb533843efb53906b77fac66f2c041f5882f2a14cff0f55ae628

Contents?: true

Size: 1.85 KB

Versions: 55

Compression:

Stored size: 1.85 KB

Contents

require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
# ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
require 'rails/test_help'

# Filter out Minitest backtrace while allowing backtrace from other libraries
# to be shown.
Minitest.backtrace_filter = Minitest::BacktraceFilter.new

require 'rails/test_unit/reporter'

Rails::TestUnitReporter.executable = 'bin/test'

# Load fixtures from the engine
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
  ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__)
  ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
  ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + '/files'
  ActiveSupport::TestCase.fixtures :all
end

load File.dirname(__FILE__) + '/dummy/db/schema.rb'

require 'request_store'

module TestHelper
  extend ActiveSupport::Concern

  # Help test raise errors message
  # https://ruby-doc.org/stdlib-2.1.5/libdoc/test/unit/rdoc/Test/Unit/Assertions.html#method-i-assert_raise
  def assert_raises_with_message(exception, expected, msg = nil, &block)
    case expected
    when String
      assert = :assert_equal
    when Regexp
      assert = :assert_match
    else
      fail TypeError, "Expected #{expected.inspect} to be a kind of String or Regexp, not #{expected.class}"
    end

    ex = assert_raises(exception, *msg) { yield }
    msg = message(msg, '') { "Expected Exception(#{exception}) was raised, but the message doesn't match" }

    if assert == :assert_equal
      assert_equal(expected, ex.message, msg)
    else
      msg = message(msg) { "Expected #{mu_pp expected} to match #{mu_pp ex.message}" }
      assert expected =~ ex.message, msg
      block.binding.eval('proc{|_|$~=_}').call($LAST_MATCH_INFO)
    end

    return ex
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
rails_ops-1.0.17.1 test/test_helper.rb
rails_ops-1.1.23 test/test_helper.rb
rails_ops-1.1.22 test/test_helper.rb
rails_ops-1.1.21 test/test_helper.rb
rails_ops-1.1.20 test/test_helper.rb
rails_ops-1.1.19 test/test_helper.rb
rails_ops-1.1.18 test/test_helper.rb
rails_ops-1.1.17 test/test_helper.rb
rails_ops-1.1.16 test/test_helper.rb
rails_ops-1.1.15 test/test_helper.rb
rails_ops-1.1.14 test/test_helper.rb
rails_ops-1.1.13 test/test_helper.rb
rails_ops-1.1.12 test/test_helper.rb
rails_ops-1.1.11 test/test_helper.rb
rails_ops-1.1.10 test/test_helper.rb
rails_ops-1.1.9 test/test_helper.rb
rails_ops-1.1.8 test/test_helper.rb
rails_ops-1.1.7 test/test_helper.rb
rails_ops-1.1.6 test/test_helper.rb
rails_ops-1.1.5 test/test_helper.rb