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

Commit b1f151e

Browse files
committed
Merge pull request #2811 from rspec/enable-deprecation-support-explicitly
Enable warning support explicitly
1 parent 4cc2f1f commit b1f151e

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

features/command_line/warnings_option.feature

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@ Feature: `--warnings` option (run with warnings enabled)
1414
When I run `rspec --warnings example_spec.rb`
1515
Then the output should contain "warning"
1616

17+
@ruby-2-7
18+
Scenario:
19+
Given a file named "example_spec.rb" with:
20+
"""ruby
21+
def foo(**kwargs)
22+
kwargs
23+
end
24+
25+
RSpec.describe do
26+
it "should warn about keyword arguments with 'rspec -w'" do
27+
expect(foo({a: 1})).to eq({a: 1})
28+
end
29+
end
30+
"""
31+
When I run `rspec -w example_spec.rb`
32+
Then the output should contain "warning"
33+
1734
Scenario:
1835
Given a file named "example_spec.rb" with:
1936
"""ruby

features/support/ruby_27_support.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Around "@ruby-2-7" do |scenario, block|
2+
if RUBY_VERSION.to_f == 2.7
3+
block.call
4+
else
5+
warn "Skipping scenario #{scenario.title} on Ruby v#{RUBY_VERSION}"
6+
end
7+
end

lib/rspec/core/option_parser.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ def parser(options)
184184
end
185185

186186
parser.on('-w', '--warnings', 'Enable ruby warnings') do
187+
if Object.const_defined?(:Warning) && Warning.respond_to?(:[]=)
188+
Warning[:deprecated] = true
189+
end
187190
$VERBOSE = true
188191
end
189192

0 commit comments

Comments
 (0)