提交 341fab88 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #27784 from y-yagi/add_warnings_option_to_test_runner

add warnings option to test runner
* Add option to configure Ruby's warning behaviour to test runner.
*Yuji Yaginuma*
* Initialize git repo when generating new app, if option `--skip-git`
is not provided.
......
......@@ -52,6 +52,11 @@ def self.plugin_rails_options(opts, options)
options[:color] = value
end
opts.on("-w", "--warnings",
"Enable ruby warnings") do
$VERBOSE = true
end
options[:color] = true
options[:output_inline] = true
options[:patterns] = defined?(@rake_patterns) ? @rake_patterns : opts.order!
......
......@@ -536,6 +536,17 @@ def test_rake_passes_multiple_TESTOPTS_to_minitest
assert_match "seed=1234", output, "passing TEST= should run selected test"
end
def test_warnings_option
app_file "test/models/warnings_test.rb", <<-RUBY
require 'test_helper'
def test_warnings
a = 1
end
RUBY
assert_match(/warning: assigned but unused variable/,
capture(:stderr) { run_test_command("test/models/warnings_test.rb -w") })
end
private
def run_test_command(arguments = "test/unit/test_test.rb")
Dir.chdir(app_path) { `bin/rails t #{arguments}` }
......
......@@ -92,6 +92,17 @@ def test_executed_only_once
assert_equal 1, result.scan(/1 runs, 1 assertions, 0 failures/).length
end
def test_warnings_option
plugin_file "test/models/warnings_test.rb", <<-RUBY
require 'test_helper'
def test_warnings
a = 1
end
RUBY
assert_match(/warning: assigned but unused variable/,
capture(:stderr) { run_test_command("test/models/warnings_test.rb -w") })
end
private
def plugin_path
"#{@destination_root}/bukkits"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册