From e39d621fb414cf9ee95dabbe7c837e96cee65ea5 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Thu, 16 Apr 2015 16:36:44 +0100 Subject: Test our enum-like type works as expected. Specifically that we can get the value back as a string, and work with the ordinal too. --- lib/custodian/testfactory.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/custodian') diff --git a/lib/custodian/testfactory.rb b/lib/custodian/testfactory.rb index 29d1f99..0f5a30d 100644 --- a/lib/custodian/testfactory.rb +++ b/lib/custodian/testfactory.rb @@ -15,6 +15,18 @@ module Custodian TEST_PASSED = 2 TEST_FAILED = 4 TEST_SKIPPED = 8 + + + # + # Allow one of our symbols to be converted back + # + def self.to_str(status) + for sym in self.constants + if self.const_get(sym) == status + return sym.to_s + end + end + end end -- cgit v1.2.1