title: rspec mocking object property assignment
body: <p>I have a rspec mocked object, a value is assign to is property. I am struggleing to have that expectation met in my rspec test. Just wondering what the sytax is? The code:</p>
  
  <pre><code>def create
  @new_campaign = AdCampaign.new(params[:new_campaign])
  @new_campaign.creationDate = "#{Time.now.year}/#{Time.now.mon}/#{Time.now.day}"
  if @new_campaign.save
    flash[:status] = "Success"
  else
    flash[:status] = "Failed"
  end end
  </code></pre>
  
  <p>The test</p>
  
  <pre><code>it "should able to create new campaign when form is submitted" do
    campaign_model = mock_model(AdCampaign)
    AdCampaign.should_receive(:new).with(params[:new_campaign]).and_return(campaign_model)
    campaign_model.should_receive(:creationDate).with("#{Time.now.year}/#{Time.now.mon}/#{Time.now.day}")campaign_model.should_receive(:save).and_return(true)
    post :create
  
    flash[:status].should == 'Success' 
    response.should render_template('create') end
  </code></pre>
  
  <p>The problem is I am getting this error:</p>
  
  <pre><code>Spec::Mocks::MockExpectationError in 'CampaignController new campaigns should able to create new campaign when form is submitted' Mock "AdCampaign_1002" received unexpected message :creationDate= with ("2010/5/7")
  </code></pre>
  
  <p>So how do i set a expectation for object property assignment?</p>
  
  <p>Thanks</p>