Sha256: f476f0cfccba55f9c7160c0df3b1e4035296b52b642e642d907eb743f09bec38

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 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"
        save_screenshot
      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"
        save_screenshot
      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.save_screenshot
    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

4 entries across 4 versions & 1 rubygems

Version Path
testcentricity_web-0.4.8 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.4.7 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.4.6 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.4.5 lib/testcentricity_web/exception_queue_helper.rb