natritmeyer/site_prism — pull request #98 by TheMetalCode (2014-12-19 17:48:03+00:00)
Title: Allow for excluded elements in a page's all_there? check

Let's say the page I'm modeling with a SitePrism::Page class has one or more modals with their own elements and functionality, and I'd like to declare them as SitePrism::Sections.

```ruby
class SomePage < SitePrism::Page

element :name_field, '#name'
section :upload_file_modal, UploadFileModal, '#upload_file_modal'

end
```

If I ever wished to leverage that page's all_there? check, it would fail because the modal section would not actually be present until the modal was opened. And yet, I would very much like to use the page's all_there? check and would still like all the advantages of a Section class to use for modeling modals.

This pull request adds the ability for any page class to define an excluded_elements method, which would return an array of elements to exclude from the all_there? check.

This would also be useful if one were using an element declaration to identify elements that aren't always there on initial page load (error or success messages, etc). This would allow those kinds of elements to enjoy the benefits of other SitePrism declared elements (build in has_element? checks, etc) while still maintaining a functional all_there? check for the page.

I'm already using this implementation in a project of mine so I thought it best to share it here. All feedback welcome, naturally.