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

Will it rain, or not? How to stub a method in Spec tests.

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… RSpec: How to stub a random variable (make the weather as you need it to be) weiterlesen

Veröffentlicht am
Kategorisiert in Code Verschlagwortet mit , ,