[rspec-users] how to refactor signin process for re-use?

S Ahmed sahmed1020 at gmail.com
Thu Mar 8 23:15:00 UTC 2012

In my authenticate_pages.spec (requests) I do the following to test if the
signin worked:

 describe "with valid information" do
      #let(:account) { FactoryGirl.create(:account) }
      let(:user) { FactoryGirl.create(:user) }

      before do
        fill_in "Email", with: user.email
        fill_in "Password", with: user.password
        click_button "Sign in"

      it { should have_link('Sign out', href: signout_path) }
      it { should_not have_link('Sign in', href: signin_path) }

Now in my other controllers that assume the user is signed in, how can I
refactor this and put it somewhere that I can just call to make the user
signed in so I can test pages that assume the user is already signed in?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120308/273b16f7/attachment.html>

More information about the rspec-users mailing list