From 1b0e427b36718177a537d23dd4e8a327a199598a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Sat, 19 Nov 2011 21:45:51 +0000 Subject: [PATCH] Added a spec related to #165 --- lib/cucumber/constantize.rb | 2 +- spec/cucumber/constantize_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 spec/cucumber/constantize_spec.rb diff --git a/lib/cucumber/constantize.rb b/lib/cucumber/constantize.rb index 7917390a77..9cbe102665 100644 --- a/lib/cucumber/constantize.rb +++ b/lib/cucumber/constantize.rb @@ -7,7 +7,7 @@ def constantize(camel_cased_word) names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? - constant = Object + constant = ::Object names.each do |name| constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) end diff --git a/spec/cucumber/constantize_spec.rb b/spec/cucumber/constantize_spec.rb new file mode 100644 index 0000000000..d04ff0a24e --- /dev/null +++ b/spec/cucumber/constantize_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +module Cucumber + describe Constantize do + include Constantize + + it "loads html formatter" do + clazz = constantize('Cucumber::Formatter::Html') + clazz.name.should == 'Cucumber::Formatter::Html' + end + end +end \ No newline at end of file