Sha256: 7abcd3e0a08c1311137af90dbcc11d722accc24f456240d22724932f59336b51

Contents?: true

Size: 1.25 KB

Versions: 33

Compression:

Stored size: 1.25 KB

Contents

module TestCentricity
  class ExceptionQueue
    include Capybara::DSL

    @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"
        enqueue_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"
        enqueue_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

    private

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

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
testcentricity_web-0.7.8 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.7.7 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.7.6 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.7.5 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.7.4 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.7.3 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.7.2 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.7.1 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.7.0 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.6.9 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.6.8 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.6.7 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.6.6.1 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.6.6 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.6.5 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.6.4.2 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.6.4.1 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.6.4 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.6.3 lib/testcentricity_web/exception_queue_helper.rb
testcentricity_web-0.6.2 lib/testcentricity_web/exception_queue_helper.rb