activesupport-deprecation_test_helper 0.1.0.pre.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 96e1b8c154348e3c7eeab086231c932236883101667273e8e6e1fa8b3ed8de28
4
+ data.tar.gz: 65e6b88eb0e720224b48ebc0f1bf27c50253a9f1361bfd0e9b29c533bb33cf6d
5
+ SHA512:
6
+ metadata.gz: ece0f7556a64e132d9ab47c7a421315a11f959959da4f7e31625de13baa07c70f7fd8e06cc352883e827350a6f5600825e802e3b3510bb08867666846a986232
7
+ data.tar.gz: 99de410cc1ed6479dc136d2d71e99db0c4611f14293e0f36dd6f7309aa9ec69bf7b92efd08903bc045c87ad21b3478823e30db4992b314cb0191855b0aac15d0
@@ -0,0 +1,10 @@
1
+ ---
2
+ version: 1
3
+ update_configs:
4
+ - package_manager: "ruby:bundler"
5
+ directory: "/"
6
+ update_schedule: "live"
7
+ version_requirement_updates: "off"
8
+ commit_message:
9
+ prefix: "No-Jira"
10
+ include_scope: true
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /gemfiles/*.lock
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/groovy
2
+
3
+ @Library('jenkins-pipeline@v0.4.4')
4
+
5
+ def setGithubStatus(String name, String description, String status) {
6
+ gitHubStatus([
7
+ repoSlug: 'Invoca/active_support-deprecation_test_helper',
8
+ sha: env.GIT_COMMIT,
9
+ description: description,
10
+ context: name,
11
+ targetURL: env.RUN_DISPLAY_URL,
12
+ token: env.GITHUB_TOKEN,
13
+ status: status
14
+ ])
15
+ }
16
+
17
+ pipeline {
18
+ agent {
19
+ kubernetes {
20
+ defaultContainer 'ruby'
21
+ yamlFile '.jenkins/ruby_build_pod.yml'
22
+ }
23
+ }
24
+
25
+ environment { GITHUB_TOKEN = credentials('github_token') }
26
+
27
+ stages {
28
+ stage("Setup") {
29
+ steps {
30
+ setGithubStatus('clean-build', 'Running unit tests', 'pending')
31
+ sh 'bundle install'
32
+ sh 'bundle exec appraisal install'
33
+ }
34
+ }
35
+
36
+ stage("Appraisals") {
37
+ parallel {
38
+ stage("Current") {
39
+ environment { JUNIT_OUTPUT = 'spec/reports/current/rspec.xml' }
40
+ steps { sh 'bundle exec rake' }
41
+ post { always { junit JUNIT_OUTPUT } }
42
+ }
43
+
44
+ stage("Rails 4") {
45
+ environment { JUNIT_OUTPUT = 'spec/reports/rails-4/rspec.xml' }
46
+ steps { sh 'bundle exec appraisal rails-4 rake' }
47
+ post { always { junit JUNIT_OUTPUT } }
48
+ }
49
+
50
+ stage("Rails 5") {
51
+ environment { JUNIT_OUTPUT = 'spec/reports/rails-5/rspec.xml' }
52
+ steps { sh 'bundle exec appraisal rails-5 rake' }
53
+ post { always { junit JUNIT_OUTPUT } }
54
+ }
55
+
56
+ stage("Rails 6") {
57
+ environment { JUNIT_OUTPUT = 'spec/reports/rails-6/rspec.xml' }
58
+ steps { sh 'bundle exec appraisal rails-6 rake' }
59
+ post { always { junit JUNIT_OUTPUT } }
60
+ }
61
+ }
62
+ }
63
+ }
64
+
65
+ post {
66
+ success { setGithubStatus('clean-build', 'Passed all unit tests!', 'success') }
67
+ failure { setGithubStatus('clean-build', 'Failure during unit tests!', 'failure') }
68
+ }
69
+ }
@@ -0,0 +1,18 @@
1
+ ---
2
+ apiVersion: v1
3
+ kind: Pod
4
+ metadata:
5
+ labels:
6
+ jenkins/active_support-deprecation_test_helper: 'true'
7
+ namespace: jenkins
8
+ name: active_support-deprecation_test_helper
9
+ spec:
10
+ containers:
11
+ - name: ruby
12
+ image: ruby:2.6.5
13
+ tty: true
14
+ resources:
15
+ requests:
16
+ memory: "100Mi"
17
+ command:
18
+ - cat
data/.rspec ADDED
@@ -0,0 +1,5 @@
1
+ --require spec_helper
2
+ --format progress
3
+ --color
4
+ --format RspecJunitFormatter
5
+ --out <%= ENV['JUNIT_OUTPUT'] || 'spec/reports/rspec.xml' %>
@@ -0,0 +1 @@
1
+ 2.6.5
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'rails-4' do
4
+ gem 'activesupport', '~> 4.2'
5
+ end
6
+
7
+ appraise 'rails-5' do
8
+ gem 'activesupport', '~> 5.2'
9
+ end
10
+
11
+ appraise 'rails-6' do
12
+ gem 'activesupport', '~> 6.0'
13
+ end
@@ -0,0 +1,12 @@
1
+ # CHANGELOG for `activesupport-deprecation_test_helper`
2
+
3
+ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
+
5
+ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.1.0] - Unreleased
8
+ Initial release for the gem
9
+ ### Added
10
+ - Added ability to configure your tests to record and report unexpected deprecation warnings
11
+
12
+ [0.1.0]: https://github.com/Invoca/active_support-deprecation_warning_helper/tree/v0.1.0
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in active_support-deprecation_test_helper.gemspec
8
+ gemspec
9
+
10
+ gem "appraisal"
11
+ gem "pry"
12
+ gem 'pry-byebug'
13
+ gem "rake", "~> 13.0"
14
+ gem "rspec", "~> 3.0"
15
+ gem "rspec_junit_formatter", "~> 0.4"
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ activesupport-deprecation_test_helper (0.1.0.pre.1)
5
+ activesupport (>= 4.2, < 7)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (6.0.3.1)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 0.7, < 2)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ zeitwerk (~> 2.2, >= 2.2.2)
16
+ appraisal (2.3.0)
17
+ bundler
18
+ rake
19
+ thor (>= 0.14.0)
20
+ byebug (11.1.3)
21
+ coderay (1.1.3)
22
+ concurrent-ruby (1.1.6)
23
+ diff-lcs (1.3)
24
+ i18n (1.8.3)
25
+ concurrent-ruby (~> 1.0)
26
+ method_source (1.0.0)
27
+ minitest (5.14.1)
28
+ pry (0.13.1)
29
+ coderay (~> 1.1)
30
+ method_source (~> 1.0)
31
+ pry-byebug (3.9.0)
32
+ byebug (~> 11.0)
33
+ pry (~> 0.13.0)
34
+ rake (13.0.1)
35
+ rspec (3.9.0)
36
+ rspec-core (~> 3.9.0)
37
+ rspec-expectations (~> 3.9.0)
38
+ rspec-mocks (~> 3.9.0)
39
+ rspec-core (3.9.2)
40
+ rspec-support (~> 3.9.3)
41
+ rspec-expectations (3.9.2)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.9.0)
44
+ rspec-mocks (3.9.1)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.9.0)
47
+ rspec-support (3.9.3)
48
+ rspec_junit_formatter (0.4.1)
49
+ rspec-core (>= 2, < 4, != 2.12.0)
50
+ thor (1.0.1)
51
+ thread_safe (0.3.6)
52
+ tzinfo (1.2.7)
53
+ thread_safe (~> 0.1)
54
+ zeitwerk (2.3.0)
55
+
56
+ PLATFORMS
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ activesupport-deprecation_test_helper!
61
+ appraisal
62
+ pry
63
+ pry-byebug
64
+ rake (~> 13.0)
65
+ rspec (~> 3.0)
66
+ rspec_junit_formatter (~> 0.4)
67
+
68
+ BUNDLED WITH
69
+ 1.17.3
@@ -0,0 +1,79 @@
1
+ # ActiveSupport::DeprecationTestHelper
2
+
3
+ A test helper that removes `ActiveSupport::Deprecation` noise from being interlaced in your test output. Instead this gem collects
4
+ any and all deprecation warnings that occur during your tests, and succinctly reports them at the end of the test run.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'activesupport-deprecation_test_helper'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install activesupport-deprecation_test_helper
21
+
22
+ ## Usage
23
+ ### Basic Configuration
24
+ In order to capture and report all deprecation warnings at the end of the test run, use one of the
25
+ following methods for configuration.
26
+
27
+ #### Configuring for Supported Test Frameworks
28
+ Currently the following test frameworks are supported out of the box:
29
+ - Minitest (`:minitest`)
30
+ - RSpec (`:rspec`)
31
+
32
+ In order to configure you test runs in `Minitest` add the following to your `test_helper.rb`
33
+ ```ruby
34
+ require 'active_support/deprecation_test_helper'
35
+ ActiveSupport::DeprecationTestHelper.configure(:minitest)
36
+ ```
37
+
38
+ And for `RSpec` add the following to your `spec_helper.rb` after your `RSpec.configure` block:
39
+ ```ruby
40
+ require 'active_support/deprecation_test_helper'
41
+ ActiveSupport::DeprecationTestHelper.configure(:rspec)
42
+ ```
43
+
44
+ #### Configuring for Unsupported Test Frameworks
45
+ If you are using an unsupported test framework and would like to use this gem, you'll need to add the
46
+ following pieces to your test setup.
47
+
48
+ 1. Include `ActiveSupport::DeprecationTestHelper` into `ActiveSupport::Deprecation` using the following
49
+ ```ruby
50
+ require 'active_support/deprecation_test_helper'
51
+ ActiveSupport::Deprecation.include ActiveSupport::DeprecationTestHelper
52
+ ```
53
+ 2. Report all unexpected warnings at the end of the test run with
54
+ ```ruby
55
+ ActiveSupport::DeprecationTestHelper.report_unexpected_warnings
56
+ ```
57
+
58
+ ### Expected Deprecation Warnings
59
+ If you have some deprecations warnings that you're not going to resolve, and would like to omit them from the test run report, you can do the following
60
+
61
+ ```ruby
62
+ ActiveSupport::DeprecationTestHelper.allow_warning("The full deprecation warning string")
63
+ ```
64
+
65
+ Or you can use a regex if you would like to match a series of deprecation warnings
66
+
67
+ ```ruby
68
+ ActiveSupport::DeprecationTestHelper.allow_warning(/will be removed from Rails 6\.0/)
69
+ ```
70
+
71
+ ## Development
72
+
73
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
74
+
75
+ 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).
76
+
77
+ ## Contributing
78
+
79
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Invoca/active_support-deprecation_test_helper.
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
@@ -0,0 +1,33 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "active_support/deprecation_test_helper/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "activesupport-deprecation_test_helper"
8
+ spec.version = ActiveSupport::DeprecationTestHelper::VERSION
9
+ spec.authors = ["Invoca"]
10
+ spec.email = ["operations@invoca.com"]
11
+
12
+ spec.summary = ""
13
+ spec.description = ""
14
+ spec.homepage = "https://github.com/Invoca/active_support-deprecation_test_helper"
15
+
16
+ spec.metadata = {
17
+ 'allowed_push_host' => 'https://rubygems.org',
18
+ 'homepage_uri' => 'https://github.com/Invoca/active_support-deprecation_test_helper',
19
+ 'source_code_uri' => 'https://github.com/Invoca/active_support-deprecation_test_helper',
20
+ 'changelog_uri' => 'https://github.com/Invoca/active_support-deprecation_test_helper/blob/master/CHANGELOG.md'
21
+ }
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency 'activesupport', '>= 4.2', '< 7'
33
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "active_support/deprecation_test_helper"
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__)
@@ -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,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "pry"
7
+ gem "pry-byebug"
8
+ gem "rake", "~> 10.0"
9
+ gem "rspec", "~> 3.0"
10
+ gem "rspec_junit_formatter", "~> 0.4"
11
+ gem "activesupport", "~> 4.2"
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "pry"
7
+ gem "pry-byebug"
8
+ gem "rake", "~> 10.0"
9
+ gem "rspec", "~> 3.0"
10
+ gem "rspec_junit_formatter", "~> 0.4"
11
+ gem "activesupport", "~> 5.2"
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "pry"
7
+ gem "pry-byebug"
8
+ gem "rake", "~> 10.0"
9
+ gem "rspec", "~> 3.0"
10
+ gem "rspec_junit_formatter", "~> 0.4"
11
+ gem "activesupport", "~> 6.0"
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/deprecation_test_helper/version"
4
+ require "active_support/deprecation"
5
+ require "active_support/core_ext/object/inclusion"
6
+
7
+ module ActiveSupport
8
+ module DeprecationTestHelper
9
+ CONFIGURABLE_TEST_FRAMEWORKS = [:rspec, :minitest].freeze
10
+
11
+ class << self
12
+ def configure(test_framework)
13
+ test_framework.in?(CONFIGURABLE_TEST_FRAMEWORKS) or raise "Unexpected test framework encountered. Supported frameworks are #{CONFIGURABLE_TEST_FRAMEWORKS.join(' ')}"
14
+
15
+ ActiveSupport::Deprecation.include(self)
16
+
17
+ case test_framework
18
+ when :rspec
19
+ RSpec.configuration.after(:all, after_all_callback)
20
+ when :minitest
21
+ Minitest.after_run(after_all_callback)
22
+ end
23
+ end
24
+
25
+ def reset
26
+ @allowed_warnings = Set.new
27
+ @unexpected_warnings = Set.new
28
+ end
29
+
30
+ def allow_warning(message_or_regex)
31
+ unless message_or_regex.is_a?(String) || message_or_regex.is_a?(Regexp)
32
+ raise ArgumentError, "Expected message_or_regex to be a String or a Regexp but was a #{message_or_regex.class.name}"
33
+ end
34
+ allowed_warnings << message_or_regex
35
+ end
36
+
37
+ def after_all_callback
38
+ -> { unexpected_warnings.any? and warn unexpected_warnings_message }
39
+ end
40
+
41
+ def unexpected_warnings_message
42
+ <<~EOS.chomp
43
+ =====
44
+ #{(['Unexpected Deprecation Warnings Encountered'] + unexpected_warnings.to_a).join("\n ")}
45
+ =====
46
+ EOS
47
+ end
48
+
49
+ def track_warning(warning)
50
+ if warning && !expected_warning?(warning)
51
+ unexpected_warnings << warning
52
+ end
53
+ end
54
+
55
+ protected
56
+
57
+ attr_reader :unexpected_warnings, :allowed_warnings
58
+
59
+ def expected_warning?(warning)
60
+ allowed_warnings.any? { |allowed_warning| allowed_warning === warning }
61
+ end
62
+ end
63
+
64
+ self.reset
65
+
66
+ def deprecation_warning(*_args)
67
+ super.tap { |warning| ActiveSupport::DeprecationTestHelper.track_warning(warning) }
68
+ end
69
+
70
+ def behavior
71
+ [::ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:silence]]
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveSupport
4
+ module DeprecationTestHelper
5
+ VERSION = "0.1.0.pre.1"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activesupport-deprecation_test_helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre.1
5
+ platform: ruby
6
+ authors:
7
+ - Invoca
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-06-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '4.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7'
33
+ description: ''
34
+ email:
35
+ - operations@invoca.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - ".dependabot/config.yml"
41
+ - ".gitignore"
42
+ - ".jenkins/Jenkinsfile"
43
+ - ".jenkins/ruby_build_pod.yml"
44
+ - ".rspec"
45
+ - ".ruby-version"
46
+ - Appraisals
47
+ - CHANGELOG.md
48
+ - Gemfile
49
+ - Gemfile.lock
50
+ - README.md
51
+ - Rakefile
52
+ - active_support-deprecation_test_helper.gemspec
53
+ - bin/console
54
+ - bin/setup
55
+ - gemfiles/rails_4.gemfile
56
+ - gemfiles/rails_5.gemfile
57
+ - gemfiles/rails_6.gemfile
58
+ - lib/active_support/deprecation_test_helper.rb
59
+ - lib/active_support/deprecation_test_helper/version.rb
60
+ homepage: https://github.com/Invoca/active_support-deprecation_test_helper
61
+ licenses: []
62
+ metadata:
63
+ allowed_push_host: https://rubygems.org
64
+ homepage_uri: https://github.com/Invoca/active_support-deprecation_test_helper
65
+ source_code_uri: https://github.com/Invoca/active_support-deprecation_test_helper
66
+ changelog_uri: https://github.com/Invoca/active_support-deprecation_test_helper/blob/master/CHANGELOG.md
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: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">"
79
+ - !ruby/object:Gem::Version
80
+ version: 1.3.1
81
+ requirements: []
82
+ rubygems_version: 3.0.3
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: ''
86
+ test_files: []