class Runtest::Command
Constants
- SYNTAX
Attributes
file_name[RW]
line_number[RW]
options[RW]
Public Class Methods
new(argument)
click to toggle source
# File lib/runtest/command.rb, line 6 def initialize argument arguments = argument.split ':' @file_name = arguments[0] || "" @line_number = arguments[1].to_i || 0 @base_command = "bundle exec ruby -Itest" raise FileNotFound unless File.exists? file_name end
Public Instance Methods
base_command()
click to toggle source
# File lib/runtest/command.rb, line 39 def base_command @base_command ||= "ruby -Itest" end
closest_example()
click to toggle source
# File lib/runtest/command.rb, line 23 def closest_example line_at_line_number.gsub SYNTAX, '' end
consolidated_command()
click to toggle source
# File lib/runtest/command.rb, line 56 def consolidated_command [ base_command, file_name, options ].join ' ' end
file_contents()
click to toggle source
# File lib/runtest/command.rb, line 47 def file_contents File.read(file_name).split "\n" end
line_at_line_number()
click to toggle source
# File lib/runtest/command.rb, line 43 def line_at_line_number file_contents[line_number].strip end
perform!()
click to toggle source
# File lib/runtest/command.rb, line 15 def perform! if line_number <= 0 run_test else run_test "-n '#{closest_example}'" end end
run_test(options="")
click to toggle source
# File lib/runtest/command.rb, line 51 def run_test options="" @options = options system consolidated_command end