I am having trouble understanding what to test in the case below and how to do it.
I have the following instance method on Address model
validate :address, on: [:create, :update]
def address
check = CalendarEventLocationParsingWorker.new.perform("", self.structured, true )
if check[:code] != 0
errors.add(:base,"#{self.kind.capitalize} Address couldn't be analysed, please fill up as much fields as possible.")
else
self.lat = check[:coords]["lat"]
self.lon = check[:coords]["lng"]
end
end
Basically its a method called on create and update hooks and checks with a third party API if the address is valid. How can i test this in isolation without making an actual call to the 3rd party api but rather simulate the response?
I read about mocks and stubs but i do not quite get them yet. Any insight is welcome. Using Rspec, shoulda matchers and factory girl.