Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1115 from rspec/switch_to_support
Browse files Browse the repository at this point in the history
Use warnings from rspec-support
  • Loading branch information
myronmarston committed Oct 30, 2013
2 parents f70c7c5 + c6c983a commit 24d1487
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 40 deletions.
3 changes: 2 additions & 1 deletion lib/rspec/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
16 changes: 0 additions & 16 deletions lib/rspec/core/warnings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 1 addition & 23 deletions spec/rspec/core/warnings_spec.rb
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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

0 comments on commit 24d1487

Please sign in to comment.