Sha256: b7db41679ccaf6762dd735edf58dbcfab78dcc5d3b938c33f1fc664bbdb3ea2f

Contents?: true

Size: 872 Bytes

Versions: 1

Compression:

Stored size: 872 Bytes

Contents

module Prickle
  module Capybara

    class ElementNotFound < Exception; end;

    class Error

      def initialize type, identifier, text, caught_exception
        @element_type = type
        @element_identifier = identifier
        @element_text = text
        @caught_exception = caught_exception
      end

      def message
        "#{element_text} with properties #{identifier} #{text_string} was not found.\n\tError: #{@caught_exception.message}"
      end

      private

      def element_text
        return highlight(@element_type) unless @element_type == "*"
        "Element"
      end

      def text_string
        " and text #{highlight(@element_text)}" unless @element_text.nil?
      end

      def identifier
        highlight(@element_identifier.to_s)
      end

      def highlight text
        "\e[1m#{text}\e[0m\e[31m"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prickle-0.0.2 lib/prickle/capybara/exceptions.rb