Sha256: b837084ed9b12d6ab0b65a43f60723c9754ad696c4022a6587226b503755ab9d

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require "capybara/dsl"
require "testable/situation"
require "testable/element"

module Testable
  include Situation
  module Interface
    module Page
      include Capybara::DSL

      module Attribute
        include Situation

        def url_is(url = nil)
          url_is_empty if url.nil? || url.empty?
          @url = url
        end

        def title_is(title = nil)
          title_is_empty if title.nil? || title.empty?
          @title = title
        end

        def url_attribute
          @url
        end

        def title_attribute
          @title
        end
      end

      def view
        no_url_provided if (url.nil? || url == 'data:,') && url_attribute.nil?
        visit(url_attribute)
      end

      def url
        current_url
      end

      def url_attribute
        self.class.url_attribute
      end

      def title_attribute
        self.class.title_attribute
      end

      def secure?
        !url.match(/^https/).nil?
      end

      private

      def find_first(*locator)
        find(*locator)
      end

      def find_all(*locator)
        all(*locator)
      end

      def element_exists?(*locator)
        has_selector?(*locator)
      end

      def element_does_not_exist?(*locator)
        has_no_selector?(*locator)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
testable-0.2.0 lib/testable/interface.rb