From 30ed2275c175fb0e4e7c053519e200e9cd6c8ee3 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 17 Oct 2013 16:30:10 +1100 Subject: [PATCH 1/2] switch to support gem for warnings and caller filter --- lib/rspec/core.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rspec/core.rb b/lib/rspec/core.rb index 323251a043..5ca0c77e77 100644 --- a/lib/rspec/core.rb +++ b/lib/rspec/core.rb @@ -15,11 +15,12 @@ require_rspec['core/version'] require 'rspec/support/caller_filter' +require 'rspec/core/warnings' +require 'rspec/support/warnings' require_rspec['core/flat_map'] require_rspec['core/filter_manager'] require_rspec['core/dsl'] -require_rspec['core/warnings'] require_rspec['core/reporter'] require_rspec['core/hooks'] From c6c983a6d7277d07019b9e1661067c13eeb791de Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Fri, 25 Oct 2013 11:35:55 +1100 Subject: [PATCH 2/2] Remove old warnings --- lib/rspec/core/warnings.rb | 16 ---------------- spec/rspec/core/warnings_spec.rb | 24 +----------------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/lib/rspec/core/warnings.rb b/lib/rspec/core/warnings.rb index fc9570b6a8..dce0b6f821 100644 --- a/lib/rspec/core/warnings.rb +++ b/lib/rspec/core/warnings.rb @@ -19,20 +19,4 @@ def self.warn_deprecation(message) RSpec.configuration.reporter.deprecation :message => message end - # @private - # - # Used internally to print warnings - def self.warning(text, options={}) - warn_with "WARNING: #{text}.", options - end - - # @private - # - # Used internally to print longer warnings - def self.warn_with(message, options = {}) - call_site = options.fetch(:call_site, CallerFilter.first_non_rspec_line) - message << " Called from #{call_site}." if call_site - ::Kernel.warn message - end - end diff --git a/spec/rspec/core/warnings_spec.rb b/spec/rspec/core/warnings_spec.rb index c876736eee..1ace69e995 100644 --- a/spec/rspec/core/warnings_spec.rb +++ b/spec/rspec/core/warnings_spec.rb @@ -1,6 +1,7 @@ require "spec_helper" describe "RSpec deprecations and warnings" do + describe "#deprecate" do it "passes the hash to the reporter" do expect(RSpec.configuration.reporter).to receive(:deprecation).with(hash_including :deprecated => "deprecated_method", :replacement => "replacement") @@ -25,27 +26,4 @@ end end - shared_examples_for "warning helper" do |helper| - it 'warns with the message text' do - expect(::Kernel).to receive(:warn).with(/Message/) - RSpec.send(helper, 'Message') - end - - it 'sets the calling line' do - expect(::Kernel).to receive(:warn).with(/#{__FILE__}:#{__LINE__+1}/) - RSpec.send(helper, 'Message') - end - end - - describe "#warning" do - it 'prepends WARNING:' do - expect(::Kernel).to receive(:warn).with(/WARNING: Message\./) - RSpec.warning 'Message' - end - it_should_behave_like 'warning helper', :warning - end - - describe "#warn_with message, options" do - it_should_behave_like 'warning helper', :warn_with - end end