title: Testing presence and belongs_to with Rspec
body: <p>I'm trying to learn how to test with Rspec. </p>
  
  <p>At the moment I have a spec for an Item class:</p>
  
  <pre><code>require 'spec_helper'
  
  describe Item do
    it { should belong_to :list }
  
    before(:each) do
      @item = FactoryGirl.create(:item)
    end
  
    subject { @item }
  
    it { should respond_to :name }
    it { should validate_presence_of :name }
  
  end
  </code></pre>
  
  <p>I have a couple of questions about this , though.</p>
  
  <p>Is <code>it { should validate_presence_of :name }</code> the same as writing:</p>
  
  <pre><code>describe "when name is not present" do
    before { @item.name = "" }
    it { should_not be_valid }
  end
  </code></pre>
  
  <p>or is there a crucial difference between the two?</p>
  
  <p>I was also wondering if <code>it { should belong_to :list }</code> is worth writing in a spec, or if there's a better way for this. </p>
  
  <p>I also know I can do <code>@item = FactoryGirl.build(:item)</code> or <code>FactoryGirl.create(:item)</code>. Does create save the item to the test db and build doesn't? Or am I confused here. When should I use which?</p>
  
  <p>Thanks.</p>