Sha256: c9cd289cf674e3c211d6f6c2cef5d5d0470881ac088b84bc3da97df5b965b063

Contents?: true

Size: 1.89 KB

Versions: 415

Compression:

Stored size: 1.89 KB

Contents

module RSpecHelpers
  def expect_no_deprecation
    expect(RSpec.configuration.reporter).not_to receive(:deprecation)
  end

  def expect_deprecation_with_call_site(file, line, snippet=//)
    expect(RSpec.configuration.reporter).to receive(:deprecation) do |options|
      expect(options[:call_site]).to include([file, line].join(':'))
      expect(options[:deprecated]).to match(snippet)
    end
  end

  def expect_deprecation_without_call_site(snippet=//)
    expect(RSpec.configuration.reporter).to receive(:deprecation) do |options|
      expect(options[:call_site]).to eq nil
      expect(options[:deprecated]).to match(snippet)
    end
  end

  def expect_warn_deprecation_with_call_site(file, line, snippet=//)
    expect(RSpec.configuration.reporter).to receive(:deprecation) do |options|
      message = options[:message]
      expect(message).to match(snippet)
      expect(message).to include([file, line].join(':'))
    end
  end

  def expect_warn_deprecation(snippet=//)
    expect(RSpec.configuration.reporter).to receive(:deprecation) do |options|
      message = options[:message]
      expect(message).to match(snippet)
    end
  end

  def allow_deprecation
    allow(RSpec.configuration.reporter).to receive(:deprecation)
  end

  def expect_no_deprecations
    expect(RSpec.configuration.reporter).not_to receive(:deprecation)
  end

  def expect_warning_without_call_site(expected=//)
    expect(::Kernel).to receive(:warn) do |message|
      expect(message).to match expected
      expect(message).to_not match(/Called from/)
    end
  end

  def expect_warning_with_call_site(file, line, expected=//)
    expect(::Kernel).to receive(:warn) do |message|
      expect(message).to match expected
      expect(message).to match(/Called from #{file}:#{line}/)
    end
  end

  def expect_no_warnings
    expect(::Kernel).not_to receive(:warn)
  end

  def allow_warning
    allow(::Kernel).to receive(:warn)
  end
end

Version data entries

415 entries across 340 versions & 82 rubygems

Version Path
plaid-14.13.0 vendor/bundle/ruby/3.0.0/gems/rspec-support-3.10.0/lib/rspec/support/spec/deprecation_helpers.rb
plaid-14.12.1 vendor/bundle/ruby/3.0.0/gems/rspec-support-3.10.0/lib/rspec/support/spec/deprecation_helpers.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/rspec-support-3.10.0/lib/rspec/support/spec/deprecation_helpers.rb
plaid-14.11.1 vendor/bundle/ruby/2.6.0/gems/rspec-support-3.10.0/lib/rspec/support/spec/deprecation_helpers.rb
plaid-14.10.0 vendor/bundle/ruby/2.6.0/gems/rspec-support-3.10.0/lib/rspec/support/spec/deprecation_helpers.rb
plaid-14.7.0 vendor/bundle/ruby/2.6.0/gems/rspec-support-3.10.0/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/deprecation_helpers.rb