module RSpec::Illustrate
Extension module to RSpec
that allows you to define illustrations in the examples that will be forwarded to the output formatter.
Constants
- VERSION
The version used by gemspec
Public Instance Methods
illustrate(content, *args)
click to toggle source
Stores an object in the surrounding example’s metadata, which can be used by the output formatter as an illustration for the example. @param content The object that will act as an illustration. @param args [Array<Hash, Symbol>] Additional options. @return The given illustration object.
# File lib/rspec/illustrate.rb, line 14 def illustrate(content, *args) illustration = { :text => content.to_s, :show_when_passed => true, :show_when_failed => true, :show_when_pending => true } args.each{|arg| illustration[arg] = true if arg.is_a?(Symbol) illustration.merge!(arg) if arg.kind_of?(Hash) } RSpec.current_example.metadata[:illustrations] << illustration content end