Permalink
Browse files

ST: Refactoring and added specs

  • Loading branch information...
1 parent 31b7001 commit 5d4041e51ffa766f06398400b1dfd0609a40227d @rudionrails committed Sep 13, 2012
@@ -22,7 +22,7 @@ production:
# :level: 'gte.info lte.fatal'
:level: 'gte.info'
- # Keep a max of 7 files for every adapter per default. You can leave this option
+ # Keep a max of 7 files for every adapter per default. You can remove this option
# if you wish to keep all files, otherwise, Yell will cleanup any :datefile
# after a rollover of 7 times.
:keep: 7
View
@@ -0,0 +1,5 @@
+# encoding: utf-8
+
+require 'yell'
+
+require File.dirname(__FILE__) + '/yell/railtie' if defined?(Rails)
@@ -1,8 +1,5 @@
# encoding: utf-8
-require 'rails'
-require 'yell'
-
module Yell #:nodoc:
class Railtie < ::Rails::Railtie
railtie_name 'yell-rails'
View
@@ -1,42 +1,4 @@
-# The following is an example config file for yell with all possible options available.
-#
-# To learn about the possible configuration options via a YAML file, read the wiki
-# on github: https://github.com/rudionrails/yell/wiki/101-configuration-with-yaml
-
-development: &development
- # Enable colorized log output with the following. It is handy for development
- # or testing, but should not be turned on for staging or production. Otherwise
- # you will see those annoying ANSI color codes when on the remote production
- # machine.
- :colors: true
-
-# we use the same settings for test that we defined for development
-test: *development
-
-# In production, you should configure yell somewhat more specific. The following
-# is an example config - change it at your own will.
-production:
- # Set the minimum (global) log level for Yell. If you prefer a different setup
- # you may comine various log levels, like:
- # # this will only log between :info and :fatal level
- # :level: 'gte.info lte.fatal'
- :level: 'gte.info'
-
- # Keep a max of 7 files for every adapter per default. You can leave this option
- # if you wish to keep all files, otherwise, Yell will cleanup any :datefile
- # after a rollover of 7 times.
- :keep: 7
-
- # define multiple adapters: one for notice and one for error messages
+test:
:adapters:
- # this adapter writes all messages with a log level of warn or lower
- # and writes to production.log (because this is your Rails.env)
- - :datefile:
- :level: 'lte.warn'
-
- # this adapter writes all messages with a log level of error or higher
- # and writes to error.log
- - :datefile:
- :level: 'gte.error'
- :filename: 'log/error.log'
+ - :stdout:
View
@@ -1,19 +1,25 @@
$:.unshift File.expand_path('..', __FILE__)
$:.unshift File.expand_path('../../lib', __FILE__)
-require 'yell/rails'
-require 'rails/all'
+require 'rails'
+require 'yell-rails'
require 'rspec'
require 'rr'
+require 'ostruct'
+
RSpec.configure do |config|
config.mock_framework = :rr
+ config.after do
+ Dir[ fixture_path + "/*.log" ].each { |f| File.delete f }
+ end
+
private
def fixture_path
- File.dirname(__FILE__) + '/fixtures'
+ File.expand_path( "fixtures", File.dirname(__FILE__) )
end
end
View
@@ -1,27 +1,36 @@
require 'spec_helper'
-# Yell Rails applicatio class
-module Yell
- class Application < Rails::Application
- end
-end
-
describe Yell::Railtie do
- let( :file ) { File.join(fixture_path, 'yell.yml') }
-
- before do
- mock( Rails.root ).join('config', 'yell.yml') { config_file }
-
- Yell::Application.initialize!
- end
+ let( :app ) { FakeApp.new }
+ let( :railtie ) { Yell::Railtie.send :new }
it "should have the right railtie name" do
Yell::Railtie.railtie_name.should == 'yell-rails'
end
- # it "should set the rails logger for the Yell::Repository" do
- # Rails.logger.should == Yell['rails']
- # end
+ context :initialized do
+ let( :app ) do
+ OpenStruct.new(
+ :config => OpenStruct.new( :paths => {'log' => [path]} )
+ )
+ end
+
+ let( :path ) { 'path/to/config' }
+ let( :file ) { mock }
+
+ before do
+ mock( ::File ).exist?( File.dirname(path) ) { true } # do not create log directory
+
+ mock( Rails.root ).join('config', 'yell.yml') { file } # mock config file
+ mock( file ).file? { false } # do not load the config file
+
+ railtie.run_initializers(:all, app )
+ end
+
+ it "should add :rails to the Yell::Repository" do
+ Yell['rails'].should be_kind_of Yell::Logger
+ end
+ end
end
View
@@ -7,18 +7,18 @@ Gem::Specification.new do |s|
s.authors = ["Rudolf Schmidt"]
s.homepage = "http://rudionrails.github.com/yell"
- s.summary = %q{yell-rails}
- s.description = %q{Yell for Rails}
+ s.summary = %q{Yell - Your Extensible Logging Library for Rails}
+ s.description = %q{Yell - Your Extensible Logging Library. Define multiple adapters, various log level combinations or message formatting options like you've never done before}
s.rubyforge_project = "yell"
- s.files = `git ls-files`.split("\n")
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.files = `git ls-files`.split($\)
+ s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
+
s.require_paths = ["lib"]
s.add_runtime_dependency "yell", ">= 0.13.2"
-
- s.add_development_dependency "rails", ">= 3.0.0"
+ s.add_runtime_dependency "rails", ">= 3.0.0"
end

0 comments on commit 5d4041e

Please sign in to comment.