title: How to stub a class method using rspec/rspec-mocks
body: <p>I am using rspec-mock for test-driven-development.
  I am starting implementing a single class and mocking/stubbing the other classes using rspec-mock. 
  Mocking objects of classes yet to be implemented works well.
  However when I try to mock a class method of a class that does not exist yet, I haven't been successful.
  My class "Hashes" should have a class method "calculate_hashes" receiving a filename and returning a hash.</p>
  
  <p>I tried</p>
  
  <pre><code> allow(Hashes).to receive(:calculate_hash) do |file| 
        # looks up what to return
   end
  </code></pre>
  
  <p>which give the error "Hashes is not a class".
  I then implemented a class "Hashes" </p>
  
  <pre><code>class Hashes
  end
  </code></pre>
  
  <p>and then only tried to stub the class method in the same way.
  This gives the error "Hashes does not implement: calculate_hash"
  When I then add the method to my class definition:</p>
  
  <pre><code>class Hashes
      def self.calculate_hash(filename)
      end
  end
  </code></pre>
  
  <p>it finally works and my stubbing of this class method works using "allow(Hashes)" as seen in the example above.
  I just wonder if there is a way of accomplishing this without writing this class skeleton.</p>
  
  <p>Or am I maybe trying to accomplish something in an inappropriate way?
  Or is rspec-mock maybe not the right tool to do this?</p>
  
  <p>Any help is greatly appreciated.</p>