使用 formulaic 填表單

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem "byebug"
  gem "rspec-rails"
  gem "factory_girl_rails"
  gem "shoulda-matchers"
  gem "capybara"
+  gem "formulaic"
end

在 spec/support/page_objects/base.rb

module PageObjects
  class Base
    include Capybara::DSL
+    include Formulaic::Dsl
    include Rails.application.routes.url_helpers
  end
end

require_relative "../../base"

module PageObjects
  module Devise
    module Sessions
      class New < Base

        def sign_in(email, password)

          within(".new_user") do
            fill_in 'Email', :with => '[email protected]'
            fill_in 'Password', :with => 'password'
          end
          click_button "Log in"
        end
      end
    end
  end
end

修改成

require_relative "../../base"

module PageObjects
  module Devise
    module Sessions
      class New < Base

        def sign_in(email, password)

          fill_form :user, email: email, password: password
          click_button "Log in"
        end
      end
    end
  end
end

results matching ""

    No results matching ""