Skip to content

Instantly share code, notes, and snippets.

@edymerchk
Last active December 25, 2015 14:39
Show Gist options
  • Save edymerchk/6992512 to your computer and use it in GitHub Desktop.
Save edymerchk/6992512 to your computer and use it in GitHub Desktop.
LoginMacros Rspec
#spec/spec_helper.rb
#add this
config.include LoginMacros
#features/private_area_specs.rb
before :each do
login @user
end
it 'works' do
visit private_path
page.should have_content("Private area")
end
# spec/support/login_macros.rb
module LoginMacros
def login(user)
visit root_path
click_link 'Login'
fill_in('Email', with: user.email)
fill_in('Password', with: user.password)
click_button "Login"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment