title: RSpec simulating calling the function argument
body: <p>How can I simulate calling the function argument that I'm testing with RSpec
  I'm doing it like this:</p>
  
  <pre><code>module Module1
    def find_item(str, item_class)
      arr = item_class.find_or_initialize_by(...)
    end
  end
  </code></pre>
  
  <p>Then in specs:</p>
  
  <pre><code>let!(:dummy_class) { Class.new { extend Module1 } }
  
  it 'calls find_or_initialize_by' do
    item_class = double("Item")
    allow(dummy_class).to receive(:item_class).and_return(item_class)
    expect(item_class).to receive(:find_or_initialize_by)
    dummy_class.find_item("item1", Item)
  end
  </code></pre>
  
  <p>And it raise an error "# does not implement: item_class"
  I was trying to use class_double and instance_double but it was unhelpful.</p>
  
  <blockquote>
    <p>Failures:</p>
    
    <p>1) Module1#find_items
       Failure/Error: allow(dummy_class).to receive(:item_class)
        # does not implement: item_class
     # ./spec/..._spec.rb:26:in `block (3 levels) in '</p>
  </blockquote>
  
  <p>26 line: allow(dummy_class).to receive(:item_class).and_return(item_class)</p>