Stub/mock normal methods

Hi friends

I want to stub or/mock the normal mt=ethod in controller

Can u give any idea?

Example

When i was testing the below code using mocks and stubs
i m getting error is “Mock ‘errors’ received unexpected message :each
with (no args)”

Could u give any idea on how to stub/mock normal methods n like
chart_files_errors in below code

Please give me ideas

In my controller method

def create

@employee = Employee.new
if (Employee.update_attributes(params[:emp]))
xxxxxx
else
#XXX_method in the controoler
flash[:error] = chart_files_errors(@exployee.errors)
end

end

def chart_files_errors(@errors)
errors.each do |key, error|
count = count + 1
key = property_name_convert(key)
if previous_error == “”
previous_error = error[0]
end
if (previous_error == error[0]) # checking the previous error and
current error
if (count == errors.size)
#Adding the previous error message and current error message (
Key and Error)
error_message = (error_message + " #{key.capitalize}
#{error[0]}")
else
#Adding the previous error message and current error message (
Key only)
error_message = (error_message + " #{key.capitalize}" + “,”)
end # end of ((count == errors.size)
else
error_message = error_message + " #{previous_error} ,
#{key.capitalize} #{error[0]}"
end # end of (pre_value == error[0])
end # errors loop
error_message

end