The method I am trying to test is:
def self.load_file(file)
lookup = ''
if file.extension.include? "abc"
lookup = file.extension
else
lookup = file.last_updated
end
@location = Location.find_by_lookup(lookup)
@location
end
So I need to stub the file so it responds to extension and last_updated calls.
I also need to mock the call to file.last_updated because I want to make sure that if the file extension has ‘abc’, it doesn’t lookup by extension but by ‘last_updated’.
How can I test this?
Your flow would look something like this (substitute “MyClass” with the actual name of your class):