Class: Rails::TestUnit::Runner
- Inherits:
-
Object
- Object
- Rails::TestUnit::Runner
- Defined in:
- lib/rails/test_unit/runner.rb
Class Method Summary collapse
- .attach_before_load_options(opts) ⇒ Object
- .compose_filter(runnable, filter) ⇒ Object
- .load_tests(argv) ⇒ Object
- .parse_options(argv) ⇒ Object
- .rake_run(argv = []) ⇒ Object
- .run(argv = []) ⇒ Object
Class Method Details
.attach_before_load_options(opts) ⇒ Object
15 16 17 18 |
# File 'lib/rails/test_unit/runner.rb', line 15 def (opts) opts.on("--warnings", "-w", "Run with Ruby warnings enabled") { } opts.on("-e", "--environment ENV", "Run tests in the ENV environment") { } end |
.compose_filter(runnable, filter) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/rails/test_unit/runner.rb', line 50 def compose_filter(runnable, filter) if filters.any? { |_, lines| lines.any? } CompositeFilter.new(runnable, filter, filters) else filter end end |
.load_tests(argv) ⇒ Object
45 46 47 48 |
# File 'lib/rails/test_unit/runner.rb', line 45 def load_tests(argv) tests = list_tests(argv) tests.to_a.each { |path| require File.(path) } end |
.parse_options(argv) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rails/test_unit/runner.rb', line 20 def (argv) # Perform manual parsing and cleanup since option parser raises on unknown options. env_index = argv.index("--environment") || argv.index("-e") if env_index argv.delete_at(env_index) environment = argv.delete_at(env_index).strip end ENV["RAILS_ENV"] = environment || "test" w_index = argv.index("--warnings") || argv.index("-w") $VERBOSE = argv.delete_at(w_index) if w_index end |
.rake_run(argv = []) ⇒ Object
33 34 35 36 37 |
# File 'lib/rails/test_unit/runner.rb', line 33 def rake_run(argv = []) # Ensure the tests run during the Rake Task action, not when the process exits success = system("rails", "test", *argv, *Shellwords.split(ENV["TESTOPTS"] || "")) success || exit(false) end |
.run(argv = []) ⇒ Object
39 40 41 42 43 |
# File 'lib/rails/test_unit/runner.rb', line 39 def run(argv = []) load_tests(argv) require "active_support/testing/autorun" end |