Module: Riot

Defined in:
lib/riot.rb,
lib/riot/rr.rb,
lib/riot/context.rb,
lib/riot/message.rb,
lib/riot/version.rb,
lib/riot/reporter.rb,
lib/riot/runnable.rb,
lib/riot/assertion.rb,
lib/riot/situation.rb,
lib/riot/middleware.rb,
lib/riot/reporter/io.rb,
lib/riot/reporter/story.rb,
lib/riot/assertion_macro.rb,
lib/riot/context_helpers.rb,
lib/riot/context_options.rb,
lib/riot/reporter/silent.rb,
lib/riot/reporter/dot_matrix.rb,
lib/riot/assertion_macros/any.rb,
lib/riot/assertion_macros/nil.rb,
lib/riot/assertion_macros/size.rb,
lib/riot/assertion_macros/empty.rb,
lib/riot/assertion_macros/equals.rb,
lib/riot/assertion_macros/exists.rb,
lib/riot/assertion_macros/raises.rb,
lib/riot/assertion_macros/assigns.rb,
lib/riot/assertion_macros/kind_of.rb,
lib/riot/assertion_macros/matches.rb,
lib/riot/assertion_macros/includes.rb,
lib/riot/assertion_macros/not_borat.rb,
lib/riot/reporter/pretty_dot_matrix.rb,
lib/riot/assertion_macros/respond_to.rb,
lib/riot/assertion_macros/equivalent_to.rb,
lib/riot/assertion_macros/same_elements.rb

Overview

The namespace for all of Riot.

Defined Under Namespace

Modules: ContextClassOverrides, ContextHelpers, ContextOptions, RR Classes: AllImportantMiddleware, AnyMacro, Assertion, AssertionMacro, AssignsMacro, Context, ContextMiddleware, DotMatrixReporter, EmptyMacro, EqualsMacro, EquivalentToMacro, ExistsMacro, Helper, IOReporter, IncludesMacro, KindOfMacro, MatchesMacro, Message, NilMacro, NotMacro, PrettyDotMatrixReporter, RaisesMacro, Reporter, RespondToMacro, RootContext, RunnableBlock, SameElementsMacro, Setup, SilentReporter, Situation, SizeMacro, StoryReporter, VerboseStoryReporter

Constant Summary collapse

VERSION =
"0.12.3"

Class Method Summary collapse

Class Method Details

.alone!Object

This means you don’t want Riot to run tests for you. You will execute Riot.run manually.



57
58
59
# File 'lib/riot.rb', line 57

def self.alone!
  @alone = true
end

.alone?Boolean

Responds to whether Riot will run at_exit (false) or manually (true).

Returns:

  • (Boolean)


64
65
66
# File 'lib/riot.rb', line 64

def self.alone?
  defined?(@alone) && @alone == true
end

.context(description, context_class = Context, &definition) ⇒ Context

A helper for creating/defining root context instances.

Parameters:

  • description (String)

    the description of this context

  • context_class (Class) (defaults to: Context)

    the Context implementation to use

  • &definition (lambda)

    the context definition

Returns:



17
18
19
# File 'lib/riot.rb', line 17

def self.context(description, context_class = Context, &definition)
  (root_contexts << context_class.new(description, &definition)).last
end

.dotsObject

Tells Riot to use DotMatrixReporter for reporting



94
95
96
# File 'lib/riot.rb', line 94

def self.dots
  Riot.reporter = Riot::DotMatrixReporter
end

.pretty_dotsObject

Tells Riot to use PrettyDotMatrixReporter for reporting



99
100
101
# File 'lib/riot.rb', line 99

def self.pretty_dots
  Riot.reporter = Riot::PrettyDotMatrixReporter
end

.reporterClass

Returns the class for the reporter that is currently selected. If no reporter was explicitly selected, StoryReporter will be used.

Returns:

  • (Class)

    the Class that represents a Reporter



79
80
81
82
83
84
85
# File 'lib/riot.rb', line 79

def self.reporter
  if Riot.silently?
    Riot::SilentReporter
  else
    (defined?(@reporter_class) && @reporter_class) || Riot::StoryReporter
  end
end

.reporter=(reporter_class) ⇒ Object

Allows the reporter class to be changed. Do this before tests are started.

Parameters:

  • reporter_class (Class)

    the Class that represents a Reporter



71
72
73
# File 'lib/riot.rb', line 71

def self.reporter=(reporter_class)
  @reporter_class = reporter_class
end

.root_contextsArray

The set of Context instances that have no parent.

Returns:



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

def self.root_contexts
  @root_contexts ||= []
end

.runRiot::Reporter

How to run Riot itself. This should be called at_exit unless you suggested - by calling alone! that you want to call this method yourself. If no reporter is set, the default will be used.

You can change reporters by setting the manually via reporter= or by using one of: dots, silently!, or verbose.

Returns:



36
37
38
39
40
41
42
# File 'lib/riot.rb', line 36

def self.run
  the_reporter = reporter.new
  the_reporter.summarize do
    root_contexts.each { |ctx| ctx.run(the_reporter) }
  end unless root_contexts.empty?
  the_reporter
end

.silently!Object

This means you don’t want to see any output from Riot. A “quiet riot”.



45
46
47
# File 'lib/riot.rb', line 45

def self.silently!
  @silent = true
end

.silently?Boolean

Reponds to whether Riot is reporting silently.

Returns:

  • (Boolean)


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

def self.silently?
  defined?(@silent) && @silent == true
end

.verboseObject

TODO:

make this a flag that DotMatrix and Story respect and cause them to print errors/failures

Tells Riot to use VerboseStoryReporter for reporting



89
90
91
# File 'lib/riot.rb', line 89

def self.verbose
  Riot.reporter = Riot::VerboseStoryReporter
end