Module: Autotest::LucidMixin
- Included in:
- Lucid, LucidRails, LucidRailsRspec, LucidRailsRspec2, LucidRspec, LucidRspec2
- Defined in:
- lib/autotest/lucid_mixin.rb
Instance Attribute Summary collapse
-
#specs_to_run ⇒ Object
Returns the value of attribute specs_to_run.
Class Method Summary collapse
Instance Method Summary collapse
- #all_specs_good ⇒ Object
- #get_to_green ⇒ Object
- #initialize ⇒ Object
- #make_lucid_cmd(specs_to_run, dirty_specs_filename) ⇒ Object
- #rerun_all_specs ⇒ Object
- #reset_specs ⇒ Object
- #run ⇒ Object
- #run_specs ⇒ Object
Instance Attribute Details
#specs_to_run ⇒ Object
Returns the value of attribute specs_to_run.
11 12 13 |
# File 'lib/autotest/lucid_mixin.rb', line 11 def specs_to_run @specs_to_run end |
Class Method Details
.included(receiver) ⇒ Object
7 8 9 |
# File 'lib/autotest/lucid_mixin.rb', line 7 def self.included(receiver) receiver::ALL_HOOKS << [:run_specs, :ran_specs] end |
Instance Method Details
#all_specs_good ⇒ Object
48 49 50 |
# File 'lib/autotest/lucid_mixin.rb', line 48 def all_specs_good specs_to_run == "" end |
#get_to_green ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/autotest/lucid_mixin.rb', line 52 def get_to_green begin super run_specs wait_for_changes unless all_specs_good end until all_specs_good end |
#initialize ⇒ Object
13 14 15 16 |
# File 'lib/autotest/lucid_mixin.rb', line 13 def initialize super reset_specs end |
#make_lucid_cmd(specs_to_run, dirty_specs_filename) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/autotest/lucid_mixin.rb', line 108 def make_lucid_cmd(specs_to_run, dirty_specs_filename) return '' if specs_to_run == '' profile_loader = Lucid::CLI::Profile.new profile ||= "autotest-all" if profile_loader.has_profile?("autotest-all") && specs_to_run == :all profile ||= "autotest" if profile_loader.has_profile?("autotest") profile ||= nil if profile args = ["--profile", profile] else args = %w{--format} << (specs_to_run == :all ? "progress" : "standard") end # No --color option as some IDEs (Netbeans) don't output them very well ([31m1 failed step[0m) args += %w{--format rerun --out} << dirty_specs_filename args << (specs_to_run == :all ? "" : specs_to_run) unless specs_to_run == :all args << 'steps' << 'common' end args = args.join(' ') return "#{Lucid::RUBY_BINARY} #{Lucid::BINARY} #{args}" end |
#rerun_all_specs ⇒ Object
60 61 62 63 |
# File 'lib/autotest/lucid_mixin.rb', line 60 def rerun_all_specs reset_specs run_specs end |
#reset_specs ⇒ Object
65 66 67 |
# File 'lib/autotest/lucid_mixin.rb', line 65 def reset_specs self.specs_to_run = :all end |
#run ⇒ Object
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 46 |
# File 'lib/autotest/lucid_mixin.rb', line 18 def run hook :initialize reset reset_specs add_sigint_handler self.last_mtime = Time.now if $f loop do begin get_to_green if self.tainted then rerun_all_tests rerun_all_specs if all_good else hook :all_good end wait_for_changes # Once tests and specs are running green, this should reset specs # every time a file is changed to see if anything breaks. reset_specs rescue Interrupt break if self.wants_to_quit reset reset_specs end end hook :quit end |
#run_specs ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/autotest/lucid_mixin.rb', line 69 def run_specs hook :run_specs Tempfile.open('autotest-lucid') do |dirty_specs_file| cmd = self.make_lucid_cmd(self.specs_to_run, dirty_specs_file.path) return if cmd.empty? puts cmd unless $q old_sync = $stdout.sync $stdout.sync = true self.results = [] line = [] begin open("| #{cmd}", "r") do |f| until f.eof? do c = f.getc or break if RUBY_VERSION >= "1.9" then print c else putc c end line << c if c == ?\n then self.results << if RUBY_VERSION >= "1.9" then line.join else line.pack "c*" end line.clear end end end ensure $stdout.sync = old_sync end self.specs_to_run = dirty_specs_file.read.strip self.tainted = true unless self.specs_to_run == '' end hook :ran_specs end |