Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Exercise 9.6.1

Refactor signin to "integratin_sign_in" method in spec_helper.rb
  • Loading branch information...
commit 912ebabe2e6d6a4c09391bd5c9ce2ae892870403 1 parent 5c92d26
David McMath authored
View
5 spec/requests/layout_links_spec.rb
@@ -52,10 +52,7 @@
describe 'when signed in' do
before(:each) do
@user = Factory(:user)
- visit signin_path
- fill_in :email, :with => @user.email
- fill_in :password, :with => @user.password
- click_button
+ integration_sign_in(@user)
end
it 'should have a signout link' do
View
15 spec/requests/users_spec.rb
@@ -31,9 +31,9 @@
end.should_not change(User, :count)
end
end
-
+
describe 'success' do
-
+
it 'should make a new user' do
lambda do
visit signup_path
@@ -42,14 +42,14 @@
fill_in 'Password', :with => 'foobar'
fill_in 'Confirmation', :with => 'foobar'
click_button
-
+
response.should have_selector('div.flash.success', :content => 'Welcome')
response.should render_template('users/show')
end.should change(User, :count).by(1)
end
end
end
-
+
describe 'sign in/out' do
describe 'failure' do
it 'should not sign a user in' do
@@ -60,14 +60,11 @@
response.should have_selector( 'div.flash.error', :content => 'Invalid' )
end
end
-
+
describe 'success' do
it 'should sign a user in and out' do
user = Factory(:user)
- visit signin_path
- fill_in :email, :with => user.email
- fill_in :password, :with => user.password
- click_button
+ integration_sign_in(user)
controller.should be_signed_in
click_link 'Sign out'
controller.should_not be_signed_in
View
7 spec/spec_helper.rb
@@ -28,4 +28,11 @@
def test_sign_in(user)
controller.sign_in(user)
end
+
+ def integration_sign_in(user)
+ visit signin_path
+ fill_in :email, :with => user.email
+ fill_in :password, :with => user.password
+ click_button
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.