Module: RSpecHelpers
- Defined in:
- lib/rspec/support/spec/deprecation_helpers.rb
Instance Method Summary collapse
- #allow_deprecation ⇒ Object
- #allow_warning ⇒ Object
- #expect_deprecation_with_call_site(file, line, snippet = //) ⇒ Object
- #expect_deprecation_without_call_site(snippet = //) ⇒ Object
- #expect_no_deprecation ⇒ Object
- #expect_no_deprecations ⇒ Object
- #expect_no_warnings ⇒ Object
- #expect_warn_deprecation(snippet = //) ⇒ Object
- #expect_warn_deprecation_with_call_site(file, line, snippet = //) ⇒ Object
- #expect_warning_with_call_site(file, line, expected = //) ⇒ Object
- #expect_warning_without_call_site(expected = //) ⇒ Object
Instance Method Details
#allow_deprecation ⇒ Object
35 36 37 |
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 35 def allow_deprecation allow(RSpec.configuration.reporter).to receive(:deprecation) end |
#allow_warning ⇒ Object
61 62 63 |
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 61 def allow_warning allow(::Kernel).to receive(:warn) end |
#expect_deprecation_with_call_site(file, line, snippet = //) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 6 def expect_deprecation_with_call_site(file, line, snippet=//) expect(RSpec.configuration.reporter).to receive(:deprecation) do || expect([:call_site]).to include([file, line].join(':')) expect([:deprecated]).to match(snippet) end end |
#expect_deprecation_without_call_site(snippet = //) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 13 def expect_deprecation_without_call_site(snippet=//) expect(RSpec.configuration.reporter).to receive(:deprecation) do || expect([:call_site]).to eq nil expect([:deprecated]).to match(snippet) end end |
#expect_no_deprecation ⇒ Object
2 3 4 |
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 2 def expect_no_deprecation expect(RSpec.configuration.reporter).not_to receive(:deprecation) end |
#expect_no_deprecations ⇒ Object
39 40 41 |
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 39 def expect_no_deprecations expect(RSpec.configuration.reporter).not_to receive(:deprecation) end |
#expect_no_warnings ⇒ Object
57 58 59 |
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 57 def expect_no_warnings expect(::Kernel).not_to receive(:warn) end |
#expect_warn_deprecation(snippet = //) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 28 def expect_warn_deprecation(snippet=//) expect(RSpec.configuration.reporter).to receive(:deprecation) do || = [:message] expect().to match(snippet) end end |
#expect_warn_deprecation_with_call_site(file, line, snippet = //) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 20 def expect_warn_deprecation_with_call_site(file, line, snippet=//) expect(RSpec.configuration.reporter).to receive(:deprecation) do || = [:message] expect().to match(snippet) expect().to include([file, line].join(':')) end end |
#expect_warning_with_call_site(file, line, expected = //) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 50 def expect_warning_with_call_site(file, line, expected=//) expect(::Kernel).to receive(:warn) do || expect().to match expected expect().to match(/Called from #{file}:#{line}/) end end |
#expect_warning_without_call_site(expected = //) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/rspec/support/spec/deprecation_helpers.rb', line 43 def expect_warning_without_call_site(expected=//) expect(::Kernel).to receive(:warn) do || expect().to match expected expect().to_not match(/Called from/) end end |