title: Testing a loop behaviour using Rspec
body: <p>The code:</p>
  
  <pre><code>def self.api_create(params)
    user_image = UserImage.new(params)
    begin
      user_image.uid = UniqueId.generate[0..7]
    end 
  
    while not(UserImage.find_all_by_uid(user_image.uid).empty?)
      return user_image
    end
  end
  </code></pre>
  
  <p>unique_id is the primary key of UserImage</p>
  
  <p>How can test the following test case?:</p>
  
  <pre><code>it "should create a new unique id if the one generated is already in use." do
  
  end
  </code></pre>