title: Mocha expects method
body: <p>So my situation is: 
  I have a 2 modules that have the same structure like that:</p>
  
  <pre><code>module Module1
    class Config
  
      def fee_rate
        2
      end
    end
  end
  </code></pre>
  
  <p>So, say, Module2 would have class Config with the method fee_rate, just with a different value (those are actually implemented in a rails engine, but it shouldn't matter)</p>
  
  <p>and then my model can use either Module1 or Module2 to get the fee rate value like that:</p>
  
  <pre><code>def config
    @config ||= "#{module_name.titleize}::Config".constantize.new
    @config
  end
  
  def get_value
    config.get_fee * some_other_value
  end
  </code></pre>
  
  <p>What I'm trying to test is if get_fee function was called on the correct class:</p>
  
  <pre><code>"#{model.module_name.titleize}::Config".constantize.any_instance.expects(:get_fee).at_least_once
  model.get_value
  </code></pre>
  
  <p>and on the line when I call get_value I get the following error -  undefined method `*' for nil:NilClass. I'm completely lost now, so I'd appreciate any help and ideas.</p>