aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/generators/rails/plugin/templates/README.md27
-rw-r--r--railties/lib/rails/test_unit/minitest_plugin.rb16
-rw-r--r--railties/lib/rails/test_unit/reporter.rb34
3 files changed, 44 insertions, 33 deletions
diff --git a/railties/lib/rails/generators/rails/plugin/templates/README.md b/railties/lib/rails/generators/rails/plugin/templates/README.md
index 61ad1ed36a..9d2b74416e 100644
--- a/railties/lib/rails/generators/rails/plugin/templates/README.md
+++ b/railties/lib/rails/generators/rails/plugin/templates/README.md
@@ -1,3 +1,28 @@
# <%= camelized_modules %>
+Short description and motivation.
-This project rocks and uses MIT-LICENSE.
+## Usage
+How to use my plugin.
+
+## Installation
+Add this line to your application's Gemfile:
+
+```ruby
+gem '<%= name %>'
+```
+
+And then execute:
+```bash
+$ bundle
+```
+
+Or install it yourself as:
+```bash
+$ gem install <%= name %>
+```
+
+## Contributing
+Contribution directions go here.
+
+## License
+The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
diff --git a/railties/lib/rails/test_unit/minitest_plugin.rb b/railties/lib/rails/test_unit/minitest_plugin.rb
index c1ea307f93..d4ab2ada66 100644
--- a/railties/lib/rails/test_unit/minitest_plugin.rb
+++ b/railties/lib/rails/test_unit/minitest_plugin.rb
@@ -3,16 +3,13 @@ require "rails/test_unit/reporter"
require "rails/test_unit/test_requirer"
module Minitest
- mattr_accessor(:hide_aggregated_results) { false }
-
- module AggregatedResultSuppresion
+ class SuppressedSummaryReporter < SummaryReporter
+ # Disable extra failure output after a run if output is inline.
def aggregated_results
- super unless Minitest.hide_aggregated_results
+ super unless options[:output_inline]
end
end
- SummaryReporter.prepend AggregatedResultSuppresion
-
def self.plugin_rails_options(opts, options)
executable = ::Rails::TestUnitReporter.executable
opts.separator ""
@@ -83,11 +80,8 @@ module Minitest
Minitest.backtrace_filter = ::Rails.backtrace_cleaner if ::Rails.respond_to?(:backtrace_cleaner)
end
- # Disable the extra failure output after a run, unless output is deferred.
- self.hide_aggregated_results = options[:output_inline]
-
- self.reporter.reporters.clear
- self.reporter << SummaryReporter.new(options[:io], options)
+ self.reporter.reporters.clear # Replace progress reporter for colors.
+ self.reporter << SuppressedSummaryReporter.new(options[:io], options)
self.reporter << ::Rails::TestUnitReporter.new(options[:io], options)
end
diff --git a/railties/lib/rails/test_unit/reporter.rb b/railties/lib/rails/test_unit/reporter.rb
index ba80dad2e3..73b8d7d27b 100644
--- a/railties/lib/rails/test_unit/reporter.rb
+++ b/railties/lib/rails/test_unit/reporter.rb
@@ -6,34 +6,19 @@ module Rails
class_attribute :executable
self.executable = "bin/rails test"
- COLOR_CODES_FOR_RESULTS = {
- "." => :green,
- "E" => :red,
- "F" => :red,
- "S" => :yellow
- }
-
- COLOR_CODES = {
- red: 31,
- green: 32,
- yellow: 33,
- blue: 34
- }
-
def record(result)
super
- color = COLOR_CODES_FOR_RESULTS[result.result_code]
if options[:verbose]
- io.puts color(format_line(result), color)
+ io.puts color_output(format_line(result), by: result)
else
- io.print color(result.result_code, color)
+ io.print color_output(result.result_code, by: result)
end
if output_inline? && result.failure && (!result.skipped? || options[:verbose])
io.puts
io.puts
- io.puts format_failures(result).map { |line| color(line, :red) }
+ io.puts format_failures(result).map { |line| color_output(line, by: result) }
io.puts
io.puts format_rerun_snippet(result)
io.puts
@@ -106,10 +91,17 @@ module Rails
options[:color] && io.respond_to?(:tty?) && io.tty?
end
- def color(string, color)
+ codes = { red: 31, green: 32, yellow: 33 }
+ COLOR_BY_RESULT_CODE = {
+ "." => codes[:green],
+ "E" => codes[:red],
+ "F" => codes[:red],
+ "S" => codes[:yellow]
+ }
+
+ def color_output(string, by:)
if colored_output?
- color = COLOR_CODES[color]
- "\e[#{color}m#{string}\e[0m"
+ "\e[#{COLOR_BY_RESULT_CODE[by.result_code]}m#{string}\e[0m"
else
string
end