Sha256: 555244833b6c7c87909b122e55c48f43db3ac79cb7f6123687ee657e566b4dba

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

require 'spec/example/example_group'

#
# Monkey-patch RSpec Example Group so that we can track whether an
# example already failed or not in an after(:each) block
#
# useful to only capture Selenium screenshots when a test fails  
#
# Only changed execution_error to be an instance variable (in lieu of 
# a local variable).
#
module Spec
  module Example
    
    class ExampleGroup
      attr_reader :execution_error

      def execute(options, instance_variables)
        options.reporter.example_started(self)
        set_instance_variables_from_hash(instance_variables)
        
        @execution_error = nil
        Timeout.timeout(options.timeout) do
          begin
            before_example
            run_with_description_capturing
          rescue Exception => e
            @execution_error ||= e
          end
          begin
            after_example
          rescue Exception => e
            @execution_error ||= e
          end
        end

        options.reporter.example_finished(self, @execution_error)
        success = @execution_error.nil? || ExamplePendingError === @execution_error
      end
      
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
selenium-client-1.2 lib/selenium/rspec/rspec_extensions.rb
selenium-client-1.2.3 lib/selenium/rspec/rspec_extensions.rb
selenium-client-1.2.5 lib/selenium/rspec/rspec_extensions.rb
selenium-client-1.2.1 lib/selenium/rspec/rspec_extensions.rb
selenium-client-1.2.4 lib/selenium/rspec/rspec_extensions.rb
selenium-client-1.2.2 lib/selenium/rspec/rspec_extensions.rb