Alle Artikel mit dem Schlagwort: stub

RSpec: How to stub a random variable (make the weather as you need it to be)


In our last challenge there was an airport that gave or declined landing permission for planes based on the weather. There was no real weather forecast, I just generated a random weather: def generate_weather [:sunny, :sunny,¬†:sunny, :stormy].shuffle.first end The Ruby-method .shuffle randomly mixes the values within the array and .first than takes the first value out. RSpec test: force the function return a specific value I implemented an if-statement in my landing- and take-off-procedures. So […]