lib/autotest/lucid_mixin.rb in lucid-0.1.1 vs lib/autotest/lucid_mixin.rb in lucid-0.2.0
- old
+ new
@@ -3,75 +3,75 @@
require 'lucid'
require 'lucid/cli/profile'
module Autotest::LucidMixin
def self.included(receiver)
- receiver::ALL_HOOKS << [:run_features, :ran_features]
+ receiver::ALL_HOOKS << [:run_specs, :ran_specs]
end
- attr_accessor :features_to_run
+ attr_accessor :specs_to_run
def initialize
super
- reset_features
+ reset_specs
end
def run
hook :initialize
reset
- reset_features
+ reset_specs
add_sigint_handler
self.last_mtime = Time.now if $f
- loop do # ^c handler
+ loop do
begin
get_to_green
if self.tainted then
rerun_all_tests
- rerun_all_features if all_good
+ rerun_all_specs if all_good
else
hook :all_good
end
wait_for_changes
- # Once tests and features are green, reset features every
- # time a file is changed to see if anything breaks.
- reset_features
+ # 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_features
+ reset_specs
end
end
hook :quit
end
- def all_features_good
- features_to_run == ""
+ def all_specs_good
+ specs_to_run == ""
end
def get_to_green
begin
super
- run_features
- wait_for_changes unless all_features_good
- end until all_features_good
+ run_specs
+ wait_for_changes unless all_specs_good
+ end until all_specs_good
end
- def rerun_all_features
- reset_features
- run_features
+ def rerun_all_specs
+ reset_specs
+ run_specs
end
- def reset_features
- self.features_to_run = :all
+ def reset_specs
+ self.specs_to_run = :all
end
- def run_features
- hook :run_features
- Tempfile.open('autotest-lucid') do |dirty_features_file|
- cmd = self.make_lucid_cmd(self.features_to_run, dirty_features_file.path)
+ 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 = []
@@ -97,35 +97,34 @@
end
end
ensure
$stdout.sync = old_sync
end
- self.features_to_run = dirty_features_file.read.strip
- self.tainted = true unless self.features_to_run == ''
+ self.specs_to_run = dirty_specs_file.read.strip
+ self.tainted = true unless self.specs_to_run == ''
end
- hook :ran_features
+ hook :ran_specs
end
- def make_lucid_cmd(features_to_run, dirty_features_filename)
- return '' if features_to_run == ''
+ 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") && features_to_run == :all
+ 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} << (features_to_run == :all ? "progress" : "standard")
+ 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_features_filename
- args << (features_to_run == :all ? "" : features_to_run)
+ args += %w{--format rerun --out} << dirty_specs_filename
+ args << (specs_to_run == :all ? "" : specs_to_run)
- # Unless I do this, all the steps turn up undefined during the rerun...
- unless features_to_run == :all
+ unless specs_to_run == :all
args << 'steps' << 'common'
end
args = args.join(' ')