From da2413c7ff5d7c103b4e4fd37b9f3d29eec8ad2a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 6 Apr 2013 17:10:37 +0100 Subject: [PATCH 1/2] make "spring test" support multiple arguments "spring test" needs to accept multiple arguments if guard-minitest is to ever have a chance of supporting spring. --- lib/spring/commands.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/spring/commands.rb b/lib/spring/commands.rb index 26432ef4..c9bab786 100644 --- a/lib/spring/commands.rb +++ b/lib/spring/commands.rb @@ -71,17 +71,19 @@ def setup end def call(args) - if args.size > 0 - ARGV.replace args - path = File.expand_path(args.first) + if args.empty? + $stderr.puts "you need to specify what test to run: spring test TEST_NAME" + return + end + ARGV.replace args + args.each do |arg| + path = File.expand_path(arg) if File.directory?(path) Dir[File.join path, "**", "*_test.rb"].each { |f| require f } else require path end - else - $stderr.puts "you need to specify what test to run: spring test TEST_NAME" end end From 34b2ee87462ab0d9601f061f6606bedfe7349fd2 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 17 Mar 2013 15:33:21 +0000 Subject: [PATCH 2/2] make "spring test" run all unit tests when given no arguments With no arguments, it now defaults to running all test-unit tests it can find, i.e. files matching test/**/*_test.rb. This is more useful and arguably more intuitive too. We need to remove test/performance/browsing_test.rb from the Rails app being tested, otherwise "spring test" attempts to run this when it iterates over test/**/*_test.rb, causing a failure due to ruby-prof not being installed. Signed-off-by: Adam Spiers --- lib/spring/commands.rb | 3 +-- .../rails-3-2/test/performance/browsing_test.rb | 12 ------------ test/unit/commands_test.rb | 14 -------------- 3 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 test/apps/rails-3-2/test/performance/browsing_test.rb diff --git a/lib/spring/commands.rb b/lib/spring/commands.rb index c9bab786..7de963ac 100644 --- a/lib/spring/commands.rb +++ b/lib/spring/commands.rb @@ -72,8 +72,7 @@ def setup def call(args) if args.empty? - $stderr.puts "you need to specify what test to run: spring test TEST_NAME" - return + args = ['test'] end ARGV.replace args diff --git a/test/apps/rails-3-2/test/performance/browsing_test.rb b/test/apps/rails-3-2/test/performance/browsing_test.rb deleted file mode 100644 index 3fea27b9..00000000 --- a/test/apps/rails-3-2/test/performance/browsing_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'test_helper' -require 'rails/performance_test_help' - -class BrowsingTest < ActionDispatch::PerformanceTest - # Refer to the documentation for all available options - # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] - # :output => 'tmp/performance', :formats => [:flat] } - - def test_homepage - get '/' - end -end diff --git a/test/unit/commands_test.rb b/test/unit/commands_test.rb index a47df7af..435a6be8 100644 --- a/test/unit/commands_test.rb +++ b/test/unit/commands_test.rb @@ -2,20 +2,6 @@ require "spring/commands" class CommandsTest < ActiveSupport::TestCase - test "test command needs a test name" do - begin - real_stderr = $stderr - $stderr = StringIO.new('') - - command = Spring::Commands::TestUnit.new - command.call([]) - - assert_equal "you need to specify what test to run: spring test TEST_NAME\n", $stderr.string - ensure - $stderr = real_stderr - end - end - test 'children of Command have inheritable accessor named "preload"' do command1, command2 = 2.times.map { Class.new(Spring::Commands::Command) }