Class Index [+]

Quicksearch

Autotest::CucumberMixin

Attributes

features_to_run[RW]

Public Class Methods

included(receiver) click to toggle source
   # File lib/autotest/cucumber_mixin.rb, line 7
7:   def self.included(receiver)
8:     receiver::ALL_HOOKS << [:run_features, :ran_features]
9:   end
new() click to toggle source
    # File lib/autotest/cucumber_mixin.rb, line 13
13:   def initialize
14:     super
15:     reset_features
16:   end

Public Instance Methods

all_features_good() click to toggle source
    # File lib/autotest/cucumber_mixin.rb, line 48
48:   def all_features_good
49:     features_to_run == ""
50:   end
get_to_green() click to toggle source
    # File lib/autotest/cucumber_mixin.rb, line 52
52:   def get_to_green
53:     begin
54:       super
55:       run_features
56:       wait_for_changes unless all_features_good
57:     end until all_features_good
58:   end
make_cucumber_cmd(features_to_run, dirty_features_filename) click to toggle source
     # File lib/autotest/cucumber_mixin.rb, line 108
108:   def make_cucumber_cmd(features_to_run, dirty_features_filename)
109:     return '' if features_to_run == ''
110:     
111:     profile_loader = Cucumber::Cli::ProfileLoader.new
112:     
113:     profile ||= "autotest-all" if profile_loader.has_profile?("autotest-all") && features_to_run == :all
114:     profile ||= "autotest"     if profile_loader.has_profile?("autotest")
115:     profile ||= nil
116:     
117:     if profile
118:       args = ["--profile", profile]
119:     else
120:       args = %{--format} << (features_to_run == :all ? "progress" : "pretty")
121:     end
122:     # No --color option as some IDEs (Netbeans) don't output them very well (1 failed step)
123:     args += %{--format rerun --out} << dirty_features_filename
124:     args << (features_to_run == :all ? "" : features_to_run)
125:     
126:     # Unless I do this, all the steps turn up undefined during the rerun...
127:     unless features_to_run == :all
128:       args << 'features/step_definitions' << 'features/support'
129:     end
130:     
131:     args = args.join(' ')
132: 
133:     return "#{Cucumber::RUBY_BINARY} #{Cucumber::BINARY} #{args}"
134:   end
rerun_all_features() click to toggle source
    # File lib/autotest/cucumber_mixin.rb, line 60
60:   def rerun_all_features
61:     reset_features
62:     run_features
63:   end
reset_features() click to toggle source
    # File lib/autotest/cucumber_mixin.rb, line 65
65:   def reset_features
66:     self.features_to_run = :all
67:   end
run() click to toggle source
    # File lib/autotest/cucumber_mixin.rb, line 18
18:   def run
19:     hook :initialize
20:     reset
21:     reset_features
22:     add_sigint_handler
23: 
24:     self.last_mtime = Time.now if $f
25: 
26:     loop do # ^c handler
27:       begin
28:         get_to_green
29:         if self.tainted then
30:           rerun_all_tests
31:           rerun_all_features if all_good
32:         else
33:           hook :all_good
34:         end
35:         wait_for_changes
36:         # Once tests and features are green, reset features every
37:         # time a file is changed to see if anything breaks.
38:         reset_features
39:       rescue Interrupt
40:         break if self.wants_to_quit
41:         reset
42:         reset_features
43:       end
44:     end
45:     hook :quit
46:   end
run_features() click to toggle source
     # File lib/autotest/cucumber_mixin.rb, line 69
 69:   def run_features
 70:     hook :run_features
 71:     Tempfile.open('autotest-cucumber') do |dirty_features_file|
 72:       cmd = self.make_cucumber_cmd(self.features_to_run, dirty_features_file.path)
 73:       return if cmd.empty?
 74:       puts cmd unless $q
 75:       old_sync = $stdout.sync
 76:       $stdout.sync = true
 77:       self.results = []
 78:       line = []
 79:       begin
 80:         open("| #{cmd}", "r") do |f|
 81:           until f.eof? do
 82:             c = f.getc or break
 83:             if RUBY_VERSION >= "1.9" then
 84:               print c
 85:             else
 86:               putc c
 87:             end
 88:             line << c
 89:             if c == \n\ then
 90:               self.results << if RUBY_VERSION >= "1.9" then
 91:                                 line.join
 92:                               else
 93:                                 line.pack "c*"
 94:                               end
 95:               line.clear
 96:             end
 97:           end
 98:         end
 99:       ensure
100:         $stdout.sync = old_sync
101:       end
102:       self.features_to_run = dirty_features_file.read.strip
103:       self.tainted = true unless self.features_to_run == ''
104:     end
105:     hook :ran_features
106:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.