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

Enable warning support explicitly #2811

Merged
merged 1 commit into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions features/command_line/warnings_option.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ Feature: `--warnings` option (run with warnings enabled)
When I run `rspec --warnings example_spec.rb`
Then the output should contain "warning"

@ruby-2-7
Scenario:
Given a file named "example_spec.rb" with:
"""ruby
def foo(**kwargs)
kwargs
end

RSpec.describe do
it "should warn about keyword arguments with 'rspec -w'" do
expect(foo({a: 1})).to eq({a: 1})
end
end
"""
When I run `rspec -w example_spec.rb`
Then the output should contain "warning"

@unsupported-on-rbx
Scenario:
Given a file named "example_spec.rb" with:
Expand Down
7 changes: 7 additions & 0 deletions features/support/ruby_27_support.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Around "@ruby-2-7" do |scenario, block|
if RUBY_VERSION.to_f == 2.7
block.call
else
warn "Skipping scenario #{scenario.title} on Ruby v#{RUBY_VERSION}"
end
end
3 changes: 3 additions & 0 deletions lib/rspec/core/option_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ def parser(options)
end

parser.on('-w', '--warnings', 'Enable ruby warnings') do
if Object.const_defined?(:Warning) && Warning.respond_to?(:[]=)
Warning[:deprecated] = true
end
$VERBOSE = true
end

Expand Down