title: How to stub property on factory object in RSpec
body: <p>How do I stub this property? </p>
  
  <p>user.rb</p>
  
  <pre><code>def my_method
    scheduling_frequency_minutes = self.business.settings_group.scheduling_frequency.minutes
    # where scheduling_frequency is an integer field in the settings_group model
    # but this is still set to the default (60), not 30
  end
  </code></pre>
  
  <p>user_spec.rb</p>
  
  <pre><code>it "get available time slots (on the half hour)" do
  
    # 1st attempt:
    @business.settings_group.scheduling_frequency = 30
    # where @business is the same Business pointed to by 'self.business' in the user.rb model
  
    # 2nd attempt:
    #Business.stub_chain(:settings_group, :scheduling_frequency).and_return(30)
  
    #3rd attempt:
  
    settings_group = mock("settings_group")
    settings_group.stub(:scheduling_frequency).and_return(30)
    @business.should_receive(:settings_group).and_return(settings_group)
  
    @business.users.all.first.my_method
  end
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Here's my latest attempt and it STILL doesn't work. What's going on??</p>
  
  <pre><code>user = @business.users.all.first
  user.stub_chain(:business, :settings_group, :scheduling_frequency).and_return(30)
  user.my_method()
  </code></pre>
  
  <p>-</p>
  
  <pre><code>  def my_method
      debugger
      # p self.business.settings_group.scheduling_frequency -&gt; 60
    end
  </code></pre>