title: Testing sequence of events with RSpec
body: <p>I was just starting out with RSpec, and im trying to do something quite trivial, but I couldnt find any good documentation on a good way of doing this. I want to test a sequence of events, say the friendship between two users.</p>
  
  <p>My spec is:</p>
  
  <pre><code>describe User do
  
    describe "friendships" do
      describe ".friends?" do
        before do
          @user1 = FactoryGirl.build(:user)
          @user2 = FactoryGirl.build(:user)
        end
  
        it "should be false for non friends" do
          @user1.friends?(@user2).should be false
          @user2.friends?(@user1).should be false
        end
  
        it "should be false for requested friendship" do
          Friendship.create(:user_id =&gt; @user1.id, :friend_id =&gt; @user2.id)  # 1
          @user1.friends?(@user2).should be false
          @user2.friends?(@user1).should be false
        end
  
        it "should be true for accepted friendship" do
          Friendship.for_users(@user1, @user2).update_attribute(:approved, true) # 2
          @user1.friends?(@user2).should be true
          @user2.friends?(@user1).should be true
        end
      end
  
    end
  end
  </code></pre>
  
  <p>I am creating a friendship at the line marked <code># 1</code>, and expect it to be present at line <code># 2</code>, but I am guessing the database gets flushed in between the two. </p>
  
  <p>Is this the wrong way of testing such a flow of events? What should I be doing? Any pointers would be much appreciated.</p>