Module: Test
- Defined in:
- lib/rubytest.rb,
lib/rubytest/cli.rb,
lib/rubytest/rake.rb,
lib/rubytest/advice.rb,
lib/rubytest/config.rb,
lib/rubytest/result.rb,
lib/rubytest/runner.rb,
lib/rubytest/recorder.rb,
lib/rubytest/code_snippet.rb,
lib/rubytest/format/abstract.rb
Defined Under Namespace
Modules: Rake, Reporters Classes: Advice, CLI, CodeSnippet, Config, Recorder, Result, RunSummary, Runner
Constant Summary collapse
- VERSION =
'0.11.1'
Class Method Summary collapse
-
.config ⇒ Object
Stores test configurations.
-
.configuration(profile = nil, reconfigurable = false) ⇒ Config
Get the current configuration.
-
.configure(profile = nil, &block) ⇒ Config
Configure test run via a block then will be passed a
Configinstance. -
.error_report(error) ⇒ String
What
run!prints for an error raised outside of any test, such as one raised while a test file loads: the error's class and message, where it was raised, and how to see the rest of the backtrace. -
.reconfigure? ⇒ Config
Reconfigure test run via a block then will be passed the Config instance.
-
.run(profile = nil, &config_proc) ⇒ Object
Alias for
Test.configure. -
.run!(config = nil, &config_proc) ⇒ void
Configure and run immediately.
Class Method Details
.config ⇒ Object
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.
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.
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 |
.error_report(error) ⇒ String
What run! prints for an error raised outside of any test, such as one
raised while a test file loads: the error's class and message, where it
was raised, and how to see the rest of the backtrace.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rubytest/runner.rb', line 34 def self.error_report(error) = error..to_s report = "ERROR: #{error.class}" report << ": #{}" unless .empty? || == error.class.name if location = (error.backtrace || []).first report << "\n at #{location}" end report << "\n(Use --debug, or ruby -d, for the full backtrace.)" report 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.
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.
8 9 10 |
# File 'lib/rubytest/runner.rb', line 8 def self.run(profile=nil, &config_proc) configure(profile, &config_proc) end |
.run!(config = nil, &config_proc) ⇒ void
Should this method return the success instead of exiting?
Wrap run in at_exit ?
This method returns an undefined value.
Configure and run immediately.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubytest/runner.rb', line 18 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_report(error)) exit -1 end end |