2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2020

09/16/2010: Tracking RSPEC Test Execution So Debugging Statements Are Segmented

Tracking RSPEC Test Execution So Debugging Statements Are Segmented

Throw the following into an initializer:

module Spec
  module Example
    module ExampleMethods
      def execute_with_print_logging(run_options, instance_variables)
        p "RSPEC TRACE: #{description} => #{@_proxy.location}"
        execute_without_print_logging(run_options, instance_variables)
      end
      alias_method_chain :execute, :print_logging
    end
 end
end

09/16/2010: How Do I Expose the Current RSPEC File and Description

My goal with this monkey patch was to expose the rspec filename and description as global variables so that my exception handling code can know which rspec test caused the exception.
module Spec
  module Example
    module ExampleMethods
      alias :old_execute execute
      def execute(run_options, instance_variables)
        $rspec_location = @_proxy.location
        $rspec_description = description
        old_execute(run_options, instance_variables)
      end
    end
 end
end