Created
March 2, 2019 13:47
-
-
Save amalrik/b536de729cd01731b99efb1260dc094b to your computer and use it in GitHub Desktop.
Using Page Object Pattern in rspec - POP final
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NewPostForm | |
include Capybara::DSL # Capybara | |
include FactoryBot::Syntax::Methods # FactoryBot | |
include Warden::Test::Helpers # Devise | |
include Rails.application.routes.url_helpers # Routes | |
def login(user) | |
login_as(user, :scope => :user) | |
self | |
end | |
def visit_page | |
visit new_post_path | |
self | |
end | |
def fill_in_with(params={}) | |
within("#new_post") do | |
fill_in 'post_title', with: params.fetch(:post_title) | |
fill_in 'post_input_content', with: params.fetch(:post_input_content) | |
end | |
self | |
end | |
def submit | |
click_button 'Publish' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment