Your weather_randomiser
does too many things:
- It generates a random number
- It maps a random number to a string value
- It updates an instance variable
To make things more testable, you could split those out, e.g.:
def weather_randomiser rand(1..10)enddef set_weather(value) @weather = case value when 1..8 then 'sunny' when 9..10 then 'stormy' endenddef stormy? set_weather weather_randomiser @weather == 'stormy'end
It does introduce an awkward coupling between the randomiser and setter; changing the former requires looking at the latter ... ymmv