Top Level Namespace
Instance Method Summary collapse
- #all_test_files ⇒ Object
- #execute(cmd) ⇒ Object
- #find_in_load_path(path) ⇒ Object
- #no_int_for_you ⇒ Object
- #run(files_to_run) ⇒ Object
- #run_all_tests ⇒ Object
- #run_test_matching(thing_to_match) ⇒ Object
- #runner ⇒ Object
-
#test_folder ⇒ Object
————————————————– Convenience Methods ————————————————–.
- #test_suffix ⇒ Object
Instance Method Details
#all_test_files ⇒ Object
16 17 18 |
# File 'lib/watch-me-now.rb', line 16 def all_test_files Dir["#{test_folder}/**/*_#{test_suffix}.rb"] end |
#execute(cmd) ⇒ Object
47 48 49 50 |
# File 'lib/watch-me-now.rb', line 47 def execute(cmd) puts("> #{cmd}") system(cmd) end |
#find_in_load_path(path) ⇒ Object
4 5 6 7 |
# File 'bin/watch-me-now', line 4 def find_in_load_path(path) dir = (['.'] + $LOAD_PATH).uniq.detect {|p| Pathname(p).join(path).exist? } dir ? path.(dir) : nil end |
#no_int_for_you ⇒ Object
52 53 54 |
# File 'lib/watch-me-now.rb', line 52 def no_int_for_you @sent_an_int = nil end |
#run(files_to_run) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/watch-me-now.rb', line 37 def run(files_to_run) if files_to_run.strip.empty? puts "No files to run" else cmd = "#{runner} -I#{test_folder} #{files_to_run}" execute cmd end no_int_for_you end |
#run_all_tests ⇒ Object
33 34 35 |
# File 'lib/watch-me-now.rb', line 33 def run_all_tests run(all_test_files.join(' ')) end |
#run_test_matching(thing_to_match) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/watch-me-now.rb', line 24 def run_test_matching(thing_to_match) matches = all_test_files.grep(/#{thing_to_match}/i) if matches.empty? puts "Sorry, thanks for playing, but there were no matches for #{thing_to_match}" else run matches.join(' ') end end |
#runner ⇒ Object
20 21 22 |
# File 'lib/watch-me-now.rb', line 20 def runner ENV["WATCHR_RUNNER"] || "ruby" end |
#test_folder ⇒ Object
Convenience Methods
4 5 6 |
# File 'lib/watch-me-now.rb', line 4 def test_folder @test_folder ||= %w[spec examples test].detect { |p| File.directory?(p) } end |
#test_suffix ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/watch-me-now.rb', line 8 def test_suffix case test_folder when "spec" then "spec" when "examples" then "example" when "test" then "test" end end |