The namespace for all of Riot.
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
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
Tells Riot to use {Riot::DotMatrixReporter} for reporting
# File lib/riot.rb, line 109 def self.dots Riot.reporter = Riot::DotMatrixReporter end
Tells Riot to turn color off in the output
# File lib/riot.rb, line 119 def self.plain! Riot.reporter_options[:plain] = true end
Tells Riot to use {Riot::PrettyDotMatrixReporter} for reporting
# File lib/riot.rb, line 114 def self.pretty_dots Riot.reporter = Riot::PrettyDotMatrixReporter end
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
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
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
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
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
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
Reponds to whether Riot is reporting silently.
@return [Boolean]
# File lib/riot.rb, line 64 def self.silently? Riot.options[:silent] == true end
@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