Sha256: ed74dc2e6988ba576b05f1283802ecb19a894db963af99b59ed39ad60bee243b

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 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) {text_field(:name, 'first_nm')}
    face(:last) {text_field(:name, 'last_nm')}
  end

  # this Address defines street name
  module Address
    include Watirloo::Page
    face :street do
      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 ) { text_field(:name, 'dob') }
    face( :gender ) { 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

2 entries across 2 versions & 1 rubygems

Version Path
watirloo-0.0.8 spec/face_mixing_spec.rb
watirloo-0.0.7 spec/face_mixing_spec.rb