重構 sign_out_spec

require "rails_helper"

describe "user sign out", :type => :feature do
  it "sign out the user" do
    user = User.create(:email => "[email protected]", :password => "password")

    new_session_page.sign_in "[email protected]", "password"
    navbar.sign_out user.email

    expect(page).not_to have_content "[email protected]"
  end

  private

  def home_page
    PageObjects::Pages::Home.new
  end

  def navbar
    PageObjects::Application::Navbar.new
  end

  def new_session_page
    home_page.go
    navbar.sign_in
  end
end
require_relative "../base"

module PageObjects
  module Application
    class Navbar < Base
      def sign_in
        click_on "Login"
        PageObjects::Devise::Sessions::New.new
      end

+      def sign_out(email)
+        user_dropdown(email).click_on "Logout"
+      end
+
+      def user_dropdown(email)
+        dropdown email
+      end
+
+      private
+
+        def dropdown(text)
+          find ".navbar .dropdown", text: text
+        end
+
    end
  end
end

results matching ""

    No results matching ""