rspec what I'm doing wrong?

In controller I have:

def search     unless params[:data_search].blank?       shop_data = params[:data_search]       @shops = Shop.data_search(shop_data).paginate(:per_page => Settings.shops_per_page, :page => params[:page])     else       @shops = Shop.all.paginate(:per_page => Settings.shops_per_page, :page => params[:page])     end     render :layout => false if request.xhr?   end

In controller.spec I have:

def mock_shop(stubs={})     @mock_shop ||= mock_model(Shop, stubs).as_null_object   end

describe "search" do     context "when name is 'Test'" do       it "should find shops" do         @name = "Test"         Shop.stub(:search).with(@name) { [mock_shop] }         get :search, :name => @name         assigns(:shops).should eq([mock_shop])       end     end   end

The failure is:

Failure/Error: assigns(:shops).should eq([mock_shop])

       expected [#<Shop:0x9f4 @name="Shop_1032">]             got

       (compared using ==)

       Diff:        @@ -1,2 +1,2 @@        -[#<Shop:0x9f4 @name="Shop_1032">]        +

What I am doing wrong?

get :search, :name => @name

and in controller data_search is expected to be present.

Yes, parameter is wrong but putting get :search, :data_search => @name I have the same failure.

describe "search" do    context "when name is 'Test'" do      it "should find shops" do        @name = "Test"        Shop.stub(:search).with(@name) { [mock_shop] }        get :search, :name => @name        assigns(:shops).should eq([mock_shop])      end    end end

The failure is:

Failure/Error: assigns(:shops).should eq([mock_shop])

      expected [#<Shop:0x9f4 @name="Shop_1032">]            got

      (compared using ==)

      Diff:       @@ -1,2 +1,2 @@       -[#<Shop:0x9f4 @name="Shop_1032">]       +

What I am doing wrong?

It doesn't look like you're calling the stubbed method

Fred

Can you suggest how can I solve?

Sorry I've solved the error was Shop.stub(:search), it must be Shop.stub(:data_search) sorry for the noise.