module Riot

The namespace for all of Riot.

Constants

RootContext
VERSION

Public Class Methods

alone!() click to toggle source

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

# File lib/riot.rb, line 69
def self.alone!
  Riot.options[:alone] = true
end
alone?() click to toggle source

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

@return [Boolean]

# File lib/riot.rb, line 76
def self.alone?
  Riot.options[:alone] == true
end
context(description, context_class = Context, &definition) click to toggle source

A helper for creating/defining root context instances.

@param [String] description the description of this context @param [Class] context_class the {Riot::Context} implementation to use @param [lambda] &definition the context definition @return [Context] the initialized {Riot::Context}

# File lib/riot.rb, line 17
def self.context(description, context_class = Context, &definition)
  (root_contexts << context_class.new(description, &definition)).last
end
dots() click to toggle source

Tells Riot to use {Riot::DotMatrixReporter} for reporting

# File lib/riot.rb, line 109
def self.dots
  Riot.reporter = Riot::DotMatrixReporter
end
options() click to toggle source

Options that configure how Riot will run.

@return [Hash] the options that tell Riot how to run

# File lib/riot.rb, line 47
def self.options
  @options ||= {
    :silent => false,
    :alone => false,
    :reporter => Riot::StoryReporter,
    :reporter_options => {:plain => false}
  }
end
plain!() click to toggle source

Tells Riot to turn color off in the output

# File lib/riot.rb, line 119
def self.plain!
  Riot.reporter_options[:plain] = true
end
pretty_dots() click to toggle source

Tells Riot to use {Riot::PrettyDotMatrixReporter} for reporting

# File lib/riot.rb, line 114
def self.pretty_dots
  Riot.reporter = Riot::PrettyDotMatrixReporter
end
reporter() click to toggle source

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

@return [Class] the Class that represents a {Riot::Reporter}

# File lib/riot.rb, line 91
def self.reporter
  Riot.silently? ? Riot::SilentReporter : Riot.options[:reporter]
end
reporter=(reporter_class) click to toggle source

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

@param [Class] reporter_class the Class that represents a {Riot::Reporter}

# File lib/riot.rb, line 83
def self.reporter=(reporter_class)
  Riot.options[:reporter] = reporter_class
end
reporter_options() click to toggle source

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

@return [Hash] the Hash of current options

# File lib/riot.rb, line 98
def self.reporter_options
  Riot.options[:reporter_options]
end
root_contexts() click to toggle source

The set of {Riot::Context} instances that have no parent.

@return [Array] instances of {Riot::Context}

# File lib/riot.rb, line 24
def self.root_contexts
  @root_contexts ||= []
end
run() click to toggle source

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

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

@return [Riot::Reporter] the reporter that was used

# 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!() click to toggle source

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

# File lib/riot.rb, line 57
def self.silently!
  Riot.options[:silent] = true
end
silently?() click to toggle source

Reponds to whether Riot is reporting silently.

@return [Boolean]

# File lib/riot.rb, line 64
def self.silently?
  Riot.options[:silent] == true
end
verbose() click to toggle source

@todo make this a flag that DotMatrix and Story respect and cause them to print errors/failures Tells Riot to use {Riot::VerboseStoryReporter} for reporting

# File lib/riot.rb, line 104
def self.verbose
  Riot.reporter = Riot::VerboseStoryReporter
end