Is there a way to change the RUBY_PLATFORM constant so that I can test the following method?
def determine_os
case RUBY_PLATFORM
when /darwin/ then :mac
when /linux/ then :linux
else raise InvalidOSError
end
end
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
RUBY_PLATFORMshouldn’t be used to determine operating system. Use the appropriate item within the hashRbConfiginstead.Also, if you want to make it more easily tested, you could do
and you could do
determine_os("darwin")for your test.