Module: Test

Defined in:
lib/rubytest.rb,
lib/rubytest/advice.rb,
lib/rubytest/config.rb,
lib/rubytest/runner.rb,
lib/rubytest/recorder.rb,
lib/rubytest/code_snippet.rb,
lib/rubytest/format/abstract.rb

Defined Under Namespace

Modules: Reporters Classes: Advice, CodeSnippet, Config, Recorder, Runner

Class Method Summary collapse

Class Method Details

.configObject

Stores test configurations.



4
5
6
# File 'lib/rubytest/config.rb', line 4

def self.config
  @config ||= {}
end

.configuration(profile = nil, reconfigurable = false) ⇒ Config

Get the current configuration.

Returns:



31
32
33
34
# File 'lib/rubytest/config.rb', line 31

def self.configuration(profile=nil, reconfigurable=false)
  @reconfigure = true if reconfigurable
  config[profile.to_s] ||= Config.new
end

.configure(profile = nil, &block) ⇒ Config

Configure test run via a block then will be passed a ‘Config` instance.

Returns:



11
12
13
14
15
16
17
# File 'lib/rubytest/config.rb', line 11

def self.configure(profile=nil, &block)
  if reconfigure?
    configuration(profile).apply(profile, &block)
  else
    config[profile.to_s] = Config.new(&block)
  end
end

.const_missing(name) ⇒ Object

Lookup missing constant in project index.



21
22
23
# File 'lib/rubytest.rb', line 21

def self.const_missing(name)
  index[name.to_s.downcase] || super(name)
end

.indexObject

Load project index on demand.



11
12
13
14
15
16
17
18
# File 'lib/rubytest.rb', line 11

def self.index
  @index ||= (
    require 'yaml'
    __dir__  = File.dirname(__FILE__)
    file = File.expand_path('rubytest.yml', __dir__)
    YAML.load_file(file)
  )
end

.reconfigure?Config

Reconfigure test run via a block then will be passed the Config instance. Unlike ‘configure` this does not create a new Config instance, but instead augments the current configuration.

Returns:



24
25
26
# File 'lib/rubytest/config.rb', line 24

def self.reconfigure?
  @reconfigure
end

.run(profile = nil, &config_proc) ⇒ Object

Alias for ‘Test.configure`. Use #run! to run tests immediately.



6
7
8
# File 'lib/rubytest/runner.rb', line 6

def self.run(profile=nil, &config_proc)
  configure(profile, &config_proc)
end

.run!(config = nil, &config_proc) ⇒ void

TODO:

Should this method return the success instead of exiting?

TODO:

Wrap run in at_exit ?

This method returns an undefined value.

Configure and run immediately.



16
17
18
19
20
21
22
23
24
25
# File 'lib/rubytest/runner.rb', line 16

def self.run!(config=nil, &config_proc)
  begin
    success = Runner.run(config, &config_proc)
    exit -1 unless success
  rescue => error
    raise error if $DEBUG
    $stderr.puts('ERROR: ' + error.to_s)
    exit -1
  end
end