pax_global_header00006660000000000000000000000064125215724310014514gustar00rootroot0000000000000052 comment=8498ee5ec78d161f19c8f69e7ab8b92c2676dc9a rspec-logsplit-0.1.3/000077500000000000000000000000001252157243100144645ustar00rootroot00000000000000rspec-logsplit-0.1.3/.gitignore000066400000000000000000000000271252157243100164530ustar00rootroot00000000000000Gemfile.lock log *.gem rspec-logsplit-0.1.3/.rspec000066400000000000000000000001171252157243100156000ustar00rootroot00000000000000--color --format documentation --order random --warnings --require spec_helper rspec-logsplit-0.1.3/.travis.yml000066400000000000000000000003711252157243100165760ustar00rootroot00000000000000script: rake ci language: ruby rvm: - 2.2.0 - jruby - ruby-head - jruby-head - rbx-2 matrix: allow_failures: - rvm: rbx-2 - rvm: ruby-head - rvm: jruby-head notifications: irc: "irc.freenode.org#abstractive" sudo: false rspec-logsplit-0.1.3/CHANGES.md000066400000000000000000000002521252157243100160550ustar00rootroot000000000000000.1.1 (2015-04-04) ----- * Updated to new RSpec syntax. * Separated classes out into own files. * Added timestamp to default logging path. 0.0.3 ----- * Initial Releaserspec-logsplit-0.1.3/Gemfile000066400000000000000000000001761252157243100157630ustar00rootroot00000000000000source "https://rubygems.org" gem 'bundler' gem 'rake' gem 'rspec', '~> 3.2' gemspec group :development do gem 'pry' endrspec-logsplit-0.1.3/LICENSE.txt000066400000000000000000000021041252157243100163040ustar00rootroot00000000000000Copyright (c) 2012 Tim Carey-Smith, digitalextremist // MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.rspec-logsplit-0.1.3/README.md000066400000000000000000000017131252157243100157450ustar00rootroot00000000000000# Log Splitter for RSpec This `RSpec` plugin allows you to change the logger for your library for each separate example. This gives the ability to see the log output for each specific test. ## Usage Currently you must have a `class` or `module` which responds to two methods. For example, `Rails` responds correctly: * `Rails.logger` * `Rails.logger=` In your `Gemfile`: ``` ruby gem "rspec-log_split" ``` In your `spec/spec_helper.rb`: ``` ruby require "rspec/log_split" RSpec.configure do |config| config.log_split_dir = File.expand_path("../../log/#{Time.now.iso8601}", __FILE__) config.log_split_module = Rails end ``` You will get a log file for each example as follows: ``` log/2013-10-05T00:47:14+13:00/main log/2013-10-05T00:47:14+13:00/spec/demo_spec.rb:5 log/2013-10-05T00:47:14+13:00/spec/demo_spec.rb:9 log/2013-10-05T00:47:14+13:00/spec/support/shared_examples/win.rb:2 log/2013-10-05T00:47:14+13:00/spec/support/shared_examples/win.rb:7 ``` rspec-logsplit-0.1.3/Rakefile000066400000000000000000000003051252157243100161270ustar00rootroot00000000000000require 'bundler/gem_tasks' Dir['tasks/**/*.rake'].each { |task| load task } default_tasks = ['spec'] # default_tasks << 'rubocop' unless ENV['CI'] task default: default_tasks task ci: %w(spec) rspec-logsplit-0.1.3/lib/000077500000000000000000000000001252157243100152325ustar00rootroot00000000000000rspec-logsplit-0.1.3/lib/rspec/000077500000000000000000000000001252157243100163465ustar00rootroot00000000000000rspec-logsplit-0.1.3/lib/rspec/log_split.rb000066400000000000000000000015071252157243100206720ustar00rootroot00000000000000require 'date' require 'logger' require 'pathname' require 'rspec/log_split/handler' require 'rspec/log_split/config' module RSpec module LogSplit class << self def apply RSpec.configure do |config| config.add_setting :log_split_module config.add_setting :log_split_dir config.add_setting :log_split config.before(:suite) do RSpec.configuration.log_split= Config.new( RSpec.configuration.log_split_module, RSpec.configuration.log_split_dir, ) end config.around(:each) do |example| RSpec.configuration.log_split.run(example) end config.after(:suite) do Handler.list_logs if $DEBUG end end end end end end RSpec::LogSplit.apply rspec-logsplit-0.1.3/lib/rspec/log_split/000077500000000000000000000000001252157243100203425ustar00rootroot00000000000000rspec-logsplit-0.1.3/lib/rspec/log_split/config.rb000066400000000000000000000011111252157243100221260ustar00rootroot00000000000000module RSpec module LogSplit class Config def initialize(mod, dir) @mod = mod @path = Pathname.new(dir) @path.mkpath @logger = logger(@path.join("main")) end def run(example) example_path = @path.join(example.location) example_path.parent.mkpath example_logger = logger(example_path.to_path) Handler.new(@logger, @mod, example, example_logger).run end def logger(path) file = File.open(path, "a") file.sync = true Logger.new(file) end end end end rspec-logsplit-0.1.3/lib/rspec/log_split/handler.rb000066400000000000000000000013711252157243100223060ustar00rootroot00000000000000module RSpec module LogSplit class Handler def initialize(logger, mod, example, example_logger) @logger = logger @mod = mod @example = example @example_logger = example_logger end def run @mod.logger = @example_logger begin error "starting #{description}" @example.run rescue Exception => e error "error with #{description}: #{e.inspect}" raise e ensure error "finishing #{description}" @mod.logger = nil end end def description @example.full_description end def error(message) @logger.error message @mod.logger.error message end end end end rspec-logsplit-0.1.3/lib/rspec/log_split/version.rb000066400000000000000000000000771252157243100223600ustar00rootroot00000000000000module RSpec module LogSplit VERSION = "0.1.3" end end rspec-logsplit-0.1.3/rspec-logsplit.gemspec000066400000000000000000000016221252157243100210010ustar00rootroot00000000000000# -*- encoding: utf-8 -*- require File.expand_path('../lib/rspec/log_split/version', __FILE__) Gem::Specification.new do |gem| gem.name = "rspec-logsplit" gem.version = RSpec::LogSplit::VERSION gem.authors = ["digitalextremist //","Tim Carey-Smith",] gem.email = ["code@extremist.digital","tim@spork.in"] gem.description = %q{A new logger for each example} gem.summary = %q{Separate the logs between examples to allow for easier understanding} gem.homepage = "https://github.com/abstractive/rspec-logsplit" gem.license = "MIT" gem.required_ruby_version = '>= 1.9.2' gem.required_rubygems_version = '>= 1.3.6' gem.files = `git ls-files`.split($/) gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] gem.add_development_dependency 'rake' gem.add_development_dependency 'bundler' end rspec-logsplit-0.1.3/spec/000077500000000000000000000000001252157243100154165ustar00rootroot00000000000000rspec-logsplit-0.1.3/spec/demo_spec.rb000066400000000000000000000002611252157243100177000ustar00rootroot00000000000000require 'spec_helper' describe "foo" do context "bar" do it "baz" do Demo.logger.info "bar" end it "qux" do Demo.logger.info "qux" end end end rspec-logsplit-0.1.3/spec/spec_helper.rb000066400000000000000000000005031252157243100202320ustar00rootroot00000000000000require 'rspec/log_split' Dir["./spec/support/**/*.rb"].sort.each {|f| require f} RSpec.configure do |config| config.filter_run :focus => true config.run_all_when_everything_filtered = true config.log_split_module = Demo config.log_split_dir = File.expand_path("../../log/#{DateTime.now.iso8601}", __FILE__) end rspec-logsplit-0.1.3/spec/support/000077500000000000000000000000001252157243100171325ustar00rootroot00000000000000rspec-logsplit-0.1.3/spec/support/demo.rb000066400000000000000000000000771252157243100204070ustar00rootroot00000000000000class Demo class << self attr_accessor :logger end end rspec-logsplit-0.1.3/spec/support/shared_examples/000077500000000000000000000000001252157243100222765ustar00rootroot00000000000000rspec-logsplit-0.1.3/spec/support/shared_examples/win.rb000066400000000000000000000002511252157243100234160ustar00rootroot00000000000000shared_examples "win" do it "works" do Demo.logger.info "works" end context "mainframe" do it "hacks" do Demo.logger.info "hacks" end end end rspec-logsplit-0.1.3/spec/things_spec.rb000066400000000000000000000001111252157243100202420ustar00rootroot00000000000000require 'spec_helper' describe "things" do include_examples "win" end rspec-logsplit-0.1.3/spec/zebra_spec.rb000066400000000000000000000001101252157243100200500ustar00rootroot00000000000000require 'spec_helper' describe "zebra" do include_examples "win" end rspec-logsplit-0.1.3/tasks/000077500000000000000000000000001252157243100156115ustar00rootroot00000000000000rspec-logsplit-0.1.3/tasks/rspec.rake000066400000000000000000000001771252157243100175760ustar00rootroot00000000000000require 'rspec/core/rake_task' RSpec::Core::RakeTask.new RSpec::Core::RakeTask.new(:rcov) do |task| task.rcov = true end