lib/cucumber/constantize.rb in aslakhellesoy-cucumber-0.3.101.2 vs lib/cucumber/constantize.rb in aslakhellesoy-cucumber-0.3.102

- old
+ new

@@ -1,19 +1,25 @@ module Cucumber module Constantize #:nodoc: def constantize(camel_cased_word) + try = 0 begin + try += 1 names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) end constant - rescue NameError + rescue NameError => e require underscore(camel_cased_word) - retry + if try < 2 + retry + else + raise e + end end end # Snagged from active_support def underscore(camel_cased_word) \ No newline at end of file