Skip to content
Browse files

Instantiate shell classes by default, so behavior is unified (instanc…

…e is used in tests, while class was the default shell)
  • Loading branch information...
1 parent 53908d5 commit 0df8839781f49b145e4f9fe3792d0fa1ed46ec68 @drogus drogus committed with josevalim Oct 28, 2010
Showing with 5 additions and 4 deletions.
  1. +4 −3 lib/thor/shell.rb
  2. +1 −1 spec/shell_spec.rb
View
7 lib/thor/shell.rb
@@ -7,11 +7,12 @@ module Base
#
def self.shell
@shell ||= if ENV['THOR_SHELL'] && ENV['THOR_SHELL'].size > 0
- Thor::Shell.const_get(ENV['THOR_SHELL'])
+ shell = Thor::Shell.const_get(ENV['THOR_SHELL'])
+ shell.is_a?(Class) ? shell.new : shell
elsif RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
- Thor::Shell::Basic
+ Thor::Shell::Basic.new
else
- Thor::Shell::Color
+ Thor::Shell::Color.new
end
end
View
2 spec/shell_spec.rb
@@ -28,7 +28,7 @@ class Thor::Shell::TestShell < Thor::Shell::Basic; end
Thor::Base.shell.must == shell.class
ENV['THOR_SHELL'] = 'TestShell'
Thor::Base.shell = nil
- Thor::Base.shell.must == Thor::Shell::TestShell
+ Thor::Base.shell.class.must == Thor::Shell::TestShell
ENV['THOR_SHELL'] = ''
Thor::Base.shell = shell.class
Thor::Base.shell.must == shell.class

0 comments on commit 0df8839

Please sign in to comment.
Something went wrong with that request. Please try again.