Parent

Spork::TestFramework

Constants

LOAD_PREFERENCE
BOOTSTRAP_FILE

Attributes

stdout[R]
stderr[R]

Public Class Methods

available?() click to toggle source

Returns true if the testing frameworks helper file exists. Override if this is not sufficient to detect your testing framework.

     # File lib/spork/test_framework.rb, line 110
110:   def self.available?
111:     File.exist?(helper_file)
112:   end
available_test_frameworks() click to toggle source

Returns a list of all testing servers that have detected their testing framework being used in the project.

    # File lib/spork/test_framework.rb, line 65
65:   def self.available_test_frameworks
66:     supported_test_frameworks.select { |s| s.available? }
67:   end
default_port() click to toggle source
    # File lib/spork/test_framework.rb, line 56
56:   def self.default_port
57:     (ENV["#{short_name.upcase}_DRB"] || self::DEFAULT_PORT).to_i
58:   end
factory(output = STDOUT, error = STDERR, beginning_with = nil) click to toggle source
    # File lib/spork/test_framework.rb, line 40
40:   def self.factory(output = STDOUT, error = STDERR, beginning_with = nil)
41:     if beginning_with
42:       @klass = supported_test_frameworks(beginning_with).first
43:       raise(NoFrameworkMatched.new(beginning_with)) if @klass.nil?
44:       raise(FrameworkNotAvailable.new(@klass)) unless @klass.available?
45:     else
46:       @klass = available_test_frameworks.first
47:       raise(NoFrameworksAvailable.new) unless @klass
48:     end
49:     @klass.new(output, error)
50:   end
helper_file() click to toggle source
    # File lib/spork/test_framework.rb, line 52
52:   def self.helper_file
53:     self::HELPER_FILE
54:   end
load_preference_index() click to toggle source

Used to specify

     # File lib/spork/test_framework.rb, line 115
115:   def self.load_preference_index
116:     LOAD_PREFERENCE.index(short_name) || LOAD_PREFERENCE.length
117:   end
new(stdout = STDOUT, stderr = STDERR) click to toggle source
    # File lib/spork/test_framework.rb, line 36
36:   def initialize(stdout = STDOUT, stderr = STDERR)
37:     @stdout, @stderr = stdout, stderr
38:   end
short_name() click to toggle source
    # File lib/spork/test_framework.rb, line 60
60:   def self.short_name
61:     self.name.gsub('Spork::TestFramework::', '')
62:   end
supported_test_frameworks(starting_with = nil) click to toggle source

Returns a list of all servers that have been implemented (it keeps track of them automatically via Class.inherited)

    # File lib/spork/test_framework.rb, line 70
70:   def self.supported_test_frameworks(starting_with = nil)
71:     @@supported_test_frameworks.sort! { |a,b| a.load_preference_index <=> b.load_preference_index }
72:     return @@supported_test_frameworks if starting_with.nil?
73:     @@supported_test_frameworks.select do |s|
74:       s.short_name.match(/^#{Regexp.escape(starting_with)}/)
75:     end
76:   end

Protected Class Methods

inherited(subclass) click to toggle source
     # File lib/spork/test_framework.rb, line 158
158:     def self.inherited(subclass)
159:       @@supported_test_frameworks << subclass
160:     end

Public Instance Methods

bootstrap() click to toggle source

Bootstraps the current test helper file by prepending a Spork.prefork and Spork.each_run block at the beginning.

     # File lib/spork/test_framework.rb, line 92
 92:   def bootstrap
 93:     if bootstrapped?
 94:       stderr.puts "Already bootstrapped!"
 95:       return
 96:     end
 97:     stderr.puts "Bootstrapping #{helper_file}."
 98:     contents = File.read(helper_file)
 99:     bootstrap_code = File.read(BOOTSTRAP_FILE)
100:     File.open(helper_file, "wb") do |f|
101:       f.puts bootstrap_code
102:       f.puts contents
103:     end
104: 
105:     stderr.puts "Done. Edit #{helper_file} now with your favorite text editor and follow the instructions."
106:     true
107:   end
bootstrapped?() click to toggle source

Detects if the test helper has been bootstrapped.

    # File lib/spork/test_framework.rb, line 87
87:   def bootstrapped?
88:     File.read(helper_file).include?("Spork.prefork")
89:   end
default_port() click to toggle source
     # File lib/spork/test_framework.rb, line 153
153:   def default_port
154:     self.class.default_port
155:   end
entry_point() click to toggle source
     # File lib/spork/test_framework.rb, line 149
149:   def entry_point
150:     bootstrapped? ? helper_file : framework.entry_point
151:   end
helper_file() click to toggle source
    # File lib/spork/test_framework.rb, line 82
82:   def helper_file
83:     self.class.helper_file
84:   end
preload() click to toggle source
     # File lib/spork/test_framework.rb, line 119
119:   def preload
120:     Spork.exec_prefork do
121:       unless bootstrapped?
122:         stderr.puts "#{helper_file} has not been bootstrapped.  Run spork --bootstrap to do so."
123:         stderr.flush
124: 
125:         if framework.bootstrap_required?
126:           stderr.puts "I can't do anything for you by default for the framework your using: #{framework.short_name}.\nYou must bootstrap #{helper_file} to continue."
127:           stderr.flush
128:           return false
129:         else
130:           load(framework.entry_point)
131:         end
132:       end
133: 
134:       framework.preload do
135:         if bootstrapped?
136:           stderr.puts "Loading Spork.prefork block..."
137:           stderr.flush
138:           load(helper_file)
139:         end
140:       end
141:     end
142:     true
143:   end
run_tests(argv, stderr, stdout) click to toggle source
     # File lib/spork/test_framework.rb, line 145
145:   def run_tests(argv, stderr, stdout)
146:     raise NotImplementedError
147:   end
short_name() click to toggle source
    # File lib/spork/test_framework.rb, line 78
78:   def short_name
79:     self.class.short_name
80:   end

Protected Instance Methods

framework() click to toggle source
     # File lib/spork/test_framework.rb, line 162
162:     def framework
163:       @framework ||= Spork::AppFramework.detect_framework
164:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.