How to test Ruby methods that involve puts or gets
11-Jul-2019 1714
What makes the ask_for_number method challenging to test is a dependency. Most methods can be tested by saying, “When I pass in argument X, I expect return value Y.” This one isn’t so straightforward though. This is more like “When the user sees output X and then enters value V, expect subsequent output O.”Instead of accepting arguments, this method gets its value from user input. And instead of necessarily returning a value, this method sometimes simply outputs more text.How can we give this method the values it needs, and how can we observe the way the method behaves when we give it these values?.
How to test Ruby methods that involve puts or gets #ruby #rubydeveloper #rubyonrails #methods #involve #test https://rubyonrails.ba/link/how-to-test-ruby-methods-that-involve-puts-or-gets