3781: Add singletest function.
authorTom Clegg <tom@curoverse.com>
Tue, 9 Dec 2014 21:44:50 +0000 (16:44 -0500)
committerTom Clegg <tom@curoverse.com>
Tue, 9 Dec 2014 21:44:50 +0000 (16:44 -0500)
apps/workbench/test/test_helper.rb

index e8f787b2460884654c50b852896e3b68c7c17570..65eed789c87fada30b4c6d4a75d2b6d9f9166dcf 100644 (file)
@@ -289,6 +289,20 @@ class RequestDuck
   end
 end
 
+# Example:
+#
+# apps/workbench$ RAILS_ENV=test bundle exec irb -Ilib:test
+# > load 'test/test_helper.rb'
+# > singletest 'integration/collection_upload_test.rb', 'Upload two empty files'
+#
+def singletest test_class_file, test_name
+  load File.join('test', test_class_file)
+  Minitest.run ['-v', '-n', "test_#{test_name.gsub ' ', '_'}"]
+  Object.send(:remove_const,
+              test_class_file.gsub(/.*\/|\.rb$/, '').camelize.to_sym)
+  ::Minitest::Runnable.runnables.reject! { true }
+end
+
 if ENV["RAILS_ENV"].eql? 'test'
   ApiServerForTests.new.run
   ApiServerForTests.new.run ["--websockets"]