Sha256: 445e1a5fcf4253e76690d5a3ed511af2dff87cf8e0a86a070c704edc0a430d11

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

# frozen_string_literal: true

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))

require "mongoid"

# MRI 2.5 and JRuby 9.2 change visibility of Object#pp when 'pp' is required,
# which happens when RSpec reports anything. This creates an issue for tests
# that verify method forwarding. Work around by proactively loading 'pp'.
# https://github.com/jruby/jruby/issues/5599
require 'pp'

require 'support/spec_config'
require "support/session_registry"

unless SpecConfig.instance.ci?
  begin
    require 'byebug'
  rescue LoadError
    # jruby - try pry
    begin
      require 'pry'
    # jruby likes to raise random error classes, in this case
    # NameError in addition to LoadError
    rescue Exception
    end
  end
end

if SpecConfig.instance.mri?
  require 'timeout_interrupt'
else
  require 'timeout'
  TimeoutInterrupt = Timeout
end

RSpec.configure do |config|
  config.expect_with(:rspec) do |c|
    c.syntax = [:should, :expect]
  end

  if SpecConfig.instance.ci?
    config.add_formatter(RSpec::Core::Formatters::JsonFormatter, File.join(File.dirname(__FILE__), '../tmp/rspec.json'))
  end

  if SpecConfig.instance.ci?
    timeout = if SpecConfig.instance.app_tests?
      # Allow 5 minutes per test for the app tests, since they install
      # gems for Rails applications which can take a long time.
      300
    else
      # Allow a max of 30 seconds per test.
      # Tests should take under 10 seconds ideally but it seems
      # we have some that run for more than 10 seconds in CI.
      30
    end
    config.around(:each) do |example|
      TimeoutInterrupt.timeout(timeout) do
        example.run
      end
    end
  end
end

# require all shared examples
Dir['./spec/support/shared/*.rb'].sort.each { |file| require file }

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongoid-7.0.12 spec/lite_spec_helper.rb
mongoid-7.0.11 spec/lite_spec_helper.rb