title: Rspec: Expecting a module to receive a method
body: <p>I've got a really simple module:</p>
  
  <pre><code>module Foo
    def self.quux
      begin
        # stuff here
      ensure
        Baz.print_stuff
      end
    end
  end
  </code></pre>
  
  <p>And then I have a simple test that fails:</p>
  
  <pre><code>describe Foo
    describe '.quux' do
      it "should print stuff" do
        Foo.quux
        expect(Baz).to receive(:print_stuff)
      end
    end
  end
  </code></pre>
  
  <p>I get the following error message when I run this:</p>
  
  <pre><code>Failures:
  
  1) Foo.quux should should print stuff
     Failure/Error: expect(Baz).to receive(:print_stuff)
       (Baz).print_stuff(any args)
           expected: 1 time with any arguments
           received: 0 times with any arguments
  </code></pre>
  
  <p>What am I doing wrong? I know for a fact that the <code>print_stuff</code> method is being called.</p>