module Protest

Constants

VERSION

Public Class Methods

add_report(name, report) click to toggle source

Register a new Report. This will make your report available to Protest, allowing you to run your tests through this report. For example

module Protest
  class Reports::MyAwesomeReport < Report
  end

  add_report :awesomesauce, MyAwesomeReport
end

See Protest.report_with to see how to select which report will be used.

# File lib/protest.rb, line 19
def self.add_report(name, report)
  reports[name] = report
end
autorun=(flag) click to toggle source

Set to false to avoid running tests at_exit. Default is true.

# File lib/protest.rb, line 24
def self.autorun=(flag)
  @autorun = flag
end
autorun?() click to toggle source

Checks to see if tests should be run at_exit or not. Default is true. See Protest.autorun=

# File lib/protest.rb, line 30
def self.autorun?
  !!@autorun
end
backtrace_filter() click to toggle source

The object that filters the backtrace

# File lib/protest.rb, line 77
def self.backtrace_filter
  @backtrace_filter
end
backtrace_filter=(filter) click to toggle source

Set what object will filter the backtrace. It must respond to filter_backtrace, taking a backtrace array and a prefix path.

# File lib/protest.rb, line 72
def self.backtrace_filter=(filter)
  @backtrace_filter = filter
end
context(description, &block) click to toggle source

Define a top level test context where to define tests. This works exactly the same as subclassing TestCase explicitly.

Protest.context "A user" do
  ...
end

is just syntax sugar to write:

class TestUser < Protest::TestCase
  self.description = "A user"
  ...
end
# File lib/protest/test_case.rb, line 15
def self.context(description, &block)
  TestCase.context(description, caller.at(0), &block)
end
Also aliased as: describe
describe(description, &block)
Alias for: context
fail_early=(flag) click to toggle source

Set to true if tests should stop on the first failure. Default is false

# File lib/protest.rb, line 35
def self.fail_early=(flag)
  @fail_early = flag
end
fail_early?() click to toggle source

Checks to see if tests should stop on the first failure. Default is false See Protest.fail_early=

# File lib/protest.rb, line 41
def self.fail_early?
  !!@fail_early
end
report(name, *report_args) click to toggle source

Load a report by name, initializing it with the extra arguments provided. If the given name doesn't match a report registered via Protest.add_report then the method will raise IndexError.

# File lib/protest.rb, line 66
def self.report(name, *report_args)
  reports.fetch(name).new(*report_args)
end
report_with(name, *report_args) click to toggle source

Select the name of the Report to use when running tests. See Protest.add_report for more information on registering a report.

Any extra arguments will be forwarded to the report's initialize method.

The default report is Protest::Reports::Documentation

# File lib/protest.rb, line 59
def self.report_with(name, *report_args)
  @report = report(name, *report_args)
end
run_all_tests!(options = {}) click to toggle source

Run all registered test cases through the selected report. You can pass arguments to the Report constructor here.

See Protest.add_test_case and Protest.report_with

# File lib/protest.rb, line 49
def self.run_all_tests!(options = {})
  Runner.new(@report).run(test_cases, options)
end
story(description, &block) click to toggle source
# File lib/protest/test_case.rb, line 22
def story(description, &block)
  warn "[DEPRECATED] `story` alias is deprecated. Use `describe` or `context` instead."
  context(description, &block)
end
test_cases() click to toggle source
# File lib/protest.rb, line 81
def self.test_cases
  @test_cases ||= []
end

Private Class Methods

reports() click to toggle source
# File lib/protest.rb, line 85
def self.reports
  @reports ||= {}
end