Sha256: 9f134d6d41aa3668d83b18c5ddadaaea05385c09acbc2c3bbaa10633b8cd18f4

Contents?: true

Size: 1.22 KB

Versions: 8

Compression:

Stored size: 1.22 KB

Contents

module TestCentricity
  class ExceptionQueue
    @error_queue

    def self.enqueue_assert_equal(expected, actual, error_message)
      unless expected == actual
        @error_queue = "#{@error_queue}#{error_message} to be\n  #{expected}\nbut found\n  #{actual}\n\n"
        screen_shot_and_save_page
      end
    end

    def self.enqueue_assert_not_equal(expected, actual, error_message)
      unless expected != actual
        @error_queue = "#{@error_queue}#{error_message} to not be equal to #{expected}\n\n"
        screen_shot_and_save_page
      end
    end

    def self.enqueue_exception(error_message)
      @error_queue = "#{@error_queue}#{error_message}\n\n"
    end

    def self.post_exceptions
      raise @error_queue unless @error_queue.nil?
    ensure
      @error_queue = nil
    end
  end

  private


  def self.screen_shot_and_save_page
    timestamp = Time.now.strftime('%Y%m%d%H%M%S')
    filename = "Screenshot-#{timestamp}"
    path = File.join Dir.pwd, "reports/screenshots/", filename
    save_screenshot "#{path}.png"
    puts "Screenshot saved at #{path}.png"
    screen_shot = { :path => path, :filename => filename }
    Environ.save_screen_shot(screen_shot)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
testcentricity_web-0.4.4 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.4.3 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.4.2 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.4.1 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.4.0 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.3.9 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.3.8 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.3.7 lib/testcentricity_web/exception_queue_helper.rb