Permalink
Browse files

Cleanup and moving to Rspec2

  • Loading branch information...
rsanheim committed May 17, 2010
1 parent 67dd2f5 commit 638d74d06f6076183216283b87c4c7e1b9e6a22f
View
@@ -1,3 +1,5 @@
+v0.x.x. Cleanup: move to Rspec; remove GemLoger
+
v0.4.10 Switch to jeweler; remove dependencies that were superfluous
v0.4.9 Added gem logging for debugging help when tracking down Gem activation errors
View
@@ -7,7 +7,7 @@ begin
gem.email = "rsanheim@gmail.com"
gem.homepage = "http://github.com/relevance/log_buddy"
gem.authors = ["Rob Sanheim"]
- gem.add_development_dependency "micronaut", ">= 0.3.0"
+ gem.add_development_dependency "rspec", ">= 0.3.0"
gem.add_development_dependency "mocha", ">= 0.3.0"
end
Jeweler::GemcutterTasks.new
@@ -16,22 +16,19 @@ rescue LoadError
end
begin
- require 'micronaut/rake_task'
+ require 'rspec/core/rake_task'
- Micronaut::RakeTask.new(:examples) do |examples|
- examples.pattern = 'examples/**/*_example.rb'
- examples.ruby_opts << '-Ilib -Iexamples'
- end
+ Rspec::Core::RakeTask.new(:spec)
- Micronaut::RakeTask.new(:rcov) do |examples|
- examples.pattern = 'examples/**/*_example.rb'
- examples.rcov_opts = %[-Ilib -Iexamples --exclude "gems/*,/Library/Ruby/*,config/*" --text-summary --sort coverage]
- examples.rcov = true
+ Rspec::Core::RakeTask.new(:coverage) do |spec|
+ spec.pattern = 'spec/**/*_spec.rb'
+ spec.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,/Library/Ruby/*,config/*" --text-summary --sort coverage]
+ spec.rcov = true
end
- task :default => [:check_dependencies, :rcov]
+ task :default => [:check_dependencies, :coverage]
rescue LoadError => e
- puts "Micronaut not available to run tests. Install it with: gem install micronaut"
+ puts "Rspec not available to run tests. Install it with: gem install rspec --pre"
puts e
puts e.backtrace
end
@@ -1,49 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), *%w[example_helper]))
-
-describe LogBuddy::GemLogger do
-
- describe "starting Gem logging" do
-
- it "includes GemLogger into Gem when #log_gems! is called" do
- Gem.expects(:include).with(LogBuddy::GemLogger)
- LogBuddy::GemLogger.log_gems!
- end
-
- end
-
- if RUBY_VERSION != '1.9.1'
-
- 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)
-
- 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
-
- 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
-
- end
-
- end
-
-end
View
@@ -1,6 +1,5 @@
require File.join(File.dirname(__FILE__), *%w[log_buddy utils])
require File.join(File.dirname(__FILE__), *%w[log_buddy mixin])
-require File.join(File.dirname(__FILE__), *%w[log_buddy gem_logger])
require File.join(File.dirname(__FILE__), *%w[log_buddy version])
=begin rdoc
@@ -28,14 +27,11 @@ module LogBuddy
# tries to default to RAILS_DEFAULT_LOGGER, and then to a STDOUT logger).
# * <tt):log_to_stdout</tt> - whether LogBuddy should _also_ log to STDOUT, very helpful for Autotest (default is +true+).
# * <tt>:disabled</tt> - when true, LogBuddy will not produce any output
- # * <tt>:log_gems</tt> - log Gem activation process - useful for tracking down Gem activation errors (default is +false+)
def self.init(options = {})
@logger = options[:logger]
@log_to_stdout = options.has_key?(:log_to_stdout) ? options[:log_to_stdout] : true
- @log_gems = options[:log_gems]
@disabled = (options[:disabled] == true)
mixin_to_object
- GemLogger.log_gems! if @log_gems
end
# Add the LogBuddy::Mixin to Object instance and class level.
@@ -1,24 +0,0 @@
-module LogBuddy
- module GemLogger
-
- BACKTRACE_SIZE = 0..5
-
- def self.log_gems!
- ::Gem.send :include, LogBuddy::GemLogger
- end
-
- def self.included(mod)
-
- class << mod
- def activate_with_logging(gem, *version_requirements)
- d %[Gem activation for gem: '#{gem}' version: '#{version_requirements}' called from:\n#{caller[BACKTRACE_SIZE].join("\n")}]
- activate_without_logging(gem, *version_requirements)
- end
-
- alias_method :activate_without_logging, :activate
- alias_method :activate, :activate_with_logging
- end
-
- end
- end
-end
@@ -1,14 +1,9 @@
-require File.expand_path(File.join(File.dirname(__FILE__), *%w[example_helper]))
+require File.expand_path(File.join(File.dirname(__FILE__), *%w[spec_helper]))
describe LogBuddy do
describe "init" do
after { reset_safe_log_buddy_mode }
- it "should call log_gems! if log_gems is true" do
- LogBuddy::GemLogger.expects(:log_gems!)
- LogBuddy.init :log_gems => true
- end
-
it "doesnt mixin to object if SAFE_LOG_BUDDY is true" do
LogBuddy.expects(:init).never
ENV["SAFE_LOG_BUDDY"] = "true"
@@ -1,4 +1,4 @@
-require File.expand_path(File.join(File.dirname(__FILE__), *%w[example_helper]))
+require File.expand_path(File.join(File.dirname(__FILE__), *%w[spec_helper]))
describe LogBuddy do
@@ -1,4 +1,4 @@
-require File.expand_path(File.join(File.dirname(__FILE__), *%w[example_helper]))
+require File.expand_path(File.join(File.dirname(__FILE__), *%w[spec_helper]))
module SomeModule
def self.say_something(name)
@@ -1,6 +1,6 @@
-require 'logger'
+require "logger"
require "mocha"
-require 'micronaut'
+require "rspec"
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "log_buddy"))
def silence_warnings
@@ -10,10 +10,11 @@ def silence_warnings
$VERBOSE = old_verbose
end
-Micronaut.configure do |config|
+Rspec.configure do |config|
config.mock_with :mocha
config.formatter = :documentation
config.color_enabled = true
config.alias_example_to :fit, :focused => true
config.filter_run :options => { :focused => true }
+ config.run_all_when_everything_filtered = true
end

0 comments on commit 638d74d

Please sign in to comment.