Skip to content

Commit

Permalink
remove call sites from command line warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Oct 6, 2013
1 parent 5e4c520 commit 2185450
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/rspec/core/option_parser.rb
Expand Up @@ -107,7 +107,7 @@ def parser(options)
end

parser.on('--configure', 'Deprecated. Use --init instead.') do |cmd|
RSpec.warning "--configure is deprecated with no effect. Use --init instead."
RSpec.warning "--configure is deprecated with no effect. Use --init instead.", :call_site => nil
exit
end

Expand Down Expand Up @@ -151,7 +151,8 @@ def parser(options)
rescue ArgumentError
RSpec.warning "Non integer specified as profile count, seperate " +
"your path from options with -- e.g. " +
"`rspec --profile -- #{argument}`"
"`rspec --profile -- #{argument}`",
:call_site => nil
true
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/core/option_parser_spec.rb
Expand Up @@ -238,7 +238,7 @@ module RSpec::Core
end

it 'warns when accidentally combined with path' do
expect_warning_with_call_site __FILE__, __LINE__+1, "Non integer specified as profile count"
expect_warning_without_call_site "Non integer specified as profile count"
options = Parser.parse!(%w[--profile some/path])
expect(options[:profile_examples]).to eq true
end
Expand Down
7 changes: 7 additions & 0 deletions spec/support/helper_methods.rb
Expand Up @@ -33,6 +33,13 @@ def allow_deprecation
allow(RSpec.configuration.reporter).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
Expand Down

0 comments on commit 2185450

Please sign in to comment.