rspec_numbering_formatter 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.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
+ .#*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec_numbering_formatter.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 conanite
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,62 @@
1
+ # RspecNumberingFormatter
2
+
3
+ An rspec formatter that shows elapsed time, example count, example description, and example location, with no scrolling except for errors.
4
+
5
+ Output looks something like this:
6
+
7
+ $ rspec spec --format RspecNumberingFormatter
8
+ 5678 examples
9
+ 3:18 3999 A Widget when updated should not show widget status unless fa /spec/models/widgets/widget_update_spec.rb:42
10
+
11
+ This formatter uses ANSI escape sequences to overwrite and re-use the same line so you do
12
+ not get massive amounts of information scrolling past; you just see where you are in the
13
+ process, and how much time has elapsed so far.
14
+
15
+ A problem with the otherwise-excellent "progress" formatter arises when you have a large
16
+ number of examples taking a long time to run (like, anything more than sixty seconds). You
17
+ see a red "F" in the output, but you have to wait till the end of the process to see what
18
+ the problem is.
19
+
20
+ Another problem is that when you have zillions of examples, the "progress" formatter turns
21
+ your terminal into a sea of dots, and it's hard to know when your run will be finished. This
22
+ format prints the elapsed time along with the example count at the beginning of each line,
23
+ the better to help you judge how long you need to wait before hitting the magic DEPLOY button.
24
+
25
+ This formatter outputs failure information immediately so you can proceed with fixing instead
26
+ of twiddling your thumbs or browsing your favourite social site while your test suite hums
27
+ away in the background. This formatter means you can be more efficient while coding. Basically,
28
+ it makes you a better person. You should start using this formatter now.
29
+
30
+ Note: (seriously) if your main project has 6,000 rspec examples, like mine does, it's probably
31
+ pathological, and you should probably refactor, as I should. This formatter can help you cope
32
+ while you're waiting for the doctor.
33
+
34
+
35
+ ## Installation
36
+
37
+ Add these lines to your application's Gemfile:
38
+
39
+ group :test do
40
+ gem 'rspec_numbering_formatter'
41
+ end
42
+
43
+ And then execute:
44
+
45
+ $ bundle
46
+
47
+
48
+ ## Usage
49
+
50
+ Run rspec thus:
51
+
52
+ $ bundle exec rspec spec --format RspecNumberingFormatter
53
+
54
+ Enjoy the immediate boost to your productivity.
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,39 @@
1
+ require 'rspec/core/formatters/base_text_formatter'
2
+
3
+ # useful reference: http://ascii-table.com/ansi-escape-sequences.php
4
+
5
+ class RspecNumberingFormatter < RSpec::Core::Formatters::BaseTextFormatter
6
+ VERSION = "0.0.1"
7
+
8
+ attr_accessor :run_count
9
+
10
+ def start(example_count)
11
+ @pwd = `pwd`
12
+ @start_time = Time.now
13
+ @run_count = 0
14
+ super
15
+ output.puts "#{example_count} examples"
16
+ end
17
+
18
+ def example_passed(example)
19
+ super
20
+ elapsed = (Time.now - @start_time).to_i
21
+ secs = elapsed % 60
22
+ mins = elapsed / 60
23
+ elapsed = "#{mins}:#{secs.to_s.rjust(2, '0')}"
24
+ @run_count += 1
25
+ output.print "\r\e[K#{elapsed.rjust(8)} #{@run_count.to_s.rjust(10)} #{example.full_description[0..100].ljust(101)} #{truncate_pwd(example.location)[0..100]}"
26
+ end
27
+
28
+ def example_failed(example)
29
+ super
30
+ @run_count += 1
31
+ output.puts failure_color("\r\e[K#{@run_count.to_s.rjust(10)} #{example.full_description}")
32
+ output.puts failure_color(" #{truncate_pwd example.location}")
33
+ dump_failure_info example
34
+ end
35
+
36
+ def truncate_pwd str
37
+ str.sub @pwd, ""
38
+ end
39
+ end
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8; mode: ruby -*-
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'rspec_numbering_formatter'
7
+
8
+ Gem::Specification.new do |gem|
9
+ gem.name = "rspec_numbering_formatter"
10
+ gem.version = RspecNumberingFormatter::VERSION
11
+ gem.authors = ["Conan Dalton"]
12
+ gem.license = 'MIT'
13
+ gem.email = ["conan@conandalton.net"]
14
+ gem.description = %q{ An rspec formatter that shows elapsed time, example count, example description, and example location, with no scrolling except for errors. }
15
+ gem.summary = %q{ RSpec formatter with more information in less space }
16
+ gem.homepage = "https://github.com/conanite/rspec_numbering_formatter"
17
+
18
+ gem.add_development_dependency 'rspec', '~> 2.9'
19
+
20
+ gem.files = `git ls-files`.split($/)
21
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
22
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
23
+ gem.require_paths = ["lib"]
24
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe RspecNumberingFormatter do
4
+ it "should produce helpful output" do
5
+ rspec_command = 'bundle exec rspec spec/sample-specs --format RspecNumberingFormatter -P "**/*_spec_sample.rb" 2>&1'
6
+ output = `#{rspec_command}`
7
+ output.gsub!(/Finished in \d+.\d+ seconds/, 'Finished in some seconds').gsub!(/\r/, "\n*").gsub!(/\e/, 'ESC')
8
+ output.should == "4 examples
9
+
10
+ *ESC[K 0:00 1 first should be nil ./spec/sample-specs/first_spec_sample.rb:4
11
+ *ESC[K 0:00 2 first should be non-nil ./spec/sample-specs/first_spec_sample.rb:8
12
+ *ESC[K 3 second sample should include a broken test
13
+ ./spec/sample-specs/second_spec_sample.rb:4
14
+ Failure/Error: (1 + 1).should == 3
15
+ expected: 3
16
+ got: 2 (using ==)
17
+
18
+ *ESC[K 0:00 4 second sample should be true ./spec/sample-specs/second_spec_sample.rb:8
19
+ Failures:
20
+
21
+ 1) second sample should include a broken test
22
+ Failure/Error: (1 + 1).should == 3
23
+ expected: 3
24
+ got: 2 (using ==)
25
+ # ./spec/sample-specs/second_spec_sample.rb:5:in `block (2 levels) in <top (required)>'
26
+
27
+ Finished in some seconds
28
+ 4 examples, 1 failure
29
+
30
+ Failed examples:
31
+
32
+ rspec ./spec/sample-specs/second_spec_sample.rb:4 # second sample should include a broken test
33
+ "
34
+ end
35
+ end
@@ -0,0 +1,11 @@
1
+ require 'sample_spec_helper'
2
+
3
+ describe "first" do
4
+ it "should be nil" do
5
+ [].first.should == nil
6
+ end
7
+
8
+ it "should be non-nil" do
9
+ [:a].first.should == :a
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'sample_spec_helper'
2
+
3
+ describe "second sample" do
4
+ it "should include a broken test" do
5
+ (1 + 1).should == 3
6
+ end
7
+
8
+ it "should be true" do
9
+ true.should == true
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ RSpec.configure do |config|
2
+ config.treat_symbols_as_metadata_keys_with_true_values = true
3
+ config.run_all_when_everything_filtered = true
4
+ end
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec_numbering_formatter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Conan Dalton
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-10-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.9'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.9'
30
+ description: ! ' An rspec formatter that shows elapsed time, example count, example
31
+ description, and example location, with no scrolling except for errors. '
32
+ email:
33
+ - conan@conandalton.net
34
+ executables: []
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - .rspec
40
+ - Gemfile
41
+ - LICENSE.txt
42
+ - README.md
43
+ - Rakefile
44
+ - lib/rspec_numbering_formatter.rb
45
+ - rspec_numbering_formatter.gemspec
46
+ - spec/rspec_numbering_formatter_spec.rb
47
+ - spec/sample-specs/first_spec_sample.rb
48
+ - spec/sample-specs/second_spec_sample.rb
49
+ - spec/sample_spec_helper.rb
50
+ - spec/spec_helper.rb
51
+ homepage: https://github.com/conanite/rspec_numbering_formatter
52
+ licenses:
53
+ - MIT
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 1.8.24
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: RSpec formatter with more information in less space
76
+ test_files:
77
+ - spec/rspec_numbering_formatter_spec.rb
78
+ - spec/sample-specs/first_spec_sample.rb
79
+ - spec/sample-specs/second_spec_sample.rb
80
+ - spec/sample_spec_helper.rb
81
+ - spec/spec_helper.rb