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

Commit 18cb2a2

Browse files
committed
Enable warning support explicitly
1 parent 5d8331d commit 18cb2a2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

features/command_line/warnings_option.feature

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

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

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) and Warning.respond_to?(:[]=)
188+
Warning[:deprecated] = true
189+
end
187190
$VERBOSE = true
188191
end
189192

0 commit comments

Comments
 (0)