Module: Riot

Defined in:
lib/riot.rb,
lib/riot/rr.rb,
lib/riot/version.rb,
lib/riot/message.rb,
lib/riot/context.rb,
lib/riot/runnable.rb,
lib/riot/reporter.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/context_helpers.rb,
lib/riot/reporter/silent.rb,
lib/riot/context_options.rb,
lib/riot/assertion_macro.rb,
lib/riot/reporter/dot_matrix.rb,
lib/riot/assertion_macros/nil.rb,
lib/riot/assertion_macros/any.rb,
lib/riot/assertion_macros/size.rb,
lib/riot/assertion_macros/empty.rb,
lib/riot/assertion_macros/raises.rb,
lib/riot/assertion_macros/equals.rb,
lib/riot/assertion_macros/exists.rb,
lib/riot/assertion_macros/matches.rb,
lib/riot/assertion_macros/assigns.rb,
lib/riot/assertion_macros/kind_of.rb,
lib/riot/assertion_macros/includes.rb,
lib/riot/reporter/pretty_dot_matrix.rb,
lib/riot/assertion_macros/respond_to.rb,
lib/riot/assertion_macros/same_elements.rb,
lib/riot/assertion_macros/equivalent_to.rb,
lib/riot/assertion_macros/raises_kind_of.rb

Overview

The namespace for all of Riot.

Defined Under Namespace

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

Constant Summary

VERSION =
"0.12.7"

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.



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

def self.alone!
  Riot.options[:alone] = true
end

.alone?Boolean

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

Returns:

  • (Boolean)


76
77
78
# File 'lib/riot.rb', line 76

def self.alone?
  Riot.options[: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



109
110
111
# File 'lib/riot.rb', line 109

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

.optionsHash

Options that configure how Riot will run.

Returns:

  • (Hash)

    the options that tell Riot how to run



47
48
49
50
51
52
53
54
# File 'lib/riot.rb', line 47

def self.options
  @options ||= {
    :silent => false,
    :alone => false,
    :reporter => Riot::StoryReporter,
    :reporter_options => {:plain => false}
  }
end

.plain!Object

Tells Riot to turn color off in the output



119
120
121
# File 'lib/riot.rb', line 119

def self.plain!
  Riot.reporter_options[:plain] = true
end

.pretty_dotsObject

Tells Riot to use PrettyDotMatrixReporter for reporting



114
115
116
# File 'lib/riot.rb', line 114

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



91
92
93
# File 'lib/riot.rb', line 91

def self.reporter
  Riot.silently? ? Riot::SilentReporter : Riot.options[:reporter]
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



83
84
85
# File 'lib/riot.rb', line 83

def self.reporter=(reporter_class)
  Riot.options[:reporter] = reporter_class
end

.reporter_optionsHash

Returns the options that will be passed to the Reporter when it is created.

Returns:

  • (Hash)

    the Hash of current options



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

def self.reporter_options
  Riot.options[:reporter_options]
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(Riot.reporter_options)
  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”.



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

def self.silently!
  Riot.options[:silent] = true
end

.silently?Boolean

Reponds to whether Riot is reporting silently.

Returns:

  • (Boolean)


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

def self.silently?
  Riot.options[: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



104
105
106
# File 'lib/riot.rb', line 104

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