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

+ (Object) alone!

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

+ (Boolean) alone?

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



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

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

+ (Context) context(description, context_class = Context, &definition)

A helper for creating/defining root context instances.



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

+ (Object) dots

Tells Riot to use DotMatrixReporter for reporting



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

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

+ (Hash) options

Options that configure how Riot will 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

+ (Object) plain!

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

+ (Object) pretty_dots

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

+ (Class) reporter

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



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

def self.reporter
  Riot.silently? ? Riot::SilentReporter : Riot.options[:reporter]
end

+ (Object) reporter=(reporter_class)

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



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

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

+ (Hash) reporter_options

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



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

def self.reporter_options
  Riot.options[:reporter_options]
end

+ (Array) root_contexts

The set of Context instances that have no parent.



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

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

+ (Riot::Reporter) run

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.



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

+ (Object) silently!

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

+ (Boolean) silently?

Reponds to whether Riot is reporting silently.



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

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

+ (Object) verbose

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