Class: Turn::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/turn/configuration.rb

Overview

Central interface for Turn configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#excludeObject

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

#formatObject

Reporter type.



37
38
39
# File 'lib/turn/configuration.rb', line 37

def format
  @format
end

#frameworkObject

TODO:

Is this used any more?

Test framework, either ‘:minitest` or `:testunit`.



56
57
58
# File 'lib/turn/configuration.rb', line 56

def framework
  @framework
end

#liveObject

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

#loadpathObject

Add these folders to the $LOAD_PATH.



31
32
33
# File 'lib/turn/configuration.rb', line 31

def loadpath
  @loadpath
end

#logObject

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

#markObject

Runtime threshold.



52
53
54
# File 'lib/turn/configuration.rb', line 52

def mark
  @mark
end

#matchcaseObject

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

#naturalObject

Use natural language case names.



62
63
64
# File 'lib/turn/configuration.rb', line 62

def natural
  @natural
end

#patternObject

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

#requiresObject

Libs to require when running tests.



34
35
36
# File 'lib/turn/configuration.rb', line 34

def requires
  @requires
end

#runmodeObject

Run mode.



40
41
42
# File 'lib/turn/configuration.rb', line 40

def runmode
  @runmode
end

#testsObject

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

#traceObject

Enable full backtrace



59
60
61
# File 'lib/turn/configuration.rb', line 59

def trace
  @trace
end

#verboseObject

Verbose output?



49
50
51
# File 'lib/turn/configuration.rb', line 49

def verbose
  @verbose
end

Instance Method Details

#ansi=(boolean) ⇒ Object



138
139
140
# File 'lib/turn/configuration.rb', line 138

def ansi=(boolean)
  @ansi = boolean ? true : false
end

#ansi?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/turn/configuration.rb', line 77

def ansi?
  @ansi
end

#environment_ansiObject



226
227
228
229
230
231
232
233
234
235
# File 'lib/turn/configuration.rb', line 226

def environment_ansi
  case ENV['ansi']
  when 'true','yes','on'
    true
  when 'false','no','off'
    false
  else
    nil
  end
end

#environment_formatObject



216
217
218
# File 'lib/turn/configuration.rb', line 216

def environment_format
  ENV['rpt']
end

#environment_traceObject



221
222
223
# File 'lib/turn/configuration.rb', line 221

def environment_trace
  (ENV['backtrace'] ? ENV['backtrace'].to_i : nil)
end

#filesObject

Test files.



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/turn/configuration.rb', line 159

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.expand_path(f) }
  ).flatten
end

#live?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/turn/configuration.rb', line 69

def live?
  @live
end

#natural?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/turn/configuration.rb', line 73

def natural?
  @natural
end

#reporterObject

Select reporter based on output mode.



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/turn/configuration.rb', line 181

def reporter
  @reporter ||= (
    opts = reporter_options
    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 :outline
      require 'turn/reporters/outline_reporter'
      Turn::OutlineReporter.new($stdout, opts)
    when :cue
      require 'turn/reporters/cue_reporter'
      Turn::CueReporter.new($stdout, opts)
    when :pretty
      require 'turn/reporters/pretty_reporter'
      Turn::PrettyReporter.new($stdout, opts)
    else
      require 'turn/reporters/pretty_reporter'
      Turn::PrettyReporter.new($stdout, opts)
    end
  )
end

#reporter_optionsObject



211
212
213
# File 'lib/turn/configuration.rb', line 211

def reporter_options
  { :trace=>trace, :natural=>natural?, :verbose=>verbose?, :mark=>mark }
end

#suite_nameObject

TODO: Better name ?



176
177
178
# File 'lib/turn/configuration.rb', line 176

def suite_name
  files.map{ |path| File.dirname(path).sub(Dir.pwd+'/','') }.uniq.join(',')
end

#verbose?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/turn/configuration.rb', line 65

def verbose?
  @verbose
end