nskins / goby

Command-line role-playing game framework
MIT License
122 stars 56 forks source link

Determine environment in type() function #60

Closed nskins closed 7 years ago

nskins commented 7 years ago

In util.rb, we have a function called type() that sleeps between the output of each character. Unfortunately, it's not very good for testing since it slows down the test suite. Is there some way to determine the environment (possibly whether the code is running via ruby vs. rspec) in Ruby? I think in Rails there is an equivalent method called rails.env but clearly it can't work here.

If so, then we can sleep only when the environment is ruby and not rspec. Then type() (and certain other methods) would be testable, which would be quite nice.

EDIT: http://stackoverflow.com/questions/24932504/detect-that-code-run-by-rspec-ruby