minitest-hooks 1.5.0 → 1.5.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.
- checksums.yaml +4 -4
 - data/CHANGELOG +6 -0
 - data/MIT-LICENSE +1 -1
 - data/README.rdoc +1 -1
 - data/lib/minitest/hooks/default.rb +1 -1
 - data/lib/minitest/hooks/test.rb +3 -1
 - metadata +20 -16
 - data/Rakefile +0 -45
 - data/spec/all.rb +0 -4
 - data/spec/errors/example.rb +0 -68
 - data/spec/helper.rb +0 -6
 - data/spec/minitest_hooks_all_name_spec.rb +0 -42
 - data/spec/minitest_hooks_direct_spec.rb +0 -113
 - data/spec/minitest_hooks_errors_spec.rb +0 -32
 - data/spec/minitest_hooks_spec.rb +0 -108
 - data/spec/minitest_hooks_test.rb +0 -120
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a525a80546faf2287ec0c0b8f5423a93bf76195381aec4bb37ab04ea6a533a71
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 8e6c6bd1f68db59ad2a6c885f6aba06b38f0302c8ecda20981381fd9e6683550
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c6ba36dfb0477f1a7a15579b791ee73c6a5f3bf56157a115f7eaa14c40763e5244e2eb3e6f774fbfdc0cdbc6a7f31a8595bd95a59042889e974acb45c3210c9e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e56c3ed65969f299e59030a590a207a56519180843221a55635c6db58fd8dd5f9b0d339af7cfecfcfee10ec1272b2353349d89048df06f25f99680b49cbeaf87
         
     | 
    
        data/CHANGELOG
    CHANGED
    
    | 
         @@ -1,3 +1,9 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            === 1.5.1 (2023-07-27)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            * Do not include specs or Rakefile in the gem (jeremyevans)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            * Fix use with minitest 5.19+ by using Minitest instead of MiniTest as the constant (jeremyevans)
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
       1 
7 
     | 
    
         
             
            === 1.5.0 (2018-05-21)
         
     | 
| 
       2 
8 
     | 
    
         | 
| 
       3 
9 
     | 
    
         
             
            * Fix use with minitest 5.11+ by using Minitest::Result in such cases (GUI) (#15)
         
     | 
    
        data/MIT-LICENSE
    CHANGED
    
    
    
        data/README.rdoc
    CHANGED
    
    | 
         @@ -29,7 +29,7 @@ First, you need to require the library. 
     | 
|
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
            You can set the default for some specs to be <tt>Minitest::HooksSpec</tt>:
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
               
     | 
| 
      
 32 
     | 
    
         
            +
              Minitest::Spec.register_spec_type(/something/, Minitest::HooksSpec)
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
            Alternatively, you can include <tt>Minitest::Hooks</tt> in a specific spec class:
         
     | 
| 
       35 
35 
     | 
    
         | 
    
        data/lib/minitest/hooks/test.rb
    CHANGED
    
    | 
         @@ -135,12 +135,14 @@ module Minitest::Hooks::ClassMethods 
     | 
|
| 
       135 
135 
     | 
    
         
             
              private
         
     | 
| 
       136 
136 
     | 
    
         | 
| 
       137 
137 
     | 
    
         
             
              def _record_minitest_hooks_error(reporter, instance)
         
     | 
| 
       138 
     | 
    
         
            -
                # In  
     | 
| 
      
 138 
     | 
    
         
            +
                # In Minitest 5.11+, use Minitest::Result for wrapping the object to send
         
     | 
| 
       139 
139 
     | 
    
         
             
                # to the reporter.
         
     | 
| 
       140 
140 
     | 
    
         
             
                if(defined?(Minitest::Result))
         
     | 
| 
       141 
141 
     | 
    
         
             
                  result = Minitest::Result.from(instance)
         
     | 
| 
      
 142 
     | 
    
         
            +
                # :nocov:
         
     | 
| 
       142 
143 
     | 
    
         
             
                else
         
     | 
| 
       143 
144 
     | 
    
         
             
                  result = instance
         
     | 
| 
      
 145 
     | 
    
         
            +
                # :nocov:
         
     | 
| 
       144 
146 
     | 
    
         
             
                end
         
     | 
| 
       145 
147 
     | 
    
         
             
                reporter.record result
         
     | 
| 
       146 
148 
     | 
    
         
             
              end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: minitest-hooks
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.5. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.5.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Jeremy Evans
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-07-27 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: minitest
         
     | 
| 
         @@ -66,6 +66,20 @@ dependencies: 
     | 
|
| 
       66 
66 
     | 
    
         
             
                - - ">="
         
     | 
| 
       67 
67 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       68 
68 
     | 
    
         
             
                    version: '0'
         
     | 
| 
      
 69 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 70 
     | 
    
         
            +
              name: minitest-global_expectations
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 73 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 74 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 75 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 76 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 77 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 78 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 79 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 80 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 81 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 82 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       69 
83 
     | 
    
         
             
            description: |
         
     | 
| 
       70 
84 
     | 
    
         
             
              minitest-hooks adds around and before_all/after_all/around_all hooks for Minitest.
         
     | 
| 
       71 
85 
     | 
    
         
             
              This allows you do things like run each suite of specs inside a database transaction,
         
     | 
| 
         @@ -82,23 +96,14 @@ files: 
     | 
|
| 
       82 
96 
     | 
    
         
             
            - CHANGELOG
         
     | 
| 
       83 
97 
     | 
    
         
             
            - MIT-LICENSE
         
     | 
| 
       84 
98 
     | 
    
         
             
            - README.rdoc
         
     | 
| 
       85 
     | 
    
         
            -
            - Rakefile
         
     | 
| 
       86 
99 
     | 
    
         
             
            - lib/minitest/hooks.rb
         
     | 
| 
       87 
100 
     | 
    
         
             
            - lib/minitest/hooks/default.rb
         
     | 
| 
       88 
101 
     | 
    
         
             
            - lib/minitest/hooks/test.rb
         
     | 
| 
       89 
     | 
    
         
            -
            - spec/all.rb
         
     | 
| 
       90 
     | 
    
         
            -
            - spec/errors/example.rb
         
     | 
| 
       91 
     | 
    
         
            -
            - spec/helper.rb
         
     | 
| 
       92 
     | 
    
         
            -
            - spec/minitest_hooks_all_name_spec.rb
         
     | 
| 
       93 
     | 
    
         
            -
            - spec/minitest_hooks_direct_spec.rb
         
     | 
| 
       94 
     | 
    
         
            -
            - spec/minitest_hooks_errors_spec.rb
         
     | 
| 
       95 
     | 
    
         
            -
            - spec/minitest_hooks_spec.rb
         
     | 
| 
       96 
     | 
    
         
            -
            - spec/minitest_hooks_test.rb
         
     | 
| 
       97 
102 
     | 
    
         
             
            homepage: http://github.com/jeremyevans/minitest-hooks
         
     | 
| 
       98 
103 
     | 
    
         
             
            licenses:
         
     | 
| 
       99 
104 
     | 
    
         
             
            - MIT
         
     | 
| 
       100 
105 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       101 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 106 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       102 
107 
     | 
    
         
             
            rdoc_options:
         
     | 
| 
       103 
108 
     | 
    
         
             
            - "--quiet"
         
     | 
| 
       104 
109 
     | 
    
         
             
            - "--line-numbers"
         
     | 
| 
         @@ -120,9 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       120 
125 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       121 
126 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       122 
127 
     | 
    
         
             
            requirements: []
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
            signing_key: 
         
     | 
| 
      
 128 
     | 
    
         
            +
            rubygems_version: 3.4.10
         
     | 
| 
      
 129 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       126 
130 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       127 
131 
     | 
    
         
             
            summary: Around and before_all/after_all/around_all hooks for Minitest
         
     | 
| 
       128 
132 
     | 
    
         
             
            test_files: []
         
     | 
    
        data/Rakefile
    DELETED
    
    | 
         @@ -1,45 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "rake"
         
     | 
| 
       2 
     | 
    
         
            -
            require "rake/clean"
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            CLEAN.include ["minitest-hooks-*.gem", "rdoc", "coverage"]
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            desc "Build minitest-hooks gem"
         
     | 
| 
       7 
     | 
    
         
            -
            task :package=>[:clean] do |p|
         
     | 
| 
       8 
     | 
    
         
            -
              sh %{#{FileUtils::RUBY} -S gem build minitest-hooks.gemspec}
         
     | 
| 
       9 
     | 
    
         
            -
            end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            ### Specs
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            desc "Run specs"
         
     | 
| 
       14 
     | 
    
         
            -
            task :spec do
         
     | 
| 
       15 
     | 
    
         
            -
              sh %{#{FileUtils::RUBY} spec/all.rb}
         
     | 
| 
       16 
     | 
    
         
            -
            end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
            task :default=>:spec
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            ### RDoc
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
            RDOC_DEFAULT_OPTS = ["--quiet", "--line-numbers", "--inline-source", '--title', 'minitest-hooks: around and before_all/after_all/around_all hooks for Minitest']
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
            begin
         
     | 
| 
       25 
     | 
    
         
            -
              gem 'hanna-nouveau'
         
     | 
| 
       26 
     | 
    
         
            -
              RDOC_DEFAULT_OPTS.concat(['-f', 'hanna'])
         
     | 
| 
       27 
     | 
    
         
            -
            rescue Gem::LoadError
         
     | 
| 
       28 
     | 
    
         
            -
            end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
            rdoc_task_class = begin
         
     | 
| 
       31 
     | 
    
         
            -
              require "rdoc/task"
         
     | 
| 
       32 
     | 
    
         
            -
              RDoc::Task
         
     | 
| 
       33 
     | 
    
         
            -
            rescue LoadError
         
     | 
| 
       34 
     | 
    
         
            -
              require "rake/rdoctask"
         
     | 
| 
       35 
     | 
    
         
            -
              Rake::RDocTask
         
     | 
| 
       36 
     | 
    
         
            -
            end
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
            RDOC_OPTS = RDOC_DEFAULT_OPTS + ['--main', 'README.rdoc']
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
            rdoc_task_class.new do |rdoc|
         
     | 
| 
       41 
     | 
    
         
            -
              rdoc.rdoc_dir = "rdoc"
         
     | 
| 
       42 
     | 
    
         
            -
              rdoc.options += RDOC_OPTS
         
     | 
| 
       43 
     | 
    
         
            -
              rdoc.rdoc_files.add %w"README.rdoc CHANGELOG MIT-LICENSE lib/**/*.rb"
         
     | 
| 
       44 
     | 
    
         
            -
            end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
    
        data/spec/all.rb
    DELETED
    
    
    
        data/spec/errors/example.rb
    DELETED
    
    | 
         @@ -1,68 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require './spec/helper'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'minitest/hooks/default'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            error = ENV['MINITEST_HOOKS_ERRORS']
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            module Minitest
         
     | 
| 
       7 
     | 
    
         
            -
              def self.plugin_result_inspector_reporter_init(options)
         
     | 
| 
       8 
     | 
    
         
            -
                self.reporter << ResultInspectorReporter.new(options[:io], options)
         
     | 
| 
       9 
     | 
    
         
            -
              end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              class ResultInspectorReporter < SummaryReporter
         
     | 
| 
       12 
     | 
    
         
            -
                def report
         
     | 
| 
       13 
     | 
    
         
            -
                  results.each do |result|
         
     | 
| 
       14 
     | 
    
         
            -
                    io.puts "result to_s: #{result.to_s.inspect}"
         
     | 
| 
       15 
     | 
    
         
            -
                    # For MiniTest 5.11+, we expect Minitest::Result objects.
         
     | 
| 
       16 
     | 
    
         
            -
                    if defined?(Minitest::Result)
         
     | 
| 
       17 
     | 
    
         
            -
                      io.puts "result source_location: #{result.source_location.inspect}"
         
     | 
| 
       18 
     | 
    
         
            -
                    else
         
     | 
| 
       19 
     | 
    
         
            -
                      # For older versions of Minitest, extract source_location in a
         
     | 
| 
       20 
     | 
    
         
            -
                      # similar fashion to how some third party reporters expected to be
         
     | 
| 
       21 
     | 
    
         
            -
                      # able to:
         
     | 
| 
       22 
     | 
    
         
            -
                      # https://github.com/circleci/minitest-ci/blob/8b72b0f32f154d91b53d63d1d0a8a8fb3b01d726/lib/minitest/ci_plugin.rb#L139
         
     | 
| 
       23 
     | 
    
         
            -
                      io.puts "result source_location: #{result.method(result.name).source_location.inspect}"
         
     | 
| 
       24 
     | 
    
         
            -
                    end
         
     | 
| 
       25 
     | 
    
         
            -
                  end
         
     | 
| 
       26 
     | 
    
         
            -
                end
         
     | 
| 
       27 
     | 
    
         
            -
              end
         
     | 
| 
       28 
     | 
    
         
            -
            end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
            Minitest.extensions << "result_inspector_reporter"
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
            describe 'Minitest::Hooks error handling' do
         
     | 
| 
       33 
     | 
    
         
            -
              before(:all) do
         
     | 
| 
       34 
     | 
    
         
            -
                raise if error == 'before-all'
         
     | 
| 
       35 
     | 
    
         
            -
              end
         
     | 
| 
       36 
     | 
    
         
            -
              before do
         
     | 
| 
       37 
     | 
    
         
            -
                raise if error == 'before'
         
     | 
| 
       38 
     | 
    
         
            -
              end
         
     | 
| 
       39 
     | 
    
         
            -
              after do
         
     | 
| 
       40 
     | 
    
         
            -
                raise if error == 'after'
         
     | 
| 
       41 
     | 
    
         
            -
              end
         
     | 
| 
       42 
     | 
    
         
            -
              after(:all) do
         
     | 
| 
       43 
     | 
    
         
            -
                raise if error == 'after-all'
         
     | 
| 
       44 
     | 
    
         
            -
              end
         
     | 
| 
       45 
     | 
    
         
            -
              around do |&block|
         
     | 
| 
       46 
     | 
    
         
            -
                raise if error == 'around-before'
         
     | 
| 
       47 
     | 
    
         
            -
                super(&block)
         
     | 
| 
       48 
     | 
    
         
            -
                raise if error == 'around-after'
         
     | 
| 
       49 
     | 
    
         
            -
              end
         
     | 
| 
       50 
     | 
    
         
            -
              around(:all) do |&block|
         
     | 
| 
       51 
     | 
    
         
            -
                raise if error == 'around-all-before'
         
     | 
| 
       52 
     | 
    
         
            -
                super(&block)
         
     | 
| 
       53 
     | 
    
         
            -
                case error
         
     | 
| 
       54 
     | 
    
         
            -
                when 'before-all'
         
     | 
| 
       55 
     | 
    
         
            -
                  name.must_equal 'before_all'
         
     | 
| 
       56 
     | 
    
         
            -
                when 'after-all'
         
     | 
| 
       57 
     | 
    
         
            -
                  name.must_equal 'after_all'
         
     | 
| 
       58 
     | 
    
         
            -
                else
         
     | 
| 
       59 
     | 
    
         
            -
                  name.must_equal 'around_all'
         
     | 
| 
       60 
     | 
    
         
            -
                end
         
     | 
| 
       61 
     | 
    
         
            -
                raise if error == 'around-all-after'
         
     | 
| 
       62 
     | 
    
         
            -
              end
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
              3.times do |i|
         
     | 
| 
       65 
     | 
    
         
            -
                it "should work try #{i}" do
         
     | 
| 
       66 
     | 
    
         
            -
                end
         
     | 
| 
       67 
     | 
    
         
            -
              end
         
     | 
| 
       68 
     | 
    
         
            -
            end
         
     | 
    
        data/spec/helper.rb
    DELETED
    
    
| 
         @@ -1,42 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require './spec/helper'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'minitest/hooks/default'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            describe 'Minitest::Hooks error handling' do
         
     | 
| 
       5 
     | 
    
         
            -
              before(:all) do
         
     | 
| 
       6 
     | 
    
         
            -
                name.must_equal 'before_all'
         
     | 
| 
       7 
     | 
    
         
            -
              end
         
     | 
| 
       8 
     | 
    
         
            -
              after(:all) do
         
     | 
| 
       9 
     | 
    
         
            -
                name.must_equal 'after_all'
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
              around(:all) do |&block|
         
     | 
| 
       12 
     | 
    
         
            -
                name.must_equal 'around_all'
         
     | 
| 
       13 
     | 
    
         
            -
                super(&block)
         
     | 
| 
       14 
     | 
    
         
            -
                name.must_equal 'around_all'
         
     | 
| 
       15 
     | 
    
         
            -
              end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
              3.times do |i|
         
     | 
| 
       18 
     | 
    
         
            -
                it "should work try #{i}" do
         
     | 
| 
       19 
     | 
    
         
            -
                end
         
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
       21 
     | 
    
         
            -
            end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
            class MinitestHooksNameTest < Minitest::Test
         
     | 
| 
       24 
     | 
    
         
            -
              include Minitest::Hooks
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
              def before_all
         
     | 
| 
       27 
     | 
    
         
            -
                assert_equal 'before_all', name
         
     | 
| 
       28 
     | 
    
         
            -
              end
         
     | 
| 
       29 
     | 
    
         
            -
              def after_all
         
     | 
| 
       30 
     | 
    
         
            -
                assert_equal 'after_all', name
         
     | 
| 
       31 
     | 
    
         
            -
              end
         
     | 
| 
       32 
     | 
    
         
            -
              def around_all
         
     | 
| 
       33 
     | 
    
         
            -
                assert_equal 'around_all', name
         
     | 
| 
       34 
     | 
    
         
            -
                super
         
     | 
| 
       35 
     | 
    
         
            -
                assert_equal 'around_all', name
         
     | 
| 
       36 
     | 
    
         
            -
              end
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
              3.times do |i|
         
     | 
| 
       39 
     | 
    
         
            -
                define_method "test_should_work_try_#{i}" do
         
     | 
| 
       40 
     | 
    
         
            -
                end
         
     | 
| 
       41 
     | 
    
         
            -
              end
         
     | 
| 
       42 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,113 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require './spec/helper'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'minitest/hooks'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            NDB = Sequel.connect(DATABASE_URL)
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            MiniTest::Spec.register_spec_type(/no_default/, Minitest::Spec)
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            describe 'Minitest::Hooks with transactions/savepoints no_default' do
         
     | 
| 
       9 
     | 
    
         
            -
              include Minitest::Hooks
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              before(:all) do
         
     | 
| 
       12 
     | 
    
         
            -
                @ds_ba = @ds_aa
         
     | 
| 
       13 
     | 
    
         
            -
                @ds_ba.count.must_equal 1 + @i
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
              before do
         
     | 
| 
       16 
     | 
    
         
            -
                @ds_be = @ds_ae
         
     | 
| 
       17 
     | 
    
         
            -
                @ds_be.count.must_equal 2 + @i * 2
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
              after do
         
     | 
| 
       20 
     | 
    
         
            -
                @ds_be.count.must_equal 2 + @i * 2
         
     | 
| 
       21 
     | 
    
         
            -
              end
         
     | 
| 
       22 
     | 
    
         
            -
              after(:all) do
         
     | 
| 
       23 
     | 
    
         
            -
                @ds_ba.count.must_equal 1 + @i
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
              around do |&block|
         
     | 
| 
       26 
     | 
    
         
            -
                @ds_aa.count.must_equal 1 + @i
         
     | 
| 
       27 
     | 
    
         
            -
                NDB.transaction(:rollback=>:always, :savepoint=>true, :auto_savepoint=>true) do
         
     | 
| 
       28 
     | 
    
         
            -
                  @ds_ae = @ds_aa
         
     | 
| 
       29 
     | 
    
         
            -
                  @ds_ae.insert(1)
         
     | 
| 
       30 
     | 
    
         
            -
                  super(&block)
         
     | 
| 
       31 
     | 
    
         
            -
                end
         
     | 
| 
       32 
     | 
    
         
            -
                @ds_aa.count.must_equal 1 + @i
         
     | 
| 
       33 
     | 
    
         
            -
              end
         
     | 
| 
       34 
     | 
    
         
            -
              around(:all) do |&block|
         
     | 
| 
       35 
     | 
    
         
            -
                @i ||= 0
         
     | 
| 
       36 
     | 
    
         
            -
                NDB.transaction(:rollback=>:always) do
         
     | 
| 
       37 
     | 
    
         
            -
                  NDB.create_table(:a){Integer :a}
         
     | 
| 
       38 
     | 
    
         
            -
                  @ds_aa = NDB[:a]
         
     | 
| 
       39 
     | 
    
         
            -
                  @ds_aa.count.must_equal 0
         
     | 
| 
       40 
     | 
    
         
            -
                  @ds_aa.insert(1)
         
     | 
| 
       41 
     | 
    
         
            -
                  super(&block)
         
     | 
| 
       42 
     | 
    
         
            -
                end
         
     | 
| 
       43 
     | 
    
         
            -
                NDB.table_exists?(:a).must_equal false
         
     | 
| 
       44 
     | 
    
         
            -
              end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
              3.times do |i|
         
     | 
| 
       47 
     | 
    
         
            -
                it "should work try #{i}" do
         
     | 
| 
       48 
     | 
    
         
            -
                  @ds_aa.count.must_equal 2
         
     | 
| 
       49 
     | 
    
         
            -
                  @ds_ae.count.must_equal 2
         
     | 
| 
       50 
     | 
    
         
            -
                  @ds_ba.count.must_equal 2
         
     | 
| 
       51 
     | 
    
         
            -
                  @ds_be.count.must_equal 2
         
     | 
| 
       52 
     | 
    
         
            -
                end
         
     | 
| 
       53 
     | 
    
         
            -
              end
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
              describe "in nested describe" do
         
     | 
| 
       56 
     | 
    
         
            -
                before(:all) do
         
     | 
| 
       57 
     | 
    
         
            -
                  @ds_ba3 = @ds_ba
         
     | 
| 
       58 
     | 
    
         
            -
                  @ds_ba2 = @ds_aa2
         
     | 
| 
       59 
     | 
    
         
            -
                  @ds_ba2.count.must_equal 2
         
     | 
| 
       60 
     | 
    
         
            -
                end
         
     | 
| 
       61 
     | 
    
         
            -
                before do
         
     | 
| 
       62 
     | 
    
         
            -
                  @ds_be3 = @ds_be
         
     | 
| 
       63 
     | 
    
         
            -
                  @ds_be2 = @ds_ae2
         
     | 
| 
       64 
     | 
    
         
            -
                  @ds_be2.count.must_equal 4
         
     | 
| 
       65 
     | 
    
         
            -
                end
         
     | 
| 
       66 
     | 
    
         
            -
                after do
         
     | 
| 
       67 
     | 
    
         
            -
                  @ds_be2.count.must_equal 4
         
     | 
| 
       68 
     | 
    
         
            -
                end
         
     | 
| 
       69 
     | 
    
         
            -
                after(:all) do
         
     | 
| 
       70 
     | 
    
         
            -
                  @ds_ba2.count.must_equal 2
         
     | 
| 
       71 
     | 
    
         
            -
                end
         
     | 
| 
       72 
     | 
    
         
            -
                around do |&block|
         
     | 
| 
       73 
     | 
    
         
            -
                  @ds_aa.count.must_equal 2
         
     | 
| 
       74 
     | 
    
         
            -
                  super() do
         
     | 
| 
       75 
     | 
    
         
            -
                    @ds_aa.count.must_equal 3
         
     | 
| 
       76 
     | 
    
         
            -
                    @ds_ae3 = @ds_ae
         
     | 
| 
       77 
     | 
    
         
            -
                    @ds_ae2 = @ds_aa2
         
     | 
| 
       78 
     | 
    
         
            -
                    @ds_ae2.insert(1)
         
     | 
| 
       79 
     | 
    
         
            -
                    block.call
         
     | 
| 
       80 
     | 
    
         
            -
                    @ds_aa.count.must_equal 4
         
     | 
| 
       81 
     | 
    
         
            -
                  end
         
     | 
| 
       82 
     | 
    
         
            -
                  @ds_aa.count.must_equal 2
         
     | 
| 
       83 
     | 
    
         
            -
                end
         
     | 
| 
       84 
     | 
    
         
            -
                around(:all) do |&block|
         
     | 
| 
       85 
     | 
    
         
            -
                  @i ||= 1
         
     | 
| 
       86 
     | 
    
         
            -
                  super() do
         
     | 
| 
       87 
     | 
    
         
            -
                    @ds_aa.count.must_equal 1
         
     | 
| 
       88 
     | 
    
         
            -
                    @ds_aa2 = @ds_aa
         
     | 
| 
       89 
     | 
    
         
            -
                    @ds_aa2.insert(1)
         
     | 
| 
       90 
     | 
    
         
            -
                    block.call
         
     | 
| 
       91 
     | 
    
         
            -
                    @ds_aa.count.must_equal 2
         
     | 
| 
       92 
     | 
    
         
            -
                  end
         
     | 
| 
       93 
     | 
    
         
            -
                  NDB.table_exists?(:a).must_equal false
         
     | 
| 
       94 
     | 
    
         
            -
                end
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
                3.times do |i|
         
     | 
| 
       97 
     | 
    
         
            -
                  it "should work try #{i}" do
         
     | 
| 
       98 
     | 
    
         
            -
                    @ds_aa.count.must_equal 4
         
     | 
| 
       99 
     | 
    
         
            -
                    @ds_ae.count.must_equal 4
         
     | 
| 
       100 
     | 
    
         
            -
                    @ds_ba.count.must_equal 4
         
     | 
| 
       101 
     | 
    
         
            -
                    @ds_be.count.must_equal 4
         
     | 
| 
       102 
     | 
    
         
            -
                    @ds_aa2.count.must_equal 4
         
     | 
| 
       103 
     | 
    
         
            -
                    @ds_ae2.count.must_equal 4
         
     | 
| 
       104 
     | 
    
         
            -
                    @ds_ba2.count.must_equal 4
         
     | 
| 
       105 
     | 
    
         
            -
                    @ds_be2.count.must_equal 4
         
     | 
| 
       106 
     | 
    
         
            -
                    @ds_ae3.count.must_equal 4
         
     | 
| 
       107 
     | 
    
         
            -
                    @ds_ba3.count.must_equal 4
         
     | 
| 
       108 
     | 
    
         
            -
                    @ds_be3.count.must_equal 4
         
     | 
| 
       109 
     | 
    
         
            -
                  end
         
     | 
| 
       110 
     | 
    
         
            -
                end
         
     | 
| 
       111 
     | 
    
         
            -
              end
         
     | 
| 
       112 
     | 
    
         
            -
            end
         
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
         @@ -1,32 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require './spec/helper'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'minitest/hooks/default'
         
     | 
| 
       3 
     | 
    
         
            -
            require 'open3'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            RUBY = ENV['RUBY'] || 'ruby'
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            describe 'Minitest::Hooks error handling' do
         
     | 
| 
       8 
     | 
    
         
            -
              def self.run_test(desc, runs, errors)
         
     | 
| 
       9 
     | 
    
         
            -
                it "should handle errors in #{desc}" do
         
     | 
| 
       10 
     | 
    
         
            -
                  ENV['MINITEST_HOOKS_ERRORS'] = desc
         
     | 
| 
       11 
     | 
    
         
            -
                  Open3.popen3(RUBY, "spec/errors/example.rb", "-v") do  |_, o, e, w|
         
     | 
| 
       12 
     | 
    
         
            -
                    output = o.read
         
     | 
| 
       13 
     | 
    
         
            -
                    output.must_match /#{runs} runs, 0 assertions, 0 failures, #{errors} errors, 0 skips/
         
     | 
| 
       14 
     | 
    
         
            -
                    output.must_match /result to_s: ".*?Minitest::Hooks error handling#\w+.*?spec\/errors\/example\.rb:\d+/
         
     | 
| 
       15 
     | 
    
         
            -
                    output.must_match /result source_location: \["(unknown|.+?\.rb)", -?\d+\]/
         
     | 
| 
       16 
     | 
    
         
            -
                    output = e.read
         
     | 
| 
       17 
     | 
    
         
            -
                    output.gsub!(/Picked up _JAVA_OPTIONS: [^\n]+\n/, '')
         
     | 
| 
       18 
     | 
    
         
            -
                    output.must_equal ''
         
     | 
| 
       19 
     | 
    
         
            -
                    w.value.exitstatus.wont_equal 0 if w
         
     | 
| 
       20 
     | 
    
         
            -
                  end
         
     | 
| 
       21 
     | 
    
         
            -
                end
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
              run_test "before-all", 1, 1
         
     | 
| 
       25 
     | 
    
         
            -
              run_test "before", 3, 3
         
     | 
| 
       26 
     | 
    
         
            -
              run_test "after", 3, 3
         
     | 
| 
       27 
     | 
    
         
            -
              run_test "after-all", 4, 1
         
     | 
| 
       28 
     | 
    
         
            -
              run_test "around-before", 1, 1
         
     | 
| 
       29 
     | 
    
         
            -
              run_test "around-after", 1, 1
         
     | 
| 
       30 
     | 
    
         
            -
              run_test "around-all-before", 1, 1
         
     | 
| 
       31 
     | 
    
         
            -
              run_test "around-all-after", 4, 1
         
     | 
| 
       32 
     | 
    
         
            -
            end
         
     | 
    
        data/spec/minitest_hooks_spec.rb
    DELETED
    
    | 
         @@ -1,108 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require './spec/helper'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'minitest/hooks/default'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            DB = Sequel.connect(DATABASE_URL)
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            describe 'Minitest::Hooks with transactions/savepoints' do
         
     | 
| 
       7 
     | 
    
         
            -
              before(:all) do
         
     | 
| 
       8 
     | 
    
         
            -
                @ds_ba = @ds_aa
         
     | 
| 
       9 
     | 
    
         
            -
                @ds_ba.count.must_equal 1 + @i
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
              before do
         
     | 
| 
       12 
     | 
    
         
            -
                @ds_be = @ds_ae
         
     | 
| 
       13 
     | 
    
         
            -
                @ds_be.count.must_equal 2 + @i * 2
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
              after do
         
     | 
| 
       16 
     | 
    
         
            -
                @ds_be.count.must_equal 2 + @i * 2
         
     | 
| 
       17 
     | 
    
         
            -
              end
         
     | 
| 
       18 
     | 
    
         
            -
              after(:all) do
         
     | 
| 
       19 
     | 
    
         
            -
                @ds_ba.count.must_equal 1 + @i
         
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
       21 
     | 
    
         
            -
              around do |&block|
         
     | 
| 
       22 
     | 
    
         
            -
                @ds_aa.count.must_equal 1 + @i
         
     | 
| 
       23 
     | 
    
         
            -
                DB.transaction(:rollback=>:always, :savepoint=>true, :auto_savepoint=>true) do
         
     | 
| 
       24 
     | 
    
         
            -
                  @ds_ae = @ds_aa
         
     | 
| 
       25 
     | 
    
         
            -
                  @ds_ae.insert(1)
         
     | 
| 
       26 
     | 
    
         
            -
                  super(&block)
         
     | 
| 
       27 
     | 
    
         
            -
                end
         
     | 
| 
       28 
     | 
    
         
            -
                @ds_aa.count.must_equal 1 + @i
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
              around(:all) do |&block|
         
     | 
| 
       31 
     | 
    
         
            -
                @i ||= 0
         
     | 
| 
       32 
     | 
    
         
            -
                DB.transaction(:rollback=>:always) do
         
     | 
| 
       33 
     | 
    
         
            -
                  DB.create_table(:a){Integer :a}
         
     | 
| 
       34 
     | 
    
         
            -
                  @ds_aa = DB[:a]
         
     | 
| 
       35 
     | 
    
         
            -
                  @ds_aa.count.must_equal 0
         
     | 
| 
       36 
     | 
    
         
            -
                  @ds_aa.insert(1)
         
     | 
| 
       37 
     | 
    
         
            -
                  super(&block)
         
     | 
| 
       38 
     | 
    
         
            -
                end
         
     | 
| 
       39 
     | 
    
         
            -
                DB.table_exists?(:a).must_equal false
         
     | 
| 
       40 
     | 
    
         
            -
              end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
              3.times do |i|
         
     | 
| 
       43 
     | 
    
         
            -
                it "should work try #{i}" do
         
     | 
| 
       44 
     | 
    
         
            -
                  @ds_aa.count.must_equal 2
         
     | 
| 
       45 
     | 
    
         
            -
                  @ds_ae.count.must_equal 2
         
     | 
| 
       46 
     | 
    
         
            -
                  @ds_ba.count.must_equal 2
         
     | 
| 
       47 
     | 
    
         
            -
                  @ds_be.count.must_equal 2
         
     | 
| 
       48 
     | 
    
         
            -
                end
         
     | 
| 
       49 
     | 
    
         
            -
              end
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
              describe "in nested describe" do
         
     | 
| 
       52 
     | 
    
         
            -
                before(:all) do
         
     | 
| 
       53 
     | 
    
         
            -
                  @ds_ba3 = @ds_ba
         
     | 
| 
       54 
     | 
    
         
            -
                  @ds_ba2 = @ds_aa2
         
     | 
| 
       55 
     | 
    
         
            -
                  @ds_ba2.count.must_equal 2
         
     | 
| 
       56 
     | 
    
         
            -
                end
         
     | 
| 
       57 
     | 
    
         
            -
                before do
         
     | 
| 
       58 
     | 
    
         
            -
                  @ds_be3 = @ds_be
         
     | 
| 
       59 
     | 
    
         
            -
                  @ds_be2 = @ds_ae2
         
     | 
| 
       60 
     | 
    
         
            -
                  @ds_be2.count.must_equal 4
         
     | 
| 
       61 
     | 
    
         
            -
                end
         
     | 
| 
       62 
     | 
    
         
            -
                after do
         
     | 
| 
       63 
     | 
    
         
            -
                  @ds_be2.count.must_equal 4
         
     | 
| 
       64 
     | 
    
         
            -
                end
         
     | 
| 
       65 
     | 
    
         
            -
                after(:all) do
         
     | 
| 
       66 
     | 
    
         
            -
                  @ds_ba2.count.must_equal 2
         
     | 
| 
       67 
     | 
    
         
            -
                end
         
     | 
| 
       68 
     | 
    
         
            -
                around do |&block|
         
     | 
| 
       69 
     | 
    
         
            -
                  @ds_aa.count.must_equal 2
         
     | 
| 
       70 
     | 
    
         
            -
                  super() do
         
     | 
| 
       71 
     | 
    
         
            -
                    @ds_aa.count.must_equal 3
         
     | 
| 
       72 
     | 
    
         
            -
                    @ds_ae3 = @ds_ae
         
     | 
| 
       73 
     | 
    
         
            -
                    @ds_ae2 = @ds_aa2
         
     | 
| 
       74 
     | 
    
         
            -
                    @ds_ae2.insert(1)
         
     | 
| 
       75 
     | 
    
         
            -
                    block.call
         
     | 
| 
       76 
     | 
    
         
            -
                    @ds_aa.count.must_equal 4
         
     | 
| 
       77 
     | 
    
         
            -
                  end
         
     | 
| 
       78 
     | 
    
         
            -
                  @ds_aa.count.must_equal 2
         
     | 
| 
       79 
     | 
    
         
            -
                end
         
     | 
| 
       80 
     | 
    
         
            -
                around(:all) do |&block|
         
     | 
| 
       81 
     | 
    
         
            -
                  @i ||= 1
         
     | 
| 
       82 
     | 
    
         
            -
                  super() do
         
     | 
| 
       83 
     | 
    
         
            -
                    @ds_aa.count.must_equal 1
         
     | 
| 
       84 
     | 
    
         
            -
                    @ds_aa2 = @ds_aa
         
     | 
| 
       85 
     | 
    
         
            -
                    @ds_aa2.insert(1)
         
     | 
| 
       86 
     | 
    
         
            -
                    block.call
         
     | 
| 
       87 
     | 
    
         
            -
                    @ds_aa.count.must_equal 2
         
     | 
| 
       88 
     | 
    
         
            -
                  end
         
     | 
| 
       89 
     | 
    
         
            -
                  DB.table_exists?(:a).must_equal false
         
     | 
| 
       90 
     | 
    
         
            -
                end
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
                3.times do |i|
         
     | 
| 
       93 
     | 
    
         
            -
                  it "should work try #{i}" do
         
     | 
| 
       94 
     | 
    
         
            -
                    @ds_aa.count.must_equal 4
         
     | 
| 
       95 
     | 
    
         
            -
                    @ds_ae.count.must_equal 4
         
     | 
| 
       96 
     | 
    
         
            -
                    @ds_ba.count.must_equal 4
         
     | 
| 
       97 
     | 
    
         
            -
                    @ds_be.count.must_equal 4
         
     | 
| 
       98 
     | 
    
         
            -
                    @ds_aa2.count.must_equal 4
         
     | 
| 
       99 
     | 
    
         
            -
                    @ds_ae2.count.must_equal 4
         
     | 
| 
       100 
     | 
    
         
            -
                    @ds_ba2.count.must_equal 4
         
     | 
| 
       101 
     | 
    
         
            -
                    @ds_be2.count.must_equal 4
         
     | 
| 
       102 
     | 
    
         
            -
                    @ds_ae3.count.must_equal 4
         
     | 
| 
       103 
     | 
    
         
            -
                    @ds_ba3.count.must_equal 4
         
     | 
| 
       104 
     | 
    
         
            -
                    @ds_be3.count.must_equal 4
         
     | 
| 
       105 
     | 
    
         
            -
                  end
         
     | 
| 
       106 
     | 
    
         
            -
                end
         
     | 
| 
       107 
     | 
    
         
            -
              end
         
     | 
| 
       108 
     | 
    
         
            -
            end
         
     | 
    
        data/spec/minitest_hooks_test.rb
    DELETED
    
    | 
         @@ -1,120 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require './spec/helper'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'minitest/hooks/test'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            class MyTest < Minitest::Test
         
     | 
| 
       5 
     | 
    
         
            -
              include Minitest::Hooks
         
     | 
| 
       6 
     | 
    
         
            -
            end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            class TestMinitestHooks < MyTest
         
     | 
| 
       9 
     | 
    
         
            -
              DB = Sequel.connect(DATABASE_URL)
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              def before_all
         
     | 
| 
       12 
     | 
    
         
            -
                super
         
     | 
| 
       13 
     | 
    
         
            -
                @ds_ba = @ds_aa
         
     | 
| 
       14 
     | 
    
         
            -
                assert_equal @ds_ba.count, 1 + @i
         
     | 
| 
       15 
     | 
    
         
            -
              end
         
     | 
| 
       16 
     | 
    
         
            -
              def setup
         
     | 
| 
       17 
     | 
    
         
            -
                super
         
     | 
| 
       18 
     | 
    
         
            -
                @ds_be = @ds_ae
         
     | 
| 
       19 
     | 
    
         
            -
                assert_equal @ds_be.count, 2 + @i * 2
         
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
       21 
     | 
    
         
            -
              def teardown
         
     | 
| 
       22 
     | 
    
         
            -
                assert_equal @ds_be.count, 2 + @i * 2
         
     | 
| 
       23 
     | 
    
         
            -
                super
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
              def after_all
         
     | 
| 
       26 
     | 
    
         
            -
                assert_equal @ds_ba.count, 1 + @i
         
     | 
| 
       27 
     | 
    
         
            -
                super
         
     | 
| 
       28 
     | 
    
         
            -
              end
         
     | 
| 
       29 
     | 
    
         
            -
              def around
         
     | 
| 
       30 
     | 
    
         
            -
                assert_equal @ds_aa.count, 1 + @i
         
     | 
| 
       31 
     | 
    
         
            -
                DB.transaction(:rollback=>:always, :savepoint=>true, :auto_savepoint=>true) do
         
     | 
| 
       32 
     | 
    
         
            -
                  @ds_ae = @ds_aa
         
     | 
| 
       33 
     | 
    
         
            -
                  @ds_ae.insert(1)
         
     | 
| 
       34 
     | 
    
         
            -
                  super
         
     | 
| 
       35 
     | 
    
         
            -
                end
         
     | 
| 
       36 
     | 
    
         
            -
                assert_equal @ds_aa.count, 1 + @i
         
     | 
| 
       37 
     | 
    
         
            -
              end
         
     | 
| 
       38 
     | 
    
         
            -
              def around_all
         
     | 
| 
       39 
     | 
    
         
            -
                @i ||= 0
         
     | 
| 
       40 
     | 
    
         
            -
                DB.transaction(:rollback=>:always) do
         
     | 
| 
       41 
     | 
    
         
            -
                  DB.create_table(:a){Integer :a}
         
     | 
| 
       42 
     | 
    
         
            -
                  @ds_aa = DB[:a]
         
     | 
| 
       43 
     | 
    
         
            -
                  assert_equal @ds_aa.count, 0
         
     | 
| 
       44 
     | 
    
         
            -
                  @ds_aa.insert(1)
         
     | 
| 
       45 
     | 
    
         
            -
                  super
         
     | 
| 
       46 
     | 
    
         
            -
                end
         
     | 
| 
       47 
     | 
    
         
            -
                assert_equal DB.table_exists?(:a), false
         
     | 
| 
       48 
     | 
    
         
            -
              end
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
              3.times do |i|
         
     | 
| 
       51 
     | 
    
         
            -
                define_method(:"test_should_work_#{i}") do
         
     | 
| 
       52 
     | 
    
         
            -
                  assert_equal @ds_aa.count, 2
         
     | 
| 
       53 
     | 
    
         
            -
                  assert_equal @ds_ae.count, 2
         
     | 
| 
       54 
     | 
    
         
            -
                  assert_equal @ds_ba.count, 2
         
     | 
| 
       55 
     | 
    
         
            -
                  assert_equal @ds_be.count, 2
         
     | 
| 
       56 
     | 
    
         
            -
                end
         
     | 
| 
       57 
     | 
    
         
            -
              end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
              class TestMinitestHooks2 < self
         
     | 
| 
       60 
     | 
    
         
            -
                def before_all
         
     | 
| 
       61 
     | 
    
         
            -
                  super
         
     | 
| 
       62 
     | 
    
         
            -
                  @ds_ba3 = @ds_ba
         
     | 
| 
       63 
     | 
    
         
            -
                  @ds_ba2 = @ds_aa2
         
     | 
| 
       64 
     | 
    
         
            -
                  assert_equal @ds_ba2.count, 2
         
     | 
| 
       65 
     | 
    
         
            -
                end
         
     | 
| 
       66 
     | 
    
         
            -
                def setup
         
     | 
| 
       67 
     | 
    
         
            -
                  super
         
     | 
| 
       68 
     | 
    
         
            -
                  @ds_be3 = @ds_be
         
     | 
| 
       69 
     | 
    
         
            -
                  @ds_be2 = @ds_ae2
         
     | 
| 
       70 
     | 
    
         
            -
                  assert_equal @ds_be2.count, 4
         
     | 
| 
       71 
     | 
    
         
            -
                end
         
     | 
| 
       72 
     | 
    
         
            -
                def teardown
         
     | 
| 
       73 
     | 
    
         
            -
                  assert_equal @ds_be2.count, 4
         
     | 
| 
       74 
     | 
    
         
            -
                  super
         
     | 
| 
       75 
     | 
    
         
            -
                end
         
     | 
| 
       76 
     | 
    
         
            -
                def after_all
         
     | 
| 
       77 
     | 
    
         
            -
                  assert_equal @ds_ba2.count, 2
         
     | 
| 
       78 
     | 
    
         
            -
                  super
         
     | 
| 
       79 
     | 
    
         
            -
                end
         
     | 
| 
       80 
     | 
    
         
            -
                def around
         
     | 
| 
       81 
     | 
    
         
            -
                  assert_equal @ds_aa.count, 2
         
     | 
| 
       82 
     | 
    
         
            -
                  super do
         
     | 
| 
       83 
     | 
    
         
            -
                    assert_equal @ds_aa.count, 3
         
     | 
| 
       84 
     | 
    
         
            -
                    @ds_ae3 = @ds_ae
         
     | 
| 
       85 
     | 
    
         
            -
                    @ds_ae2 = @ds_aa2
         
     | 
| 
       86 
     | 
    
         
            -
                    @ds_ae2.insert(1)
         
     | 
| 
       87 
     | 
    
         
            -
                    yield
         
     | 
| 
       88 
     | 
    
         
            -
                    assert_equal @ds_aa.count, 4
         
     | 
| 
       89 
     | 
    
         
            -
                  end
         
     | 
| 
       90 
     | 
    
         
            -
                  assert_equal @ds_aa.count, 2
         
     | 
| 
       91 
     | 
    
         
            -
                end
         
     | 
| 
       92 
     | 
    
         
            -
                def around_all
         
     | 
| 
       93 
     | 
    
         
            -
                  @i ||= 1
         
     | 
| 
       94 
     | 
    
         
            -
                  super do
         
     | 
| 
       95 
     | 
    
         
            -
                    assert_equal @ds_aa.count, 1
         
     | 
| 
       96 
     | 
    
         
            -
                    @ds_aa2 = @ds_aa
         
     | 
| 
       97 
     | 
    
         
            -
                    @ds_aa2.insert(1)
         
     | 
| 
       98 
     | 
    
         
            -
                    yield
         
     | 
| 
       99 
     | 
    
         
            -
                    assert_equal @ds_aa.count, 2
         
     | 
| 
       100 
     | 
    
         
            -
                  end
         
     | 
| 
       101 
     | 
    
         
            -
                  assert_equal DB.table_exists?(:a), false
         
     | 
| 
       102 
     | 
    
         
            -
                end
         
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
                3.times do |i|
         
     | 
| 
       105 
     | 
    
         
            -
                  define_method(:"test_should_work_#{i}") do
         
     | 
| 
       106 
     | 
    
         
            -
                    assert_equal @ds_aa.count, 4
         
     | 
| 
       107 
     | 
    
         
            -
                    assert_equal @ds_ae.count, 4
         
     | 
| 
       108 
     | 
    
         
            -
                    assert_equal @ds_ba.count, 4
         
     | 
| 
       109 
     | 
    
         
            -
                    assert_equal @ds_be.count, 4
         
     | 
| 
       110 
     | 
    
         
            -
                    assert_equal @ds_aa2.count, 4
         
     | 
| 
       111 
     | 
    
         
            -
                    assert_equal @ds_ae2.count, 4
         
     | 
| 
       112 
     | 
    
         
            -
                    assert_equal @ds_ba2.count, 4
         
     | 
| 
       113 
     | 
    
         
            -
                    assert_equal @ds_be2.count, 4
         
     | 
| 
       114 
     | 
    
         
            -
                    assert_equal @ds_ae3.count, 4
         
     | 
| 
       115 
     | 
    
         
            -
                    assert_equal @ds_ba3.count, 4
         
     | 
| 
       116 
     | 
    
         
            -
                    assert_equal @ds_be3.count, 4
         
     | 
| 
       117 
     | 
    
         
            -
                  end
         
     | 
| 
       118 
     | 
    
         
            -
                end
         
     | 
| 
       119 
     | 
    
         
            -
              end
         
     | 
| 
       120 
     | 
    
         
            -
            end
         
     |