Module: Riot

Defined in:
lib/riot.rb,
lib/riot/context.rb,
lib/riot/reporter.rb,
lib/riot/runnable.rb,
lib/riot/assertion.rb,
lib/riot/situation.rb,
lib/riot/assertion_macros.rb

Defined Under Namespace

Classes: Assertion, Context, DotMatrixReporter, IOReporter, Reporter, RootContext, RunnableBlock, Setup, SilentReporter, Situation, StoryReporter, VerboseStoryReporter

Class Method Summary collapse

Class Method Details

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



9
10
11
# File 'lib/riot.rb', line 9

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

.dotsObject



37
# File 'lib/riot.rb', line 37

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

.reporterObject



27
28
29
30
31
32
33
# File 'lib/riot.rb', line 27

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

.reporter=(reporter_class) ⇒ Object



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

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

.root_contextsObject



13
# File 'lib/riot.rb', line 13

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

.runObject



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

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

.silently!Object



22
# File 'lib/riot.rb', line 22

def self.silently!; @silent = true; end

.silently?Boolean

Returns:

  • (Boolean)


23
# File 'lib/riot.rb', line 23

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



36
# File 'lib/riot.rb', line 36

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