title: How can you stub a method on an OpenStruct?
body: <p>I have an rspec test that does the following:</p>
  
  <pre><code>  enrollment_hash = {
        checked_dependents: []
    }
    enrollment = OpenStruct.new enrollment_hash
  
    org_plan_response.new(enrollment)
  </code></pre>
  
  <p>and in the org_plan_response I have:</p>
  
  <pre><code>@enrollment.requires_termination_reason?(x, y)
  </code></pre>
  
  <p>I would like to stub out the requires_termination_reason in the test but can't figure it out.</p>
  
  <p>I tried: <code>enrollment.stub(:requires_termination_reason?).with('x', 'y').and_return { false }</code></p>
  
  <p>but get:</p>
  
  <blockquote>
    <p>NoMethodError: undefined method `stub' for #&lt; OpenStruct checked_dependents=[]></p>
  </blockquote>
  
  <p>Any help would be appreciated!</p>