title: Spec RSpec model attribute setter
body: <p>I'm using Sinatra (1.2) and RSpec (2.5) and would like to create a new object with an attribute TDD style. This is how the end result should look like:</p>
  
  <pre><code>class User
    def initialize(name)
      @name = name
    end
  end
  </code></pre>
  
  <p>I know I have to write the example before the implementation but I'm trying to explain my question here. :) Here is the not working spec I have so far:</p>
  
  <pre><code>describe User
    it "creates a new user object" do
      name = mock("A name")
      user = mock(User) # shouldn't do this, see the reply's
      user.should_receive(:name=).with(name)
      User.new(name)
    end
  end
  </code></pre>
  
  <p>When I run RSpec I get the "expected: 1 time, received 0 times" error. Any idea how I can explain RSpec I would like to assign the name attribute?</p>
  
  <p>Note: I'm not using Rails, not using ActiveRecord or anything, just Ruby.</p>