diff options
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 18 | ||||
-rw-r--r-- | railties/lib/rails/test_unit/reporter.rb | 12 |
2 files changed, 25 insertions, 5 deletions
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 70a20801a0..560a553789 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -63,12 +63,26 @@ module Rails # Add the given source to +Gemfile+ # + # If block is given, gem entries in block are wrapped into the source group. + # # add_source "http://gems.github.com/" - def add_source(source, options={}) + # + # add_source "http://gems.github.com/" do + # gem "rspec-rails" + # end + def add_source(source, options={}, &block) log :source, source in_root do - prepend_file "Gemfile", "source #{quote(source)}\n", verbose: false + if block + append_file "Gemfile", "source #{quote(source)} do", force: true + @in_group = true + instance_eval(&block) + @in_group = false + append_file "Gemfile", "\nend\n", force: true + else + prepend_file "Gemfile", "source #{quote(source)}\n", verbose: false + end end end diff --git a/railties/lib/rails/test_unit/reporter.rb b/railties/lib/rails/test_unit/reporter.rb index faf551f381..09b8675cf8 100644 --- a/railties/lib/rails/test_unit/reporter.rb +++ b/railties/lib/rails/test_unit/reporter.rb @@ -7,7 +7,7 @@ module Rails self.executable = "bin/rails test" def report - return if results.empty? + return if filtered_results.empty? io.puts io.puts "Failed tests:" io.puts @@ -15,14 +15,20 @@ module Rails end def aggregated_results # :nodoc: - filtered_results = results.dup - filtered_results.reject!(&:skipped?) unless options[:verbose] filtered_results.map do |result| location, line = result.method(result.name).source_location "#{self.executable} #{relative_path_for(location)}:#{line}" end.join "\n" end + def filtered_results + if options[:verbose] + results + else + results.reject(&:skipped?) + end + end + def relative_path_for(file) file.sub(/^#{Rails.root}\/?/, '') end |