Skip to content

5 Integrating with RSpec

Justin Watts edited this page Feb 27, 2017 · 1 revision

Using a SiteObject

When employing a SiteObject, we recommend that you pollute RSpec's context/namespace. =

# site.rb
module Ferris
  module SiteObject
    class MyWebsite
      SiteObject.configure do
        base_url('http://www.mywebsite.com')

        page(:home_page, MyWebsite::Home)
        region(:header,  MyWebsite::Header)      { browser.div(id: 'siteheader') }
      end

      def logged_in?
        header.logout_button.exists?
      end

    end
  end
end

# spec_helper.rb
RSpec.configure do |c|
  c.include Ferris::SiteObject
end

c.before(:each) do
  Ferris::Browser.browser = Watir::Browser.new :chrome
end

c.after(:each) do
  Ferris::Browser.browser.close
end

Using PageObjects

# spec_helper.rb
c.before(:each) do
  Ferris::Browser.browser = Watir::Browser.new :chrome
end

c.after(:each) do
  Ferris::Browser.browser.close
end
Clone this wiki locally