In Rails, set `Hashie.logger` to `Rails.logger`
This commit is contained in:
parent
ac6193c9ea
commit
ca34d28a84
|
@ -4,6 +4,8 @@ coverage
|
|||
rdoc
|
||||
pkg
|
||||
*.gem
|
||||
*.log
|
||||
.bundle
|
||||
.rvmrc
|
||||
Gemfile.lock
|
||||
Gemfile.lock
|
||||
log/
|
||||
|
|
|
@ -5,7 +5,12 @@ module Hashie
|
|||
#
|
||||
# @return [Logger]
|
||||
def self.logger
|
||||
@logger ||= Logger.new(STDOUT)
|
||||
@logger ||=
|
||||
if defined?(::Rails)
|
||||
Rails.logger
|
||||
else
|
||||
Logger.new(STDOUT)
|
||||
end
|
||||
end
|
||||
|
||||
# Sets the logger that Hashie uses for reporting errors.
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
--colour
|
||||
--format=documentation
|
||||
--pattern=*_spec.rb
|
|
@ -0,0 +1,5 @@
|
|||
source 'http://rubygems.org'
|
||||
|
||||
gem 'hashie', path: '../../..'
|
||||
gem 'rails'
|
||||
gem 'rspec', '~> 3.5.0'
|
|
@ -0,0 +1,66 @@
|
|||
ENV['RACK_ENV'] = 'test'
|
||||
|
||||
require 'rspec/core'
|
||||
require 'rails'
|
||||
require 'rails/all'
|
||||
require 'action_view/testing/resolvers'
|
||||
|
||||
module RailsApp
|
||||
class Application < ::Rails::Application
|
||||
config.action_dispatch.show_exceptions = false
|
||||
config.active_support.deprecation = :stderr
|
||||
config.eager_load = false
|
||||
config.root = __dir__
|
||||
config.secret_key_base = 'hashieintegrationtest'
|
||||
|
||||
routes.append do
|
||||
get '/' => 'application#index'
|
||||
end
|
||||
|
||||
config.assets.paths << File.join(__dir__, 'assets/javascripts')
|
||||
config.assets.debug = true
|
||||
end
|
||||
end
|
||||
|
||||
LAYOUT = <<-HTML
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>TestApp</title>
|
||||
<%= stylesheet_link_tag "application", :media => "all" %>
|
||||
<%= javascript_include_tag "application" %>
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
INDEX = <<-HTML
|
||||
<h1>Hello, world!</h1>
|
||||
HTML
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
layout 'application'
|
||||
|
||||
self.view_paths = [ActionView::FixtureResolver.new(
|
||||
'layouts/application.html.erb' => LAYOUT,
|
||||
'application/index.html.erb' => INDEX
|
||||
)]
|
||||
|
||||
def index
|
||||
end
|
||||
end
|
||||
|
||||
RailsApp::Application.initialize!
|
||||
|
||||
require 'hashie'
|
||||
|
||||
RSpec.describe 'the Hashie logger' do
|
||||
it 'is set to the Rails logger' do
|
||||
expect(Hashie.logger).to eq(Rails.logger)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue