Rspec 2 controller testing with method_missing expectation
I have an application that does a lot of logging for different situations like simple page views likes this:

      def index
        @network_data = current_user.network.data.present? ? JSON.parse(current_user.network.data) : nil
        AnalyticLog.viewed_my_network(user: current_user, session: session)
      end

The call to AnalyticLog.viewed_my_network is important to know that it's running, however, if I write some type of expectation, it never seems to get called. Any idea what I'm doing wrong?

    describe "GET #index" do
      it "assigns @network_data" do
        get :index
        assigns(:network_data).should be_nil  
      end
    
      it "logs view" do
        AnalyticLog.should_receive(:viewed_my_network)
        get :index
      end
    end

Results in:

    1) NetworkController GET #index logs view
     Failure/Error: AnalyticLog.should_receive(:viewed_my_network)
       (<AnalyticLog (class)>).viewed_my_network(any args)
           expected: 1 time
           received: 0 times
Rspec 2 controller testing with method_missing expectation
===

I have an application that does a lot of logging for different situations like simple page views likes this:

      def index
        @network_data = current_user.network.data.present? ? JSON.parse(current_user.network.data) : nil
        AnalyticLog.viewed_my_network(user: current_user, session: session)
      end

The call to AnalyticLog.viewed_my_network is important to know that it's running, however, if I write some type of expectation, it never seems to get called. Any idea what I'm doing wrong?

    describe "GET #index" do
      it "assigns @network_data" do
        get :index
        assigns(:network_data).should be_nil  
      end
    
      it "logs view" do
        AnalyticLog.should_receive(:viewed_my_network)
        get :index
      end
    end

Results in:

    1) NetworkController GET #index logs view
     Failure/Error: AnalyticLog.should_receive(:viewed_my_network)
       (<AnalyticLog (class)>).viewed_my_network(any args)
           expected: 1 time
           received: 0 times