[rspec-users] Stubbing return arguments

rhydiant
Sat, 15 May 2010 07:56:31 -0000

I''m writting a code example for the following method:

    def upload(email_address, product_data)
      errors = []
      user = resolve_user_from(email_address)
      product_file_name = ProductFileHandler.persist(user,
product_data, errors)
      if errors.blank?
        # ... do some stuff
      else
        # ... do some other stuff
      end
    end

ProductFileHandler.persist will add any errors it encounters to the
errors array I pass in. In my test of upload, I want to stub that
error array with different values. After much googling and RSpec doc
searching I can''t find a way to stub arguments like that? Is this
possible with RSpec?