towel-minitest 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: afc38d5f22716e715ab85ab4f31e8c29b5960c0161a793ee009263dfb4af75be
4
+ data.tar.gz: daff2fe96a8fce0b2031a56f3ebe04ce8e3183943c733af86d39bb7559acba7a
5
+ SHA512:
6
+ metadata.gz: 23b9b4a89fdafc1fe461253781e43d1fd878c19b14819d12be6cab2f82dd9488111763d45b473f4d9cc925de74f32730f65633ce2140e74ae62453ae3cdc3e64
7
+ data.tar.gz: 229a0177878d2981b2b6d175b7081b37e9fe6137911510de8e5537a360a4adfc121fad7aa33fcaad3730f1e72881b023d359f2c1d5f48d4ffae8093b7b4822fe
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in towel-minitest.gemspec
6
+ gemspec
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Towel::Minitest
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/towel/minitest`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'towel-minitest'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install towel-minitest
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/towel-minitest. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Towel::Minitest project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/towel-minitest/blob/master/CODE_OF_CONDUCT.md).
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 "towel/minitest"
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,39 @@
1
+ # This is an example configuration file for Towel. It shows most of the
2
+ # different options that can be set, even though a normal config file will only
3
+ # have a subset of options specified. Towel uses TOML for configuration. It's a
4
+ # lot like INI, but well-defined. To get a feel for the syntax, look at
5
+ # https://github.com/toml-lang/toml/blob/v0.5.0/README.md
6
+
7
+
8
+ [auth]
9
+ # The Towel account that is reporting invocations. This is how your invocations
10
+ # are linked to you.
11
+ account = "wile.e.coyote@acme.corp"
12
+
13
+ # The API key to communicate with. DO NOT commit this or make this public to
14
+ # others that you do not want them to be able to report to Towel.
15
+ api_key = "AezKF3gPPyzD8dvgDYFYF9we5YP4R87UqhTzDxs3CnkY"
16
+
17
+
18
+ [collector]
19
+ # Where should results be reported to. This should be a hostname and port if
20
+ # non-standard (443). This allows you to point against different Towel instances
21
+ # (staging for example).
22
+ address = "localhost:10081"
23
+
24
+ # The organization handle for the organization that holds your Towel projects.
25
+ organization = "acme"
26
+
27
+ # The project handle for the project that invocations should be reported under.
28
+ project = "dynamite"
29
+
30
+
31
+ # This section is free-form. You can add whatever labels you would like to
32
+ # appear on all invocations reported using this configuration. This is useful
33
+ # for per-branch or per-environment annotations. NOTE: Only string values are
34
+ # allowed here.
35
+ [labels]
36
+ branch = "master"
37
+ environment = "test"
38
+ language = "ruby"
39
+ framework = "minitest"
@@ -0,0 +1,29 @@
1
+ require "bundler/setup"
2
+ require "minitest/autorun"
3
+
4
+ class ParallelTest < Minitest::Test
5
+ parallelize_me!
6
+
7
+ def test_foo
8
+ puts "foo"
9
+ end
10
+
11
+ def test_bar
12
+ puts "bar"
13
+ end
14
+
15
+ def test_baz
16
+ puts "baz"
17
+ flunk "The 'baz' plugin is not currently installed"
18
+ end
19
+
20
+ def test_box
21
+ puts "box"
22
+ raise ArgumentError, "This was unexpected"
23
+ end
24
+
25
+ def test_zap
26
+ puts "zap"
27
+ skip "Zap is not implemented yet"
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ require "bundler/setup"
2
+ require "minitest/autorun"
3
+
4
+ Foo = Class.new
5
+
6
+ describe Foo do
7
+ describe "foo" do
8
+ it "acts normally" do
9
+ puts "OK"
10
+ end
11
+
12
+ it "stays cool"
13
+ it "never gives up"
14
+ end
15
+
16
+ describe "bar" do
17
+ it "is a little unsure of itself" do
18
+ raise ArgumentError, "Not sure of myself"
19
+ end
20
+
21
+ it "needs affirmation" do
22
+ _(false).must_equal true
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ require "bundler/setup"
2
+ require "minitest/autorun"
3
+
4
+ class FooTest < Minitest::Test
5
+ def test_foo
6
+ puts "foo"
7
+ end
8
+
9
+ def test_bar
10
+ puts "bar"
11
+ end
12
+
13
+ def test_baz
14
+ puts "baz"
15
+ flunk "The 'baz' plugin is not currently installed"
16
+ end
17
+
18
+ def test_box
19
+ puts "box"
20
+ raise ArgumentError, "This was unexpected"
21
+ end
22
+
23
+ def test_zap
24
+ puts "zap"
25
+ skip "Zap is not implemented yet"
26
+ end
27
+ end
28
+
29
+
30
+ class LongTest < Minitest::Test
31
+ def test_wait
32
+ sleep 10.0
33
+ end
34
+ end
35
+
@@ -0,0 +1,12 @@
1
+ require "towel/minitest"
2
+
3
+ module Minitest
4
+ def self.plugin_towel_options(opts, options)
5
+ end
6
+
7
+ def self.plugin_towel_init(options)
8
+ unless Towel.disabled?
9
+ self.reporter << Towel::Minitest::Reporter.new(options)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # Gems
2
+ require "minitest"
3
+ require "towel"
4
+
5
+ require "towel/minitest/reporter"
6
+ require "towel/minitest/version"
7
+
8
+ module Towel
9
+ module Minitest
10
+ class Error < StandardError; end
11
+ # Your code goes here...
12
+ end
13
+ end
@@ -0,0 +1,102 @@
1
+ module Towel
2
+ module Minitest
3
+ # Reports Minitest results to Towel.
4
+ class Reporter < ::Minitest::AbstractReporter
5
+ def initialize(options)
6
+ @session = Towel::Session.new
7
+ @stdout = nil
8
+ @stderr = nil
9
+ @previous_stdout = nil
10
+ @previous_stderr = nil
11
+ @cancelled = false
12
+ end
13
+
14
+ def start
15
+ url = @session.create_invocation
16
+ puts "View test results at #{url}"
17
+
18
+ # Register a cancellation handler
19
+ old_handler = Signal.trap("INT") do
20
+ @cancelled = true
21
+ if old_handler.respond_to?(:call)
22
+ old_handler.call
23
+ else
24
+ raise Interrupt
25
+ end
26
+ end
27
+
28
+ # Capture logs
29
+ @previous_stdout = $stdout
30
+ $stdout = @stdout = Towel::LogIO.new(@session.create_log("STDOUT"))
31
+ @previous_stderr = $stderr
32
+ $stderr = @stderr = Towel::LogIO.new(@session.create_log("STDERR"))
33
+ end
34
+
35
+ def prerecord(klass, name)
36
+ context = @session.create_result(
37
+ klass.to_s,
38
+ name,
39
+ display_name: result_name(klass, name)
40
+ )
41
+
42
+ @stdout.context = context
43
+ @stderr.context = context
44
+ end
45
+
46
+ def record(result)
47
+ if result.passed?
48
+ state = Towel::V1alpha::ResultState::SUCCESS
49
+ elsif result.skipped?
50
+ state = Towel::V1alpha::ResultState::SKIPPED
51
+ elsif result.error?
52
+ state = Towel::V1alpha::ResultState::ERROR
53
+ else
54
+ state = Towel::V1alpha::ResultState::FAILURE
55
+ end
56
+
57
+ duration = nil
58
+ if !result.skipped?
59
+ duration = result.time
60
+ end
61
+
62
+ description = nil
63
+ if !result.failures.empty?
64
+ description = result.failures.first.message
65
+ end
66
+
67
+ @session.update_result(
68
+ result.klass,
69
+ result.name,
70
+ state: state,
71
+ duration: duration,
72
+ description: description
73
+ )
74
+
75
+ @stdout.context = nil
76
+ @stderr.context = nil
77
+ end
78
+
79
+ def report
80
+ $stdout = @previous_stdout
81
+ $stderr = @previous_stderr
82
+
83
+ if @cancelled
84
+ @session.cancel_invocation
85
+ else
86
+ @session.finish_invocation
87
+ end
88
+ end
89
+
90
+ private
91
+
92
+ # Clean up names from Minitest::Spec
93
+ def result_name(klass, name)
94
+ if klass.ancestors.include?(::Minitest::Spec)
95
+ name.sub(/^test_\d{4}_/, "")
96
+ else
97
+ name
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,5 @@
1
+ module Towel
2
+ module Minitest
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,41 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "towel/minitest/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "towel-minitest"
8
+ spec.version = Towel::Minitest::VERSION
9
+ spec.authors = ["Andrew Smith"]
10
+ spec.email = ["andrew@velvet.software"]
11
+
12
+ spec.summary = "Towel integration for collecting results from Minitest"
13
+ spec.description = <<END
14
+ Towel collects test results as they run, reporting them to towel.dev for easier
15
+ inspection, debugging, and sharing.
16
+ END
17
+ spec.homepage = "https://towel.dev"
18
+ spec.license = "MIT"
19
+
20
+ if spec.respond_to?(:metadata)
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://bitbucket.org/VelvetSoftware/towel-ruby"
23
+ spec.metadata["changelog_uri"] = "https://bitbucket.org/VelvetSoftware/towel-ruby/src/master/extensions/towel-minitest/CHANGELOG.md"
24
+ end
25
+
26
+ # Specify which files should be added to the gem when it is released.
27
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_dependency "minitest", "~> 5.0"
36
+ spec.add_dependency "towel", "~> 0.1"
37
+
38
+ spec.add_development_dependency "bundler", "~> 1.17"
39
+ spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "minitest", "~> 5.0"
41
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: towel-minitest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Smith
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-07-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: towel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.17'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.17'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ description: |
84
+ Towel collects test results as they run, reporting them to towel.dev for easier
85
+ inspection, debugging, and sharing.
86
+ email:
87
+ - andrew@velvet.software
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - Gemfile
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
98
+ - examples/.towel.toml
99
+ - examples/parallel_test.rb
100
+ - examples/simple_spec.rb
101
+ - examples/simple_test.rb
102
+ - lib/minitest/towel_plugin.rb
103
+ - lib/towel/minitest.rb
104
+ - lib/towel/minitest/reporter.rb
105
+ - lib/towel/minitest/version.rb
106
+ - towel-minitest.gemspec
107
+ homepage: https://towel.dev
108
+ licenses:
109
+ - MIT
110
+ metadata:
111
+ homepage_uri: https://towel.dev
112
+ source_code_uri: https://bitbucket.org/VelvetSoftware/towel-ruby
113
+ changelog_uri: https://bitbucket.org/VelvetSoftware/towel-ruby/src/master/extensions/towel-minitest/CHANGELOG.md
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubygems_version: 3.0.3
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Towel integration for collecting results from Minitest
133
+ test_files: []