fivemat 1.0.0

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,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Tim Pope
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/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) Tim Pope
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # Fivemat
2
+
3
+ Why settle for a test output *format* when you can have a test output
4
+ *fivemat*?
5
+
6
+ I'm tired of the two *de facto* standards for test output:
7
+
8
+ 1. Bunch of dots — Wait till the end to see what failed, and
9
+ guess the dot count to estimate progress.
10
+ 2. Extreme verbosity — See failures as they happen if you pay very,
11
+ very close attention.
12
+
13
+ In other words, you can choose between "too little" or "too much."
14
+
15
+ I've looked at third party alternatives, but none of them did much for
16
+ me. What I want is the middle ground: dots grouped by file. Thus,
17
+ I give you Fivemat:
18
+
19
+ DoohickeyTest ....
20
+ KajiggerTest .........................F...........
21
+ 1) Failure:
22
+ test_isnt_actually_nil(KajiggerTest) [test/kajigger_test.rb:17]:
23
+ Expected nil to not be nil.
24
+ WhatchamacallitTest ................................................
25
+ WidgetTest ...E......
26
+ 2) Error:
27
+ ZeroDivisionError: divided by 0
28
+ test/widget_test.rb:20:in `/'
29
+ test/widget_test.rb:20:in `test_dividing_by_1'
30
+
31
+ MiniTest, RSpec, and Cucumber are supported. Here, have some sample
32
+ Cucumber output:
33
+
34
+ features/sign_in.feature ......F--........
35
+ no button with value or id or text 'Go' found (Capybara::ElementNotFound)
36
+ ./features/step_definitions/web_steps.rb:53:in `/^I press "([^"]*)"$/'
37
+ ./features/sign_in.feature:10:in `When I press "Log In"'
38
+ features/sign_out.feature .......
39
+ features/sign_up.feature ...............................................
40
+
41
+ ## Usage
42
+
43
+ Start by adding `gem 'fivemat'` to your `Gemfile`.
44
+
45
+ ### MiniTest
46
+
47
+ Change `require 'minitest/autorun'` to `require 'fivemat/minitest/autorun'`.
48
+
49
+ ### RSpec
50
+
51
+ Add `--format Fivemat` to `.rspec`.
52
+
53
+ ### Cucumber
54
+
55
+ Add `--format Fivemat` to `cucumber.yml`.
56
+
57
+ ## Contributing
58
+
59
+ Don't forget to include test coverage for any changes you introduce.
60
+ (Ha! I kid! Everybody knows it's impossible to test a test library.)
61
+
62
+ ## License
63
+
64
+ Copyright © Tim Pope. MIT License.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/fivemat.gemspec ADDED
@@ -0,0 +1,16 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["Tim Pope"]
5
+ gem.email = ["code@tp" + 'ope.net']
6
+ gem.description = %q{MiniTest/RSpec/Cucumber formatter that gives each test file its own line of dots}
7
+ gem.summary = %q{Why settle for a test output format when you could have a test output fivemat?}
8
+ gem.homepage = "https://github.com/tpope/fivemat"
9
+
10
+ gem.files = `git ls-files`.split($\)
11
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
12
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
+ gem.name = "fivemat"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = '1.0.0'
16
+ end
@@ -0,0 +1,29 @@
1
+ require 'cucumber/formatter/progress'
2
+
3
+ module Fivemat
4
+ class Cucumber < ::Cucumber::Formatter::Progress
5
+ def before_feature(feature)
6
+ @io.print "#{feature.file} "
7
+ @io.flush
8
+ @exceptions = []
9
+ end
10
+
11
+ def after_feature(feature)
12
+ @io.puts
13
+ @exceptions.each do |(exception, status)|
14
+ print_exception(exception, status, 2)
15
+ end
16
+ end
17
+
18
+ def exception(exception, status)
19
+ @exceptions << [exception, status]
20
+ super
21
+ end
22
+
23
+ def after_features(features)
24
+ @io.puts
25
+ print_stats(features, @options)
26
+ print_passing_wip(@options)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,2 @@
1
+ require 'minitest/autorun'
2
+ require 'fivemat/minitest'
@@ -0,0 +1,26 @@
1
+ require 'minitest/unit'
2
+
3
+ module Fivemat
4
+ module MiniTest
5
+ class Unit < ::MiniTest::Unit
6
+ def _run_suites(suites, type)
7
+ offset = 0
8
+ suites.reject do |suite|
9
+ filter = options[:filter] || '/./'
10
+ filter = Regexp.new $1 if filter =~ /\/(.*)\//
11
+ suite.send("#{type}_methods").grep(filter).empty?
12
+ end.map do |suite|
13
+ print "#{suite} "
14
+ result = _run_suite suite, type
15
+ puts
16
+ report.each_with_index do |msg, i|
17
+ puts "%3d) %s" % [offset + i + 1, msg.gsub(/\n/, "\n ")]
18
+ end
19
+ offset += report.size
20
+ report.clear
21
+ result
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ require 'fivemat/minitest/unit'
2
+
3
+ MiniTest::Unit.runner = Fivemat::MiniTest::Unit.new
@@ -0,0 +1,41 @@
1
+ require 'rspec/core/formatters/progress_formatter'
2
+
3
+ module Fivemat
4
+ class RSpec < ::RSpec::Core::Formatters::ProgressFormatter
5
+ def initialize(*)
6
+ super
7
+ @group_level = 0
8
+ @index_offset = 0
9
+ end
10
+
11
+ def example_group_started(group)
12
+ if @group_level.zero?
13
+ output.print "#{group.description} "
14
+ @failure_output = []
15
+ end
16
+ @group_level += 1
17
+ end
18
+
19
+ def example_group_finished(group)
20
+ @group_level -= 1
21
+ if @group_level.zero?
22
+ output.puts
23
+ failed_examples.each_with_index do |example, index|
24
+ if pending_fixed?(example)
25
+ dump_pending_fixed(example, @index_offset + index)
26
+ else
27
+ dump_failure(example, @index_offset + index)
28
+ end
29
+ dump_backtrace(example)
30
+ end
31
+ @index_offset += failed_examples.size
32
+ failed_examples.clear
33
+ end
34
+ end
35
+
36
+ def start_dump
37
+ # Skip the call to output.puts in the messiest way possible.
38
+ self.class.superclass.superclass.instance_method(:start_dump).bind(self).call
39
+ end
40
+ end
41
+ end
data/lib/fivemat.rb ADDED
@@ -0,0 +1,15 @@
1
+ module Fivemat
2
+ autoload :Cucumber, 'fivemat/cucumber'
3
+ autoload :MiniTest, 'fivemat/minitest/unit'
4
+ autoload :RSpec, 'fivemat/rspec'
5
+
6
+ def self.new(*args)
7
+ case args.size
8
+ when 0 then MiniTest::Unit
9
+ when 1 then RSpec
10
+ when 3 then Cucumber
11
+ else
12
+ raise ArgumentError
13
+ end.new(*args)
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fivemat
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tim Pope
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-12 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: MiniTest/RSpec/Cucumber formatter that gives each test file its own line
15
+ of dots
16
+ email:
17
+ - code@tpope.net
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE
25
+ - MIT-LICENSE
26
+ - README.md
27
+ - Rakefile
28
+ - fivemat.gemspec
29
+ - lib/fivemat.rb
30
+ - lib/fivemat/cucumber.rb
31
+ - lib/fivemat/minitest.rb
32
+ - lib/fivemat/minitest/autorun.rb
33
+ - lib/fivemat/minitest/unit.rb
34
+ - lib/fivemat/rspec.rb
35
+ homepage: https://github.com/tpope/fivemat
36
+ licenses: []
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 1.8.21
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: Why settle for a test output format when you could have a test output fivemat?
59
+ test_files: []