Topic: Making Tests for Articles using Rspec

Hello,
I am trying to make some tests using Rspec for users updating and editing their own articles that they have posted. I am already off to a weak start. I am trying to test for a user that is not signed in, but I get the following error: "Validation failed: Email has already been taken".

Here's the test:

  describe "authentication of article edit/update pages" do

    before(:each) do
      @user = Factory(:user)
      @article = Factory(:article)
    end

    describe "for non-signed-in users" do

      it "should deny access to 'edit'" do
        get :edit, :id => @article
        response.should redirect_to(@article)
      end

      it "should deny access to 'update'" do
        put :update, :id => @article, :article => {}
        response.should redirect_to(@article)
      end

    end

  end

Here's the factory file:

Factory.define :user do |user|
  user.name "Michael Hartl"
  user.email "mhartl@railstutorials.org"
  user.password "foobar"
  user.password_confirmation "foobar"
end

Factory.sequence :email do |n|
  "person-#{n}@example.com"
end

Factory.define :article do |article|
  article.title "Article Title"
  article.content "Article Content"
  article.association :user
end

Also, I want to create a before(:each) do....end block where the newly generated Factory user creates an article, and they are connected in the sense that if I look up the user of the article, it will return the generated Factory user. How would I do that? (trying to test that only the user that created the article can edit and delete the article). Thank you very much.