Class: M::Parser
- Inherits:
-
Object
- Object
- M::Parser
- Defined in:
- lib/m/parser.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
Instance Method Details
#parse ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/m/parser.rb', line 10 def parse # With no arguments, if argv.empty? # Just shell out to `rake test`. exec "rake test" else argv # Parse out ARGV, it should be coming in in a format like `test/test_file.rb:9:19` parsed = argv.first.split(':') testable.file = parsed.shift testable.lines = parsed if testable.lines.none? # If this file is a directory, not a file, run the tests inside of this directory if Dir.exist?(testable.file) # Make a new rake test task with a hopefully unique name, and run every test looking file in it require "rake/testtask" Rake::TestTask.new(:m_custom) do |t| t.libs << 'test' t.libs << 'spec' t.test_files = FileList[wildcard("test"), wildcard("spec")] t.warning = false end # Invoke the rake task and exit, hopefully it'll work! begin Rake::Task['m_custom'].invoke rescue RuntimeError exit(1) ensure exit($?.exitstatus) end else return testable end end end |