Sha256: 2e8b1b64f881d1dd9250f1f538cb49ccf2848d64da7607d763f7989216ae928b

Contents?: true

Size: 1.82 KB

Versions: 34

Compression:

Stored size: 1.82 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 allow_warning
    allow(::Kernel).to receive(:warn)
  end
end

Version data entries

34 entries across 31 versions & 9 rubygems

Version Path
opal-rspec-0.8.0 rspec-support/upstream/lib/rspec/support/spec/deprecation_helpers.rb
opal-rspec-0.8.0.alpha3 rspec-support/upstream/lib/rspec/support/spec/deprecation_helpers.rb
opal-rspec-0.8.0.alpha2 rspec-support/upstream/lib/rspec/support/spec/deprecation_helpers.rb
opal-rspec-0.8.0.alpha1 rspec-support/upstream/lib/rspec/support/spec/deprecation_helpers.rb
opal-rspec-0.7.1 rspec-support/upstream/lib/rspec/support/spec/deprecation_helpers.rb
opal-rspec-0.7.0 rspec-support/upstream/lib/rspec/support/spec/deprecation_helpers.rb
opal-rspec-0.6.2 rspec-support/lib/rspec/support/spec/deprecation_helpers.rb
opal-rspec-0.7.0.rc.2 rspec-support/upstream/lib/rspec/support/spec/deprecation_helpers.rb
opal-rspec-0.6.1 rspec-support/lib/rspec/support/spec/deprecation_helpers.rb
opal-rspec-0.6.0 rspec-support/lib/rspec/support/spec/deprecation_helpers.rb
opal-rspec-0.6.0.beta1 rspec-support/lib/rspec/support/spec/deprecation_helpers.rb
opal-connect-rspec-0.5.0 rspec-support/lib/rspec/support/spec/deprecation_helpers.rb
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/rspec-support-3.1.2/lib/rspec/support/spec/deprecation_helpers.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/rspec-support-3.1.0/lib/rspec/support/spec/deprecation_helpers.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/rspec-support-3.1.0/lib/rspec/support/spec/deprecation_helpers.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/rspec-support-3.1.0/lib/rspec/support/spec/deprecation_helpers.rb
opal-rspec-0.5.0 rspec-support/lib/rspec/support/spec/deprecation_helpers.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/rspec-support-3.1.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/logstash-codec-json-2.0.3/vendor/gems/rspec-support-3.1.2/lib/rspec/support/spec/deprecation_helpers.rb
logstash-codec-json-2.0.3 vendor/gems/rspec-support-3.1.2/lib/rspec/support/spec/deprecation_helpers.rb