title: RSpec stub object method with variable
body: <p>Testing out a helper and I've run into an issue.</p>
  
  <p>I have a scope on a model:
  <code>Task.due_within(days)</code></p>
  
  <p>And this is referenced in a helper:</p>
  
  <pre><code>module UsersHelper
    ...
    def show_alert(tasks, properties, user)
      pulse_alert(tasks, properties) ||
        tasks.due_within(7).count.positive? ||
        tasks.needs_more_info.count.positive? ||
        tasks.due_within(14).count.positive? ||
        tasks.created_since(user.last_sign_in_at).count.positive?
    end
    ...
  end
  </code></pre>
  
  <p>So I'm testing with stubs for <code>tasks</code>, <code>properties</code>, and <code>user</code>:</p>
  
  <pre><code>RSpec.describe UsersHelper, type: :helper do
    describe '#show_alert' do
      it 'returns true if there are tasks due within 7 days' do
        tasks = double(:task, due_within: [1, 2, 3, 4], past_due: [])
        properties = double(:property, over_budget: [], nearing_budget: [])
        user = double(:user)
  
        expect(helper.show_alert(tasks, properties, user)).to eq true
      end
  
      it 'returns true if there are tasks due within 14 days' do
        # uh oh. This test would be exactly the same as above.
      end
    end
  end
  </code></pre>
  
  <p>This passes, but when I went to write the test for <code>it 'returns true if there are tasks due within 14 days</code>, I realized that my <code>double(:task, due_within: [])</code> doesn't interact with the variable provided to the method.</p>
  
  <h3>How can I write a stub that cares about the variable provided to the method?</h3>
  
  <p>Obviously this doesn't work:</p>
  
  <pre><code>tasks = double(:task, due_within(7): [1, 2], due_within(14): [1, 2, 3, 4])
  </code></pre>