collectiveidea / capybara-ui

Page objects for readable, resilient acceptance tests
MIT License
6 stars 0 forks source link

Documentation: Convention recommendation for where to place Capybara::UI class definitions. #4

Closed manlycode closed 7 years ago

manlycode commented 10 years ago

The README doesn't recommend where to place definitions in the spec directory.

laserlemon commented 10 years ago

Good call. That's because I don't know what to recommend yet.

I've thought:

▾ spec
  ▾ support
    ▾ ui
      ▾ pages
          foo_page.rb
          bar_page.rb
      ▾ elements
          foo_table.rb
          bar_form.rb

or maybe just:

▾ spec
  ▾ support
    ▾ ui
        foo_page.rb
        bar_page.rb
        foo_table.rb
        bar_form.rb

Thoughts?

laserlemon commented 10 years ago

I also like Domino's convention of namespacing the classes:

module UI
  class FooPage < Capybara::UI
    # TODO
  end

  class BarPage < Capybara::UI
    # TODO
  end
end
manlycode commented 10 years ago

Support worked for me. But, convention over configuration. Amirite?

— Sent from Mailbox for iPhone

On Wed, Dec 25, 2013 at 3:16 PM, Steve Richert notifications@github.com wrote:

Good call. That's because I don't know what to recommend yet. I've thought:

▾ spec
  ▾ support
    ▾ ui
      ▾ pages
          foo_page.rb
          bar_page.rb
      ▾ elements
          foo_table.rb
          bar_form.rb

or maybe just:

▾ spec
  ▾ support
    ▾ ui
        foo_page.rb
        bar_page.rb
        foo_table.rb
        bar_form.rb

Thoughts?

Reply to this email directly or view it on GitHub: https://github.com/collectiveidea/capybara-ui/issues/4#issuecomment-31204691

laserlemon commented 10 years ago

I'm also wondering if pages should inherit from a more descriptive class than Capybara::UI like Capybara::UI::Page which has good symmetry with Capybara::UI::Element.

laserlemon commented 10 years ago

Ultimately, it doesn't matter where you put them as long as you load them before you run your suite. By default (and in most cases), the spec/support directory will be automatically loaded (as instructed by spec_helper.rb) so anywhere inside spec/support is a good candidate.

emilford commented 10 years ago

+1 to UI:: namespace, spec/support/{pages,elements}, and Capybara::UI::Page.

ersatzryan commented 10 years ago

since we don't HAVE to reference the class thanks to page.ui could namespace them under Capybara::UI

module Capybara::UI
  class PeoplePage < Page
  end

  class Person < Element
  end
end
ersatzryan commented 10 years ago

This also lends itself nicely to your first proposal of

▾ spec
  ▾ support
    ▾ ui
      ▾ pages
          foo_page.rb
          bar_page.rb
      ▾ elements
          foo_table.rb
          bar_form.rb
asheren commented 7 years ago

Hi there! We're doing some open source maintenance work and closing old issues. If this issue is still applicable or you would still like it to be addressed, please re-open the issue by April 17, 2017. Thanks!