Skip to content

Commit 18de599

Browse files
committed
Move login method to LoginHelper
1 parent 4bec0b5 commit 18de599

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

spec/features/user_login_and_logout_spec.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,4 @@
6262

6363
end
6464

65-
private
66-
67-
def login(email, password)
68-
fill_in "Email", with: email
69-
fill_in "Password", with: password
70-
click_button "Log in"
71-
end
72-
7365
end

spec/support/login_helper.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module LoginHelper
2+
3+
def login(*args)
4+
if args.size == 1 && args[0].is_a?(User)
5+
user = args[0]
6+
email = user.email
7+
password = user.password
8+
elsif args.size == 2
9+
email, password = args
10+
else
11+
raise "Unable to handle args #{args.inspect}"
12+
end
13+
14+
fill_in "Email", with: email
15+
fill_in "Password", with: password
16+
click_button "Log in"
17+
end
18+
19+
end
20+
21+
RSpec.configure do |config|
22+
config.include LoginHelper, type: :feature
23+
end

0 commit comments

Comments
 (0)