Topic: Understanding Rspec Integration Testing / login method..

Hi Folks,

I'm a testing noob. I'm writing tests for an existing app that uses rails 2.3.5, spec 1.3.1, and rspec-rails 1.3.3 & Capybara.

Here's my snippet of code:

require 'spec_helper'

describe "Users" do
  before(:each) do
    @user = Factory(:user)
  end
  
  it "login" do
    visit login_path
    fill_in :login, :with => @user.email
    fill_in :password, :with => @user.password
    click_button "login_button"
    page.has_content?("Logged in successfully")
  end
  
  it "create profile" do
     visit new_social_profile_path  
  end
  
end

Here's my question. Most of my tests will require that a user should be logged in. How do I keep this dry in my integration specs so I'm not creating a login method each time?

Sorry if this is a trivial question.

Chris

Re: Understanding Rspec Integration Testing / login method..

will @user = test_sign_in(Factory(:user)) in the before (:each) block work?