My controller accesses the tempfile
attribute of an uploaded file and passes it to another mocked component. My test code has
@file = mock(Object)
Finally found this, which tells that although the thing returned by fixture_file_upload
has a @tempfile
member, it lacks the reader method. Solved as follows
FileUtils.touch('file.zip') # fixture_file_upload needs the file to exist
@file = fixture_file_upload('file.zip')
class << @file
# The reader method is present in a real invocation,
# but missing from the fixture object for some reason (Rails 3.1.1)
attr_reader :tempfile
end