cutest-reporter 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0370e651d4de184664deb43bafa074b3f5e9ce4238abb7898debc1c6e63c9d4b
4
+ data.tar.gz: 362e55d2c65c3203ed3772e4819f13a5d3f98bf1cee237809a91f8e079a30afb
5
+ SHA512:
6
+ metadata.gz: 3ea8a153d8d20608ae26aaaaa4404f662f51f13f915938dc43bf68804a799043d1947e900097fb84728bd87527b55e5d7bb5468043ced86c86b4fc8b36900e9d
7
+ data.tar.gz: baf64f005257770e494a95d545ddcae8e918cc9d2e4778f1aec90c3b5909b739362dd618f7edecc91fc09d91a9640a05a9d56215595ab56bc04fb3834167e836
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.1
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "rake", "~> 12.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 César Carruitero
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Cutest::Reporter
2
+
3
+ extend [Cutest](https://github.com/djanowski/cutest) to run all tests with a summary report
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'cutest-reporter'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install cutest-reporter
20
+
21
+ ## Usage
22
+
23
+ Add this line in your test file or helper
24
+
25
+ ```ruby
26
+ require 'cutest/reporter'
27
+ ```
28
+
29
+ ## Development
30
+
31
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
+
33
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome at https://github.com/ccarruitero/cutest-reporter.
38
+
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cutest/reporter"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ require_relative 'lib/cutest/reporter/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "cutest-reporter"
5
+ spec.version = Cutest::Reporter::VERSION
6
+ spec.authors = ["César Carruitero"]
7
+ spec.email = ["ccarruitero@protonmail.com"]
8
+
9
+ spec.summary = "extend cutest to allow summary report and some tweacks"
10
+ spec.description = spec.summary
11
+ spec.homepage = "https://github.com/ccarruitero/cutest-reporter"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "cutest"
25
+ spec.add_development_dependency "pry"
26
+ end
@@ -0,0 +1,27 @@
1
+ module Kernel
2
+ private
3
+
4
+ def reporter
5
+ cutest[:reporter] ||= Cutest::Reporter.new
6
+ end
7
+
8
+ def flunk(message = nil)
9
+ backtrace = caller
10
+ trace = backtrace.select { |line| line !~ Cutest::FILTER }
11
+ exception = Cutest::AssertionFailed.new(message)
12
+ exception.set_backtrace(trace)
13
+ reporter.record(cutest[:test], 'failed', exception)
14
+ end
15
+
16
+ def success
17
+ reporter.record(cutest[:test], 'successed')
18
+ end
19
+
20
+ def skip(name = nil, &block)
21
+ backtrace = caller
22
+ trace = backtrace.select { |line| line !~ Cutest::FILTER }
23
+ exception = Cutest::AssertionFailed.new()
24
+ exception.set_backtrace(trace)
25
+ reporter.record(name, 'skipped', exception)
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ class Cutest
2
+ class Reporter
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,58 @@
1
+ require "cutest"
2
+ require "cutest/kernel"
3
+ require "cutest/runner"
4
+ require "cutest/reporter/version"
5
+ require "cutest/result"
6
+
7
+ class Cutest
8
+ class Reporter
9
+ attr_reader :results
10
+
11
+ def initialize
12
+ @results = []
13
+ end
14
+
15
+ # Store test result
16
+ def record name, state, exception = nil
17
+ results.push(Result.new(name, state, exception))
18
+ print display(state)
19
+ end
20
+
21
+ # Output summary report
22
+ def report
23
+ successed = results.select(&:successed?)
24
+ failed = results.select(&:failed?)
25
+ skipped = results.select(&:skipped?)
26
+
27
+ puts
28
+ puts "#{results.count} tests"
29
+ puts "#{successed.count} successed"
30
+ puts "#{failed.count} failed"
31
+ puts "#{skipped.count} skipped"
32
+
33
+ display_result_trace(failed, "Failed:") if failed.count > 0
34
+ display_result_trace(skipped, "Skipped:") if skipped.count > 0
35
+ end
36
+
37
+ private
38
+
39
+ def display_result_trace(results, header)
40
+ puts header
41
+ results.each do |result|
42
+ puts "test: #{result.name}"
43
+ result&.exception&.backtrace&.each { |line| Cutest.display_trace(line) }
44
+ end
45
+ end
46
+
47
+ def display state
48
+ case state
49
+ when "successed"
50
+ "."
51
+ when "failed"
52
+ "F"
53
+ when "skipped"
54
+ "S"
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,17 @@
1
+ class Cutest
2
+ class Result
3
+ STATES = %w[successed failed skipped].freeze
4
+
5
+ attr_reader :name, :state, :exception
6
+
7
+ def initialize(name, state, exception = nil)
8
+ @name, @state, @exception = name, state, exception
9
+
10
+ STATES.each do |method|
11
+ define_singleton_method "#{method}?" do
12
+ state == method
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ class Cutest
2
+ module Runner
3
+ def autorun
4
+ at_exit { reporter.report }
5
+ end
6
+ end
7
+ end
8
+
9
+ Cutest.extend Cutest::Runner
10
+
11
+ Cutest.autorun
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cutest-reporter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - César Carruitero
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cutest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: extend cutest to allow summary report and some tweacks
42
+ email:
43
+ - ccarruitero@protonmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - cutest-reporter.gemspec
57
+ - lib/cutest/kernel.rb
58
+ - lib/cutest/reporter.rb
59
+ - lib/cutest/reporter/version.rb
60
+ - lib/cutest/result.rb
61
+ - lib/cutest/runner.rb
62
+ homepage: https://github.com/ccarruitero/cutest-reporter
63
+ licenses:
64
+ - MIT
65
+ metadata:
66
+ homepage_uri: https://github.com/ccarruitero/cutest-reporter
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 2.3.0
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubygems_version: 3.0.6
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: extend cutest to allow summary report and some tweacks
86
+ test_files: []