more flexible login in spec helper
This commit is contained in:
parent
d58ce31b7f
commit
a858ceedea
2 changed files with 4 additions and 6 deletions
|
@ -9,7 +9,7 @@ describe 'the session', :type => :feature do
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
end
|
end
|
||||||
it 'logs me in' do
|
it 'logs me in' do
|
||||||
login user.nick, user.password
|
login user
|
||||||
expect(page).to_not have_selector('.alert-error')
|
expect(page).to_not have_selector('.alert-error')
|
||||||
end
|
end
|
||||||
it 'does not log me in with wrong password' do
|
it 'does not log me in with wrong password' do
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
|
|
||||||
module SessionHelper
|
module SessionHelper
|
||||||
|
|
||||||
def login(nick=nil, password=nil)
|
def login(user=nil, password=nil)
|
||||||
visit login_path
|
visit login_path
|
||||||
if nick.nil?
|
user = FactoryGirl.create :user if user.nil?
|
||||||
user = FactoryGirl.create :user
|
nick, password = user.nick, user.password if user.instance_of? ::User
|
||||||
nick, password = user.nick, user.password
|
|
||||||
end
|
|
||||||
fill_in 'nick', :with => nick
|
fill_in 'nick', :with => nick
|
||||||
fill_in 'password', :with => password
|
fill_in 'password', :with => password
|
||||||
find('input[type=submit]').click
|
find('input[type=submit]').click
|
||||||
|
|
Loading…
Reference in a new issue