logger_for_test 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 66ef0664389695bb3ca766e3ac9a761ee22a1630
4
+ data.tar.gz: 1cb32e734e0aa62a3968a9e8fded106fbd9f1a49
5
+ SHA512:
6
+ metadata.gz: b1ab7b5f169b165095d38e758fe0ffc8d5b97e2bfbff216c4738ca02ce1c9d58353c27b9f344da954582882a5a63054494832d350ed294eae1394aa1a0966087
7
+ data.tar.gz: b1ecc137c9fd2aee3cbf91bb43bf13c9622abf7ed37a8c7143a2ba49273e7ef814fbcea868a3a06557e8ec9cf52696f12cb05b1b8bf6029c484a80854f95c28f
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.1
5
+ - jruby-head
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in logger_for_test.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Sean Sorrell
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ [![Build Status](https://travis-ci.org/rudle/LoggerForTest.svg?branch=master)](https://travis-ci.org/rudle/LoggerForTest)
2
+ # LoggerForTest
3
+
4
+ LoggerForTest is a [Logger](http://www.ruby-doc.org/stdlib-2.1.2/libdoc/logger/rdoc/Logger.html) API compatible logger that lets you inspect the contents of a log
5
+ without hitting the disk. You probably want to replace the `Logger` constant in your app with this in your `spec_helper.rb`.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'logger_for_test'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install logger_for_test
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/rudle/logger_for_test/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rubocop/rake_task'
5
+ require 'rake/testtask'
6
+
7
+ RuboCop::RakeTask.new
8
+
9
+ Rake::TestTask.new do |t|
10
+ t.test_files = FileList['test/**/*_test.rb']
11
+ end
12
+
13
+ task testtask: 'rubocop'
14
+
15
+ task default: 'testtask'
@@ -0,0 +1,28 @@
1
+ # encoding: UTF-8
2
+ require 'delegate'
3
+
4
+ # This is the implementation of Logger that stores an in memory representation
5
+ # of your log lines. It uses the delegator pattern to ensure that things
6
+ # continue to work
7
+ # suggested usages:
8
+ # LoggerForTest.new(Logger.new(STDOUT))
9
+ # LoggerForTest.new(Rails.logger))
10
+ class LoggerForTest < SimpleDelegator
11
+ VERSION = '0.0.1'
12
+ def initialize(*args)
13
+ super
14
+ @log_lines = []
15
+ end
16
+ attr_accessor :log_lines
17
+
18
+ def add(sev, message = nil, progname = nil)
19
+ log_lines << format(sev, message, progname)
20
+ super(sev, message, progname)
21
+ end
22
+
23
+ def format(sev, message, progname)
24
+ { sev: sev,
25
+ message: message,
26
+ progname: progname }
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'logger_for_test'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'logger_for_test'
8
+ spec.version = LoggerForTest::VERSION
9
+ spec.authors = ['Square']
10
+ spec.email = ['git@squareup.com']
11
+ spec.summary = ['A Ruby Logger that stores your log lines in memory.',
12
+ 'Use it in your tests to avoid awkward mocking!'].join
13
+ spec.homepage = 'https://github.com/rudle/LoggerForTest'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'minitest', '~> 5.3'
23
+ spec.add_development_dependency 'rake', '~> 10.3'
24
+ spec.add_development_dependency 'rubocop', '= 0.24'
25
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../test_helper'
4
+ require_relative '../../lib/logger_for_test'
5
+
6
+ describe LoggerForTest do
7
+ before do
8
+ @logger_double = MiniTest::Mock.new
9
+ @logger = LoggerForTest.new(@logger_double)
10
+ end
11
+
12
+ describe '#add' do
13
+ it 'shall call the implementation of Logger' do
14
+ @logger_double.expect(:add, nil,
15
+ ['error', 'something went wrong', 'progname'])
16
+
17
+ @logger.add('error', 'something went wrong', 'progname')
18
+ end
19
+
20
+ it 'shall log the input in memory' do
21
+ @logger_double.expect(:add, nil,
22
+ ['error', 'something went wrong', 'progname'])
23
+
24
+ @logger.add('error', 'something went wrong', 'progname')
25
+
26
+ @logger.log_lines.must_equal [{ sev: 'error',
27
+ message: 'something went wrong',
28
+ progname: 'progname' }]
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ # encoding: UTF-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ gem 'minitest' # silence a warning
6
+ require 'minitest/autorun'
7
+ require 'minitest/pride'
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logger_for_test
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Square
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: '0.24'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: '0.24'
69
+ description:
70
+ email:
71
+ - git@squareup.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/logger_for_test.rb
83
+ - logger_for_test.gemspec
84
+ - test/logger_for_test/logger_for_test_test.rb
85
+ - test/test_helper.rb
86
+ homepage: https://github.com/rudle/LoggerForTest
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.2.2
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: A Ruby Logger that stores your log lines in memory.Use it in your tests to
110
+ avoid awkward mocking!
111
+ test_files:
112
+ - test/logger_for_test/logger_for_test_test.rb
113
+ - test/test_helper.rb