Permalink
Browse files

add line option, closes #9

  • Loading branch information...
1 parent 311ea36 commit cfb3227c5b21901316bd7a1edbc88a9c22377653 @cldwalker cldwalker committed Apr 7, 2012
Showing with 21 additions and 3 deletions.
  1. +6 −3 lib/m.rb
  2. +15 −0 test/options_test.rb
View
@@ -132,7 +132,7 @@ def parse
# Parse out ARGV, it should be coming in in a format like `test/test_file.rb:9`
@file, line = @argv.first.split(':')
- @line = line.to_i
+ @line ||= line.to_i
# If this file is a directory, not a file, run the tests inside of this directory
if Dir.exist?(@file)
@@ -161,14 +161,17 @@ def parse_options!(argv)
exit
end
- opts.on '--version', 'Display version.' do
+ opts.on '--version', 'Display the version.' do
puts "m #{M::VERSION}"
exit
end
+ opts.on '-l', '--line LINE', Integer, 'Line number for file.' do |line|
+ @line = line
+ end
+
opts.parse! argv
end
-
end
def execute
View
@@ -15,4 +15,19 @@ def test_verbose_option
output = m('--version')
assert_output /^m #{M::VERSION}/, output
end
+
+ def test_short_line_option
+ output = m('-l19 examples/minitest_example_test.rb')
+ assert_output /1 tests, 1 assertions/, output
+ end
+
+ def test_long_line_option
+ output = m('--line 19 examples/minitest_example_test.rb')
+ assert_output /1 tests, 1 assertions/, output
+ end
+
+ def test_line_option_has_precedence_over_colon_format
+ output = m('--line 19 examples/minitest_example_test.rb:2')
+ assert_output /1 tests, 1 assertions/, output
+ end
end

0 comments on commit cfb3227

Please sign in to comment.