Sha256: b54209e353ba67b2af8f643a8656c1b84b1d6690acf073722752818e2e1952fa

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'helper'
require 'minitest/mock'

describe Kookaburra::UIDriver::UIComponent do
  it 'can have nested UIComponents' do
    InnerComponent = Class.new(Kookaburra::UIDriver::UIComponent)
    OuterComponent = Class.new(Kookaburra::UIDriver::UIComponent) do
      ui_component :inner_component
    end
    component = OuterComponent.new(:browser => Object.new)
    assert_kind_of InnerComponent, component.inner_component
  end

  let(:component_class) do
    Class.new(Kookaburra::UIDriver::UIComponent) do
      component_locator '#my_component'
      public :count
    end
  end

  describe '#count' do
    it 'returns the number of elements found within the component' do
      browser = Object.new.tap do |b|
        def b.within(*args)
          @context_set = true
          yield self
        end

        def b.all(*args)
          return unless @context_set
          Array.new(3)
        end
      end
      component = component_class.new(:browser => browser)
      assert_equal 3, component.count('.element')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kookaburra-0.12.0 test/kookaburra/ui_driver/ui_component_test.rb