Module: RSpecHelpers

Defined in:
lib/rspec/support/spec/deprecation_helpers.rb

Instance Method Summary collapse

Instance Method Details

#allow_deprecationObject



24
25
26
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 24

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

#allow_warningObject



47
48
49
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 47

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

#expect_deprecation_with_call_site(file, line, snippet = //) ⇒ Object



4
5
6
7
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 4

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

#expect_deprecation_without_call_site(snippet = //) ⇒ Object



9
10
11
12
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 9

def expect_deprecation_without_call_site(snippet=//)
  expect(RSpec.configuration.reporter).to receive(:deprecation).
    with(include(:deprecated => match(snippet), :call_site => eq(nil)))
end

#expect_no_deprecationsObject Also known as: expect_no_deprecation



28
29
30
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 28

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

#expect_no_warningsObject



43
44
45
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 43

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

#expect_warn_deprecation(snippet = //) ⇒ Object



19
20
21
22
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 19

def expect_warn_deprecation(snippet=//)
  expect(RSpec.configuration.reporter).to receive(:deprecation).
    with(include(:message => match(snippet)))
end

#expect_warn_deprecation_with_call_site(file, line, snippet = //) ⇒ Object



14
15
16
17
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 14

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

#expect_warning_with_call_site(file, line, expected = //) ⇒ Object



38
39
40
41
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 38

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

#expect_warning_without_call_site(expected = //) ⇒ Object



33
34
35
36
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 33

def expect_warning_without_call_site(expected=//)
  expect(::Kernel).to receive(:warn).
    with(match(expected).and(satisfy { |message| !(/Called from/ =~ message) }))
end