Topic: Making Tests for Articles using Rspec

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)

    describe "for non-signed-in users" do

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

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



Here's the factory file:

Factory.define :user do |user| "Michael Hartl" ""
  user.password "foobar"
  user.password_confirmation "foobar"

Factory.sequence :email do |n|

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

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.