Skip to content
Browse files

Triaging for Ruby 1.9 (Closes #1)

  • Loading branch information...
1 parent f6f320f commit 31089d9e59baf19b306725209ee1bef80762a9c5 @spicycode spicycode committed May 22, 2009
Showing with 32 additions and 28 deletions.
  1. +30 −26 examples/log_buddy/gem_logger_example.rb
  2. +2 −2 lib/log_buddy/gem_logger.rb
View
56 examples/log_buddy/gem_logger_example.rb
@@ -10,36 +10,40 @@
end
end
-
- describe "Gem#activation monkey patching for logging" do
+
+ if RUBY_VERSION =! '1.9.1'
- before do
- LogBuddy.init
- LogBuddy::GemLogger.log_gems!
- end
+ describe "Gem#activation monkey patching for logging" do
+
+ before do
+ LogBuddy.init
+ LogBuddy::GemLogger.log_gems!
+ end
- it "should log the gem name and version and where it was called from" do
- Gem.stubs(:activate_without_logging)
+ it "should log the gem name and version and where it was called from" do
+ Gem.stubs(:activate_without_logging)
+
+ LogBuddy.expects(:debug).with do |msg|
+ msg.should include(%[Gem activation for gem: 'gem-name' version: '0.5' called from:\n])
+ gem_calling_line = __LINE__ + 3
+ msg.should include(%[examples/log_buddy/gem_logger_example.rb:#{gem_calling_line}])
+ end
+ gem "gem-name", "0.5"
+ end
- LogBuddy.expects(:debug).with do |msg|
- msg.should include(%[Gem activation for gem: 'gem-name' version: '0.5' called from:\n])
- gem_calling_line = __LINE__ + 3
- msg.should include(%[examples/log_buddy/gem_logger_example.rb:#{gem_calling_line}])
+ it "should do the original gem activation call" do
+ LogBuddy.stubs(:debug)
+ Gem.expects(:activate_without_logging).with('gem-name', ">= 1.0.0")
+ gem "gem-name", ">= 1.0.0"
end
- gem "gem-name", "0.5"
- end
-
- it "should do the original gem activation call" do
- LogBuddy.stubs(:debug)
- Gem.expects(:activate_without_logging).with('gem-name', ">= 1.0.0")
- gem "gem-name", ">= 1.0.0"
- end
-
- it "should add alias gem_without_logging" do
- Gem.should respond_to(:activate)
- Gem.should respond_to(:activate_without_logging)
- end
+ it "should add alias gem_without_logging" do
+ Gem.should respond_to(:activate)
+ Gem.should respond_to(:activate_without_logging)
+ end
+
+ end
+
end
-end
+end
View
4 lib/log_buddy/gem_logger.rb
@@ -4,7 +4,7 @@ module GemLogger
BACKTRACE_SIZE = 0..5
def self.log_gems!
- Gem.send :include, LogBuddy::GemLogger
+ ::Gem.send :include, LogBuddy::GemLogger
end
def self.included(mod)
@@ -21,4 +21,4 @@ def activate_with_logging(gem, *version_requirements)
end
end
-end
+end

0 comments on commit 31089d9

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