From: Arun Sharma Date: 2010-11-17T15:05:11+09:00 Subject: expected 1 times, but received it 0 times I am initial level of rspec.i am getting a problem as my action is as follow def get_roles_to_customer @user_role = RoleRelation.first(:conditions => ["user_id = ? AND customer_id = ?", current_user.id, params[:id]]) if current_user.is_superadmin @allow_roles = Role.all(:conditions => ["role_type = ? ",'user']) elsif !@user_role.nil? and (@user_role.role.name == 'admin' or @user_role.role.name == 'mgt-cust') @allow_roles = Role.all(:conditions => ["role_type = ?AND name != ?",'user','superadmin']) elsif !@user_role.nil? and @user_role.role.name == 'manager' @allow_roles = Role.all(:conditions => ["role_type = ? AND name NOT IN ('admin','mgt-cust')",'user']) end options ="" for role in @allow_roles options += "" end render :text => options end My spec file code is controller.should_receive(:get_roles_to_customer).with(:id=>1).and_return(true) this line of code is creating a error '# expected :get_roles_to_customer with ({:id=>1}) once, but received it 0 times' Please post the solution of this problem -- Posted via http://www.ruby-forum.com/.