minitest-around-0.6.0/0000755000004100000410000000000015125730516014674 5ustar www-datawww-dataminitest-around-0.6.0/minitest-around.gemspec0000644000004100000410000000265715125730516021375 0ustar www-datawww-data######################################################### # This file has been automatically generated by gem2tgz # ######################################################### # -*- encoding: utf-8 -*- # stub: minitest-around 0.6.0 ruby lib Gem::Specification.new do |s| s.name = "minitest-around".freeze s.version = "0.6.0".freeze s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.require_paths = ["lib".freeze] s.authors = ["Peter Leitzen".freeze] s.date = "2025-12-28" s.description = "Alternative for setup/teardown dance.".freeze s.email = ["peter-minitest-around@suschlik.de".freeze] s.files = ["LICENSE".freeze, "README.md".freeze, "lib/minitest/around.rb".freeze, "lib/minitest/around/spec.rb".freeze, "lib/minitest/around/unit.rb".freeze, "lib/minitest/around/version.rb".freeze] s.homepage = "https://github.com/splattael/minitest-around".freeze s.licenses = ["MIT".freeze] s.rubygems_version = "3.4.10".freeze s.summary = "Around block for minitest.".freeze s.specification_version = 4 s.add_development_dependency(%q.freeze, [">= 0".freeze]) s.add_development_dependency(%q.freeze, [">= 0".freeze]) s.add_development_dependency(%q.freeze, [">= 0".freeze]) s.add_runtime_dependency(%q.freeze, ["> 5.0".freeze, "< 7.0".freeze]) s.add_development_dependency(%q.freeze, [">= 0".freeze]) end minitest-around-0.6.0/lib/0000755000004100000410000000000015125730516015442 5ustar www-datawww-dataminitest-around-0.6.0/lib/minitest/0000755000004100000410000000000015125730516017276 5ustar www-datawww-dataminitest-around-0.6.0/lib/minitest/around.rb0000644000004100000410000000033115125730516021110 0ustar www-datawww-datarequire 'minitest/around/version' require 'minitest/around/spec' require 'minitest/around/unit' module Minitest module Around # Ugly hack for cucumber/mt5 combo! VERSION = MinitestAround::VERSION end end minitest-around-0.6.0/lib/minitest/around/0000755000004100000410000000000015125730516020566 5ustar www-datawww-dataminitest-around-0.6.0/lib/minitest/around/unit.rb0000644000004100000410000000040015125730516022064 0ustar www-datawww-datarequire 'minitest/test' require 'minitest/around/version' Minitest::Test.prepend(Module.new do def run(*args) if defined?(around) result = nil around { result = super(*args) } result else super(*args) end end end) minitest-around-0.6.0/lib/minitest/around/spec.rb0000644000004100000410000000214415125730516022046 0ustar www-datawww-datarequire 'minitest/spec' require 'minitest/around/version' require 'minitest/around/unit' Minitest::Spec::DSL.class_eval do # - resume to call first part # - execute test # - resume fiber to execute last part def around(*args, &block) raise ArgumentError, "only :each, :example, or no argument are supported" if args - [:each, :example] != [] fib = nil before do fib = Fiber.new do |context, resume| begin context.instance_exec(resume, &block) rescue Object fib = :failed raise end end fib.resume(self, lambda { Fiber.yield }) end after { fib.resume if fib && fib != :failed } end # Minitest does not support multiple before/after blocks remove_method :before def before(type=nil, &block) include Module.new { define_method(:setup) { super(); instance_exec(&block) } } end remove_method :after def after(type=nil, &block) include(Module.new do define_method(:teardown) do begin instance_exec(&block) ensure super() end end end) end end minitest-around-0.6.0/lib/minitest/around/version.rb0000644000004100000410000000005615125730516022601 0ustar www-datawww-datamodule MinitestAround VERSION = '0.6.0' end minitest-around-0.6.0/LICENSE0000644000004100000410000000213315125730516015700 0ustar www-datawww-dataCopyright (c) 2012 Peter Suschlik Copyright (c) 2018 Peter Leitzen (Suschlik) MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. minitest-around-0.6.0/README.md0000644000004100000410000000504415125730516016156 0ustar www-datawww-data[github]: https://github.com/splattael/minitest-around [doc]: http://rubydoc.info/github/splattael/minitest-around/master/file/README.md [gem]: https://rubygems.org/gems/minitest-around [travis]: https://travis-ci.org/splattael/minitest-around # minitest-around [![Travis](https://img.shields.io/travis/splattael/minitest-around.svg?branch=master)][travis] [![Gem Version](https://img.shields.io/gem/v/minitest-around.svg)][gem] [Gem][gem] | [Source][github] Around block for minitest 5.X and later. Alternative for setup/teardown dance. ## Installation ```Bash gem install minitest-around ``` ## Usage ### Unit tests ```Ruby require 'minitest/autorun' require 'minitest/around/unit' require 'thread' class MutexTest < Minitest::Test def around(&block) Mutex.new.synchronize(&block) end def test_synchronized # ... end end ``` ### Spec ```Ruby require 'minitest/autorun' require 'minitest/around/spec' require 'tmpdir' describe "inside new directory" do around do |test| Dir.mktmpdir do |dir| @dir = dir Dir.chdir(dir) do test.call end end end it "is in new directory" do assert_equal @dir, Dir.pwd.sub("/private/var/", "/var/") end end ``` ## Multiple before/after blocks Minitest-around also enables the use of multiple before/after blocks, which normally don't work in minitest. ## Caveats - Test bodies won't be run if you don't test.call inside +around+. - around runs inside a Fiber, so use `Thread.get_thread_local` / `set_thread_local` instead of `Thread.current.[]` ### Minitest 5.X and later `minitest-around` currently supports only `minitest` 5.X and later. Please see the [mt4](https://github.com/splattael/minitest-around/tree/mt4) branch for `minitest` 4.7.X support. ## License [MIT License](http://www.opensource.org/licenses/mit-license.php) ## Authors * [Peter Leitzen](https://github.com/splattael) ## [Contributors](https://github.com/splattael/minitest-around/graphs/contributors) * [Michael Grosser](https://github.com/grosser) * [Hendra Uzia](https://github.com/hendrauzia) * [Rick Martínez](https://github.com/rickmzp) * [Philip Nelson](https://github.com/pnelson) ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Added some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request ## Test ```Bash bundle exec rake test ``` ## Release ```Bash bundle exec rake bump:{patch|minor|major} bundle exec rake release ```