rspec-longrun-0.1.2/0000755000175000017500000000000012217250614013666 5ustar boutilboutilrspec-longrun-0.1.2/examples/0000755000175000017500000000000012217250614015504 5ustar boutilboutilrspec-longrun-0.1.2/examples/example_spec.rb0000644000175000017500000000127712217250614020505 0ustar boutilboutilrequire 'rspec' require 'rspec/longrun' describe "Underpants gnomes" do include RSpec::Longrun::DSL it "The plan" do step "Collect underpants" do end step "Umm ..." do sleep 0.3 # thinking end step "Profit!" do pending "need a real business plan" end end end describe "Killer app" do include RSpec::Longrun::DSL describe "Some feature" do it "Scenario 1" do step "Step 1" do end step "Step 2" do end step "Step 3" do end end it "Scenario 2" do end end describe "Another feature" do it "Scenario" do step "Step 1" do end step "Step 2" do end end end end rspec-longrun-0.1.2/Gemfile0000644000175000017500000000012512217250614015157 0ustar boutilboutilsource "https://rubygems.org" gemspec gem "rake" gem "rspec", ENV["RSPEC_VERSION"] rspec-longrun-0.1.2/metadata.yml0000644000175000017500000000314112217250614016170 0ustar boutilboutil--- !ruby/object:Gem::Specification name: rspec-longrun version: !ruby/object:Gem::Version version: 0.1.2 platform: ruby authors: - Mike Williams autorequire: bindir: bin cert_chain: [] date: 2013-02-28 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ! '>=' - !ruby/object:Gem::Version version: 2.10.0 name: rspec-core requirement: !ruby/object:Gem::Requirement requirements: - - ! '>=' - !ruby/object:Gem::Version version: 2.10.0 type: :runtime description: email: - mdub@dogbiscuit.org executables: [] extensions: [] extra_rdoc_files: [] files: - .gitignore - .rspec - .travis.yml - Gemfile - LICENSE - README.md - Rakefile - examples/example_spec.rb - lib/rspec/longrun.rb - lib/rspec/longrun/core_ext.rb - lib/rspec/longrun/dsl.rb - lib/rspec/longrun/formatter.rb - lib/rspec/longrun/version.rb - rspec-longrun.gemspec - spec/rspec/longrun/formatter_spec.rb homepage: http://github.com/mdub/rspec-longrun licenses: [] metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.0.0 signing_key: specification_version: 4 summary: An RSpec formatter for long-running specs. test_files: - spec/rspec/longrun/formatter_spec.rb rspec-longrun-0.1.2/.travis.yml0000644000175000017500000000021412217250614015774 0ustar boutilboutillanguage: ruby env: - RSPEC_VERSION="~> 2.10.0" - RSPEC_VERSION="~> 2.11.0" - RSPEC_VERSION="~> 2.12.0" - RSPEC_VERSION="~> 2.13.0" rspec-longrun-0.1.2/LICENSE0000644000175000017500000000205512217250614014675 0ustar boutilboutilCopyright (c) 2012 Mike Williams 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-longrun-0.1.2/README.md0000644000175000017500000000377612217250614015162 0ustar boutilboutil# RSpec::Longrun RSpec is a fine unit-testing framework, but is also handy for acceptance and integration tests. But the default report formatters make it difficult to track progress of such long-running tests. The RSpec::Longrun::Formatter outputs the name of each test as it starts, rather than waiting until it passes or fails. It also provides a mechanism for reporting on progress of a test while it is still executing. ## Installation Add this line to your application's Gemfile: gem 'rspec-longrun' In a Rails project, you can safely limit it to the "test" group. ## Usage ### Running tests Specify the custom output format when invoking RSpec, as follows: rspec -r rspec/longrun -f RSpec::Longrun::Formatter spec ... The resulting test output looks something like: Example group { First example OK (1.2s) Second example OK (3.4s) Third example PENDING (Not implemented yet) (0.2s) } (5.2s) (though a little more colourful). ### Tracking progress Include RSpec::Longrun::DSL to define the 'step' method, which can be used to group blocks of code within the context of a large test. For example: describe "Account management" do include RSpec::Longrun::DSL # <-- important example "Log in and alter preferences" do step "Log in" do ui.go_home ui.authenticate_as "joe", "fnord" end step "Navigate to preferences page" do ui.nav.prefs_link.click end step "Change preferences" do ui.prefs_pane.enter_defaults ui.prefs_pane.save end end end The resulting test output looks something like: Account management { Log in and alter preferences { Log in (0.5s) Navigate to preferences page (0.2s) Change preferences (5.2s) } OK (7.1s) } OK (7.2s) which gives you some extra context in the event that something fails, or hangs, during the test run. ## Contributing rspec-longrun is on Github. You know what to do. rspec-longrun-0.1.2/.rspec0000644000175000017500000000006612217250614015005 0ustar boutilboutil-r rspec/longrun -f RSpec::Longrun::Formatter --color rspec-longrun-0.1.2/Rakefile0000644000175000017500000000035312217250614015334 0ustar boutilboutil#!/usr/bin/env rake require "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) do |t| t.pattern = 'spec/**/*_spec.rb' t.rspec_opts = ["--colour", "--format", "nested"] end task :default => :spec rspec-longrun-0.1.2/lib/0000755000175000017500000000000012217250614014434 5ustar boutilboutilrspec-longrun-0.1.2/lib/rspec/0000755000175000017500000000000012217250614015550 5ustar boutilboutilrspec-longrun-0.1.2/lib/rspec/longrun.rb0000644000175000017500000000013712217250614017562 0ustar boutilboutilrequire "rspec/longrun/dsl" require "rspec/longrun/formatter" require "rspec/longrun/version" rspec-longrun-0.1.2/lib/rspec/longrun/0000755000175000017500000000000012217250614017234 5ustar boutilboutilrspec-longrun-0.1.2/lib/rspec/longrun/dsl.rb0000644000175000017500000000063312217250614020345 0ustar boutilboutilrequire 'rspec/longrun/core_ext' # extend rspec-core with support for "steps" module RSpec module Longrun module DSL private def step(description) pending(description) unless block_given? begin @_rspec_reporter.step_started(description) yield ensure @_rspec_reporter.step_finished(description) end end end end end rspec-longrun-0.1.2/lib/rspec/longrun/formatter.rb0000644000175000017500000000543112217250614021567 0ustar boutilboutilrequire "rspec/core/formatters/base_text_formatter" module RSpec module Longrun class Formatter < RSpec::Core::Formatters::BaseTextFormatter def initialize(output) super(output) @blocks = [Block.new(true)] end def example_group_started(example_group) super(example_group) begin_block(example_group.description) end def example_group_finished(example_group) super(example_group) end_block end def example_started(example) super(example) begin_block(detail_color(example.description)) end def example_passed(example) super(example) end_block(success_color("OK")) end def example_pending(example) super(example) end_block(pending_color("PENDING: " + example.execution_result[:pending_message])) end def example_failed(example) super(example) end_block(failure_color("FAILED")) end def step_started(description) begin_block(description) end def step_finished(description) end_block end protected def self.alias_missing_method(method_name, fallback_method_name) unless method_defined?(method_name) alias_method method_name, fallback_method_name end end alias_missing_method :detail_color, :cyan alias_missing_method :success_color, :green alias_missing_method :pending_color, :yellow alias_missing_method :failure_color, :red private def current_block @blocks.last end def begin_block(message) unless current_block.nested? output << faint("{\n") current_block.nested! end output << current_indentation output << message.strip output << ' ' @blocks.push(Block.new) end def end_block(message = nil) block = @blocks.pop block.finished! if block.nested? output << current_indentation output << faint('} ') end if message output << message.strip output << ' ' end output << faint('(' + block.timing + ')') output << "\n" end def current_indentation ' ' * (@blocks.size - 1) end def faint(text) color(text, "\e[2m") end class Block def initialize(nested = false) @began_at = Time.now @nested = nested end def finished! @finished_at = Time.now end def timing delta = @finished_at - @began_at '%.2fs' % delta end def nested! @nested = true end def nested? @nested end end end end end rspec-longrun-0.1.2/lib/rspec/longrun/core_ext.rb0000644000175000017500000000126512217250614021375 0ustar boutilboutilrequire 'rspec/core' require 'rspec/core/formatters/base_formatter' # extend rspec-core with support for "steps" module RSpec::Core class Reporter def step_started(description) notify :step_started, description end def step_finished(description) notify :step_finished, description end end class Formatters::BaseFormatter def step_started(description) end def step_finished(description) end end class Example private alias :start_without_reporter :start def start(reporter) start_without_reporter(reporter) @example_group_instance.instance_variable_set(:@_rspec_reporter, reporter) end end end rspec-longrun-0.1.2/lib/rspec/longrun/version.rb0000644000175000017500000000007612217250614021251 0ustar boutilboutilmodule RSpec module Longrun VERSION = "0.1.2" end end rspec-longrun-0.1.2/spec/0000755000175000017500000000000012217250614014620 5ustar boutilboutilrspec-longrun-0.1.2/spec/rspec/0000755000175000017500000000000012217250614015734 5ustar boutilboutilrspec-longrun-0.1.2/spec/rspec/longrun/0000755000175000017500000000000012217250614017420 5ustar boutilboutilrspec-longrun-0.1.2/spec/rspec/longrun/formatter_spec.rb0000644000175000017500000000440512217250614022765 0ustar boutilboutilrequire "rspec/longrun" require "stringio" describe RSpec::Longrun::Formatter do let(:output_buffer) { StringIO.new } let(:formatter) { described_class.new(output_buffer) } def undent(raw) if raw =~ /\A( +)/ indent = $1 raw.gsub(/^#{indent}/, '').gsub(/ +$/, '') else raw end end def output output_buffer.string end def normalized_output output.gsub(/0\.\d\ds/, "N.NNs") end module NoColor def color_enabled? false end end before do formatter.extend(NoColor) suite.run(formatter) end context "for nested example groups" do let(:suite) do RSpec::Core::ExampleGroup.describe("foo") do describe "bar" do describe "baz" do end end describe "qux" do end end end it "outputs nested group names" do normalized_output.should eql(undent(<<-EOF)) foo { bar { baz (N.NNs) } (N.NNs) qux (N.NNs) } (N.NNs) EOF end end context "with examples" do let(:suite) do RSpec::Core::ExampleGroup.describe("suite") do example "works" do; end example "is unimplemented" do pending "implement me" end example "fails" do fail "no worky" end end end it "outputs example names and status" do normalized_output.should eql(undent(<<-EOF)) suite { works OK (N.NNs) is unimplemented PENDING: implement me (N.NNs) fails FAILED (N.NNs) } (N.NNs) EOF end end context "with steps" do let(:suite) do RSpec::Core::ExampleGroup.describe("suite") do include RSpec::Longrun::DSL example "has steps" do step "Collect underpants" do end step "Er ..." do step "(thinking)" do end end step "Profit!" end end end it "outputs steps" do normalized_output.should eql(undent(<<-EOF)) suite { has steps { Collect underpants (N.NNs) Er ... { (thinking) (N.NNs) } (N.NNs) } PENDING: Profit! (N.NNs) } (N.NNs) EOF end end end rspec-longrun-0.1.2/rspec-longrun.gemspec0000644000175000017500000000116512217250614020034 0ustar boutilboutil# -*- encoding: utf-8 -*- require File.expand_path('../lib/rspec/longrun/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["Mike Williams"] gem.email = ["mdub@dogbiscuit.org"] gem.summary = "An RSpec formatter for long-running specs." gem.homepage = "http://github.com/mdub/rspec-longrun" gem.files = `git ls-files`.split($\) gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.name = "rspec-longrun" gem.require_paths = ["lib"] gem.version = RSpec::Longrun::VERSION gem.add_runtime_dependency("rspec-core", ">= 2.10.0") end rspec-longrun-0.1.2/.gitignore0000644000175000017500000000010312217250614015650 0ustar boutilboutil*.gem .bundle Gemfile.lock coverage doc/ pkg rdoc spec/reports tmp rspec-longrun-0.1.2/checksums.yaml.gz0000444000175000017500000000065112217250614017156 0ustar boutilboutilj/QO0S/H9Bu,K=,~Nz( 47n7_Ͽ.k2 uS2^[~oRCn@B=|@|v3~qPNtV ?$jZm2&gV?O 阴9WKbyq )k/~Jha>{Yit5쐦} f35ܼ-yqc7Ctf\gm+>@)ΰM<<cLdHgAcJ4ڞg4I+?S<{ÀB>=iuO(FXְoH猄{jo18QHշ1Ti1` qP'z):ˡ*