appfolio / ae_page_objects

Page Objects for Capybara
MIT License
28 stars 9 forks source link

Support Site mounting #66

Closed dtognazzini closed 8 years ago

dtognazzini commented 10 years ago

The main purpose of the Site class is to provide routing for the contained page objects.

The common setup for a Rails app is define all the page objects within a single Site as all the page objects will share the same router.

When using mountable engines in Rails, routes are defined by engines and then mounted by the application. It's nice to have the engine provide page objects for its pages as they can be used by both the top level application and the dummy application used in the engine's tests. The colocation of the page objects and the engine, keeps the page objects and the corresponding engine's pages to evolve together.

Enhance Site with a way to compose other Site instances provided by engines.

Something like the following should be supported:

Engine1

class Engine1Page < AePageObjects::Document
  path :engine1_page
end

class Engine1Site < AePageObjects::Site
end

Engine2

class Engine2Page < AePageObjects::Document
  path :engine2_page
end

class Engine2Site < AePageObjects::Site
end

Application

class ApplicationPage < AePageObjects::Document
  path :application_page

  def submit!
    node.click('#submit_button')
    window.change_to(Engine1Page)
  end
end

class ApplicationSite < AePageObjects::Site
  mount Engine1Site, "/engine1directory"
  mount Engine2Site, "/engine2directory"
end
dtognazzini commented 8 years ago

Site is no more.