Class: Turn::Configuration
- Inherits:
-
Object
- Object
- Turn::Configuration
- Defined in:
- lib/turn/configuration.rb
Overview
Central interface for Turn configuration.
Instance Attribute Summary collapse
-
#exclude ⇒ Object
List of file names or globs to exclude from
tests
list. -
#format ⇒ Object
Reporter type.
-
#framework ⇒ Object
Test framework, either :minitest or :testunit.
-
#live ⇒ Object
Test against live install (i.e. Don’t use loadpath option).
-
#loadpath ⇒ Object
Add these folders to the $LOAD_PATH.
-
#log ⇒ Object
Log results? May be true/false or log file name.
-
#matchcase ⇒ Object
Regexp pattern that all test cases must match to be eligible to run.
-
#natural ⇒ Object
Use natural language case names.
-
#pattern ⇒ Object
Regexp pattern that all test name’s must match to be eligible to run.
-
#requires ⇒ Object
Libs to require when running tests.
-
#runmode ⇒ Object
Run mode.
-
#tests ⇒ Object
List of if file names or glob pattern of tests to run.
-
#trace ⇒ Object
Enable full backtrace.
-
#verbose ⇒ Object
Verbose output?.
Instance Method Summary collapse
- #ansi=(boolean) ⇒ Object
- #ansi? ⇒ Boolean
- #environment_trace ⇒ Object
-
#files ⇒ Object
Test files.
- #live? ⇒ Boolean
- #natural? ⇒ Boolean
-
#reporter ⇒ Object
Select reporter based on output mode.
-
#suite_name ⇒ Object
TODO: Better name ?.
- #verbose? ⇒ Boolean
Instance Attribute Details
#exclude ⇒ Object
List of file names or globs to exclude from tests
list.
20 21 22 |
# File 'lib/turn/configuration.rb', line 20 def exclude @exclude end |
#format ⇒ Object
Reporter type.
37 38 39 |
# File 'lib/turn/configuration.rb', line 37 def format @format end |
#framework ⇒ Object
Test framework, either :minitest or :testunit
52 53 54 |
# File 'lib/turn/configuration.rb', line 52 def framework @framework end |
#live ⇒ Object
Test against live install (i.e. Don’t use loadpath option)
43 44 45 |
# File 'lib/turn/configuration.rb', line 43 def live @live end |
#loadpath ⇒ Object
Add these folders to the $LOAD_PATH.
31 32 33 |
# File 'lib/turn/configuration.rb', line 31 def loadpath @loadpath end |
#log ⇒ Object
Log results? May be true/false or log file name. (TODO)
46 47 48 |
# File 'lib/turn/configuration.rb', line 46 def log @log end |
#matchcase ⇒ Object
Regexp pattern that all test cases must match to be eligible to run.
28 29 30 |
# File 'lib/turn/configuration.rb', line 28 def matchcase @matchcase end |
#natural ⇒ Object
Use natural language case names.
58 59 60 |
# File 'lib/turn/configuration.rb', line 58 def natural @natural end |
#pattern ⇒ Object
Regexp pattern that all test name’s must match to be eligible to run.
24 25 26 |
# File 'lib/turn/configuration.rb', line 24 def pattern @pattern end |
#requires ⇒ Object
Libs to require when running tests.
34 35 36 |
# File 'lib/turn/configuration.rb', line 34 def requires @requires end |
#runmode ⇒ Object
Run mode.
40 41 42 |
# File 'lib/turn/configuration.rb', line 40 def runmode @runmode end |
#tests ⇒ Object
List of if file names or glob pattern of tests to run.
17 18 19 |
# File 'lib/turn/configuration.rb', line 17 def tests @tests end |
#trace ⇒ Object
Enable full backtrace
55 56 57 |
# File 'lib/turn/configuration.rb', line 55 def trace @trace end |
#verbose ⇒ Object
Verbose output?
49 50 51 |
# File 'lib/turn/configuration.rb', line 49 def verbose @verbose end |
Instance Method Details
#ansi=(boolean) ⇒ Object
121 122 123 |
# File 'lib/turn/configuration.rb', line 121 def ansi=(boolean) @ansi = boolean ? true : false end |
#ansi? ⇒ Boolean
63 |
# File 'lib/turn/configuration.rb', line 63 def ansi? ; @ansi ; end |
#environment_trace ⇒ Object
191 192 193 |
# File 'lib/turn/configuration.rb', line 191 def environment_trace (ENV['backtrace'] ? ENV['backtrace'].to_i : nil) end |
#files ⇒ Object
Test files.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/turn/configuration.rb', line 142 def files @files ||= ( fs = tests.map do |t| File.directory?(t) ? Dir[File.join(t, '**', '*')] : Dir[t] end fs = fs.flatten.reject{ |f| File.directory?(f) } ex = exclude.map do |x| File.directory?(x) ? Dir[File.join(x, '**', '*')] : Dir[x] end ex = ex.flatten.reject{ |f| File.directory?(f) } (fs - ex).uniq.map{ |f| File.(f) } ).flatten end |
#live? ⇒ Boolean
61 |
# File 'lib/turn/configuration.rb', line 61 def live? ; @live ; end |
#natural? ⇒ Boolean
62 |
# File 'lib/turn/configuration.rb', line 62 def natural? ; @natural ; end |
#reporter ⇒ Object
Select reporter based on output mode.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/turn/configuration.rb', line 164 def reporter @reporter ||= ( opts = { :trace=>trace, :natural=>natural? } case format when :marshal require 'turn/reporters/marshal_reporter' Turn::MarshalReporter.new($stdout, opts) when :progress require 'turn/reporters/progress_reporter' Turn::ProgressReporter.new($stdout, opts) when :dotted, :dot require 'turn/reporters/dot_reporter' Turn::DotReporter.new($stdout, opts) when :pretty require 'turn/reporters/pretty_reporter' Turn::PrettyReporter.new($stdout, opts) when :cue require 'turn/reporters/cue_reporter' Turn::CueReporter.new($stdout, opts) else require 'turn/reporters/outline_reporter' Turn::OutlineReporter.new($stdout, opts) end ) end |
#suite_name ⇒ Object
TODO: Better name ?
159 160 161 |
# File 'lib/turn/configuration.rb', line 159 def suite_name files.map{ |path| File.dirname(path).sub(Dir.pwd+'/','') }.uniq.join(',') end |
#verbose? ⇒ Boolean
60 |
# File 'lib/turn/configuration.rb', line 60 def verbose? ; @verbose ; end |