Geek Culture
Published in

Geek Culture

Hermetic Unit Testing

Photo by CDC on Unsplash
def to_fahrenheit(api_return)
(api_return[:temperature] * 9/5) +32
end
Figure 1: Arbitrary Ruby method to coverting Celsius to Fahrenheit
class TestMeme < Minitest::Test
def setup
@fake_api_return = {temperature: 100}
end

def test_to_fahrenheit
assert_equal 212, to_fahrenheit(@fake_api_return)
end
end
Figure 2: Hermetic Unit Test of to_fahrenheit using Ruby minitest

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mathew Phillip Wheatley

I am a software engineer with a mechanical background. Interests swing from aerospace, to woodworking, travel, skiing, hiking, running, climbing, and lasers.