Displaying 1 result from an estimated 1 matches for "req_url".
2013 Jun 09
2
Minitest mock or stub methods
...fetches all available tracks at the 3rd
party and returns them as an array.
In my artist class I have a separate method that makes the actual API calls
and parses the XML response with Nokogiri
def self.find(name: nil)
# Stuff...
doc = get_data(some_url)
# More stuff...
end
def get_data(req_url)
Nokogiri::XML(open(req_url))
end
When writing my tests I don''t want to hit the actual URL but instead load
an XML file from disk.
I''m using Minitest which has a mocking library, but how do I actually mock
(or is it more appropriate to stub?) the method?
--
You received th...