Method: Beaker::DSL::Structure#step

Defined in:
lib/beaker/dsl/structure.rb

#step(step_name, &block) ⇒ Object

Provides a method to help structure tests into coherent steps.

Parameters:

  • step_name (String)

    The name of the step to be logged.

  • block (Proc)

    The actions to be performed in this step.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/beaker/dsl/structure.rb', line 38

def step step_name, &block
  logger.notify "\n* #{step_name}\n"
  set_current_step_name(step_name)
  if block_given?
    begin
      logger.with_indent do
        yield
      end
    rescue Exception => e
      if(@options.has_key?(:debug_errors) && @options[:debug_errors] == true)
        logger.info("Exception raised during step execution and debug-errors option is set, entering pry. Exception was: #{e.inspect}")
        logger.info("HINT: Use the pry 'backtrace' and 'up' commands to navigate to the test code")
        binding.pry
      end
      raise e
    end
  end
end