Thursday, September 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
Post a Comment