Sha256: 37d1967db7ce47c398525f717a374942c518b068f76383cf4ee81b9933b3c75f

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'


describe "Class client mixing interfaces from other modules" do

  # Examples of Interface usage in Watirloo
  # define interface to first and last name
  module FullName
    include Watirloo::Page
    face(:first) {doc.text_field(:name, 'first_nm')}
    face(:last) {doc.text_field(:name, 'last_nm')}
  end

  # this Address defines street name
  module Address
    include Watirloo::Page
    face :street do
      doc.text_field(:name, 'addr1')
    end
  end

  # this page is a composition of interfaces that may appear by themselves
  # as pages in an application.
  # think of a Page as some container. It can be entire page or part of Page
  # This page is composed of interfaces that appear in Address, FullName
  # but become interface to PersonalInfo
  # method face is shortcut for interface
  class PersonalInfo
    include Address
    include FullName
    include Watirloo::Page
    face( :dob ) { doc.text_field(:name, 'dob') }
    face( :gender ) { doc.select_list(:name, 'sex_cd') }
  end
  

  before :each do
    @page = PersonalInfo.new
    @page.browser.goto testfile('person.html')
  end

  it 'spray and scrape example' do
    data = {
      :first => 'Inzynier',
      :last => 'Maliniak',
      :gender => 'M',
      :dob => '03/25/1956',
      :street => '1313 Lucky Ave'
    }
    @page.spray data # send params to the page to enter the data
    data_return = @page.scrape data.keys
    data_return.should == data
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
marekj-watirloo-0.0.5 spec/face_mixing_spec.rb