pax_global_header00006660000000000000000000000064126513170710014515gustar00rootroot0000000000000052 comment=ae4305714e95638b974f19fd8b2e7778b8dbc1d5 ruby-minitest-hooks-1.4.0/000077500000000000000000000000001265131707100154535ustar00rootroot00000000000000ruby-minitest-hooks-1.4.0/CHANGELOG000066400000000000000000000011621265131707100166650ustar00rootroot00000000000000=== 1.4.0 (2015-11-17) * Handle errors in before(:all)/after(:all)/around(:all) hooks (jeremyevans) === 1.3.0 (2015-08-17) * Don't run before_all/after_all/around_all hooks for classes with no tests/specs when using minitest >= 5.8.0 (jeremyevans) (#7) === 1.2.0 (2015-07-02) * Add minitest/hooks/test file, which doesn't require minitest/spec (janko-m) (#9, #10) === 1.1.0 (2015-05-11) * Remove unnecessary module inclusion (jeremyevans) * Add block-based around and around(:all) support (jeremyevans) === 1.0.1 (2015-04-26) * Fix homepage in gemspec (jeremyevans) === 1.0.0 (2015-04-26) * Initial Public Release ruby-minitest-hooks-1.4.0/MIT-LICENSE000066400000000000000000000020211265131707100171020ustar00rootroot00000000000000Copyright (c) 2015 Jeremy Evans 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 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. ruby-minitest-hooks-1.4.0/README.rdoc000066400000000000000000000131231265131707100172610ustar00rootroot00000000000000= minitest-hooks minitest-hooks adds around and before_all/after_all/around_all hooks for Minitest. This allows you do things like run each suite of specs inside a database transaction, running each spec inside its own savepoint inside that transaction, which can significantly speed up testing for specs that share expensive database setup code. = Installation gem install minitest-hooks = Source Code Source code is available on GitHub at https://github.com/jeremyevans/minitest-hooks = Usage == In Specs (Minitest::Spec) === For all specs require 'minitest/hooks/default' === For some specs First, you need to require the library. require 'minitest/hooks' You can set the default for some specs to be Minitest::HooksSpec: MiniTest::Spec.register_spec_type(/something/, Minitest::HooksSpec) Alternatively, you can include Minitest::Hooks in a specific spec class: describe 'something' do include Minitest::Hooks end === before_all Hooks To run code before any specs in the suite are executed, pass +:all+ to +before+: describe 'something' do before(:all) do DB[:table].insert(:column=>1) end end === after_all Hooks To run code after all specs in the suite are executed, pass +:all+ to +after+: describe 'something' do after(:all) do DB[:table].delete end end === around Hooks To run code around each spec in a suite, call +around+ with a block, and have the block call +super+: describe 'something' do around do |&block| DB.transaction(:rollback=>:always, :savepoint=>true, :auto_savepoint=>true) do super(&block) end end end === around_all Hooks To run code around all specs in a suite, call around(:all) with a block, and have the block call +super+: describe 'something' do around(:all) do |&block| DB.transaction(:rollback=>:always) do super(&block) end end end === In Tests (Minitest::Test) Create a subclass of Minitest::Test and include Minitest::Hooks, and have your test classes subclass from that subclass: require 'minitest/hooks/test' class MyTest < Minitest::Test include Minitest::Hooks end class TestSuite1 < MyTest end You can just define the +before_all+, +after_all+, +around+, and +around_all+ methods, instead of using the spec DSL. Make sure to call super when overriding the methods. class TestSuite1 < MyTest def before_all super DB[:table].insert(:column=>1) end def after_all DB[:table].delete super end def around DB.transaction(:rollback=>:always, :savepoint=>true, :auto_savepoint=>true) do super end end def around_all DB.transaction(:rollback=>:always) do super end end end = Behavior == Hooks Just Define Methods Just like the before/after hooks supported by minitest, all hooks supported by minitest-hooks just define methods on the spec class, there is no magic ("It's just ruby"). This has a couple of effects: 1. You cannot define multiple hooks of the same type in the same class. This is because you cannot have multiple methods with the same name in the same class. If you define a second hook of the same type in the same class, it will overwrite the previous hook, just like ruby's behavior if you define a method twice in the same class. 2. For around and around(:all) hooks, you should always call super. If you want a subclass around hook to run inside a superclass around hook, you need to call super in the subclass hook and run the code inside the block you pass to super, then call block.call somewhere inside the super block: describe "superclass" do around do |&block| some_outer_method do super(&block) end end describe "subclass" do around do |&block| super do some_inner_method do block.call end end end end end You do not need to call super for before(:all) or after(:all) hooks. Both before(:all) and after(:all) implicitly call super for you in the method they define, mirroring minitest's behavior for before and after hooks. 3. All hooks share state/instance variables. So any instance variables you set in before(:all), around(:all), or around are shared with the examples. Note that after(:all) will only see instance variables set in before(:all) or around(:all), it will not see instance variables set inside examples. == All Spec Classes are Independent The way minitest works, all spec classes are indepedent of other spec classes in terms of how and when they are executed, even spec classes that are subclasses of other spec classes. This means that for every spec class, the before(:all), after(:all), and around(:all) hooks for that class will be executed, even if they were defined in the spec's superclass and not in the spec class itself. So if you have a spec superclass that uses before(:all), and a spec subclass for that superclass, the before(:all) in the spec superclass will be run twice, once in the context of an instance of the superclass, before executing the superclass's specs, and once in the context of an instance of the subclass, before executing the subclass's specs. == Order of Operations For each spec class, the around(:all) hooks are run first. Both before(:all) and after(:all) run inside around(:all). For each spec inside the spec the spec class, around will be called, and before and after for each spec will be run inside around. = License MIT = Author Jeremy Evans ruby-minitest-hooks-1.4.0/Rakefile000066400000000000000000000020461265131707100171220ustar00rootroot00000000000000require "rake" require "rake/clean" CLEAN.include ["minitest-hooks-*.gem", "rdoc", "coverage"] desc "Build minitest-hooks gem" task :package=>[:clean] do |p| sh %{#{FileUtils::RUBY} -S gem build minitest-hooks.gemspec} end ### Specs desc "Run specs" task :spec do ENV['RUBY'] = FileUtils::RUBY ENV['RUBYLIB'] = "lib:#{ENV['RUBYLIB']}" sh %{#{FileUtils::RUBY} -I lib -e 'ARGV.each{|f| require f}' ./spec/*.rb} end task :default=>:spec ### RDoc RDOC_DEFAULT_OPTS = ["--quiet", "--line-numbers", "--inline-source", '--title', 'minitest-hooks: around and before_all/after_all/around_all hooks for Minitest'] begin gem 'hanna-nouveau' RDOC_DEFAULT_OPTS.concat(['-f', 'hanna']) rescue Gem::LoadError end rdoc_task_class = begin require "rdoc/task" RDoc::Task rescue LoadError require "rake/rdoctask" Rake::RDocTask end RDOC_OPTS = RDOC_DEFAULT_OPTS + ['--main', 'README.rdoc'] rdoc_task_class.new do |rdoc| rdoc.rdoc_dir = "rdoc" rdoc.options += RDOC_OPTS rdoc.rdoc_files.add %w"README.rdoc CHANGELOG MIT-LICENSE lib/**/*.rb" end ruby-minitest-hooks-1.4.0/lib/000077500000000000000000000000001265131707100162215ustar00rootroot00000000000000ruby-minitest-hooks-1.4.0/lib/minitest/000077500000000000000000000000001265131707100200555ustar00rootroot00000000000000ruby-minitest-hooks-1.4.0/lib/minitest/hooks.rb000066400000000000000000000002601265131707100215230ustar00rootroot00000000000000require 'minitest/hooks/test' require 'minitest/spec' # Spec subclass that includes the hook methods. class Minitest::HooksSpec < Minitest::Spec include Minitest::Hooks end ruby-minitest-hooks-1.4.0/lib/minitest/hooks/000077500000000000000000000000001265131707100212005ustar00rootroot00000000000000ruby-minitest-hooks-1.4.0/lib/minitest/hooks/default.rb000066400000000000000000000001251265131707100231470ustar00rootroot00000000000000require 'minitest/hooks' MiniTest::Spec.register_spec_type(//, Minitest::HooksSpec) ruby-minitest-hooks-1.4.0/lib/minitest/hooks/test.rb000066400000000000000000000061231265131707100225060ustar00rootroot00000000000000require 'minitest' # Add support for around and before_all/after_all/around_all hooks to # minitest spec classes. module Minitest::Hooks # Add the class methods to the class. Also, include an additional # module in the class that before(:all) and after(:all) methods # work on a class that directly includes this module. def self.included(mod) super mod.instance_exec do extend(Minitest::Hooks::ClassMethods) end end # Empty method, necessary so that super calls in spec subclasses work. def before_all end # Empty method, necessary so that super calls in spec subclasses work. def after_all end # Method that just yields, so that super calls in spec subclasses work. def around_all yield end # Method that just yields, so that super calls in spec subclasses work. def around yield end # Run around hook inside, since time_it is run around every spec. def time_it super do around do yield end end end end module Minitest::Hooks::ClassMethods # Object used to get an empty new instance, as new by default will return # a dup of the singleton instance. NEW = Object.new.freeze # Unless name is NEW, return a dup singleton instance. def new(name) if name.equal?(NEW) return super end instance = @instance.dup instance.name = name instance.failures = [] instance end # When running the specs in the class, first create a singleton instance, the singleton is # used to implement around_all/before_all/after_all hooks, and each spec will run as a # dup of the singleton instance. def with_info_handler(reporter, &block) @instance = new(NEW) inside = false begin @instance.around_all do inside = true begin @instance.capture_exceptions do @instance.before_all end if @instance.failure failed = true reporter.record @instance else super(reporter, &block) end ensure @instance.capture_exceptions do @instance.after_all end if @instance.failure && !failed failed = true reporter.record @instance end inside = false end end rescue => e @instance.capture_exceptions do raise e end reporter.record @instance end end # If type is :all, set the around_all hook, otherwise set the around hook. def around(type=nil, &block) meth = type == :all ? :around_all : :around define_method(meth, &block) end # If type is :all, set the before_all hook instead of the before hook. def before(type=nil, &block) if type == :all define_method(:before_all) do super() instance_exec(&block) end nil else super end end # If type is :all, set the after_all hook instead of the after hook. def after(type=nil, &block) if type == :all define_method(:after_all) do instance_exec(&block) super() end nil else super end end end ruby-minitest-hooks-1.4.0/metadata.yml000066400000000000000000000062311265131707100177600ustar00rootroot00000000000000--- !ruby/object:Gem::Specification name: minitest-hooks version: !ruby/object:Gem::Version version: 1.4.0 platform: ruby authors: - Jeremy Evans autorequire: bindir: bin cert_chain: [] date: 2015-11-17 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: minitest requirement: !ruby/object:Gem::Requirement requirements: - - ">" - !ruby/object:Gem::Version version: '5' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">" - !ruby/object:Gem::Version version: '5' - !ruby/object:Gem::Dependency name: sequel requirement: !ruby/object:Gem::Requirement requirements: - - ">" - !ruby/object:Gem::Version version: '4' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">" - !ruby/object:Gem::Version version: '4' - !ruby/object:Gem::Dependency name: sqlite3 requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' description: | minitest-hooks adds around and before_all/after_all/around_all hooks for Minitest. This allows you do things like run each suite of specs inside a database transaction, running each spec inside its own savepoint inside that transaction, which can significantly speed up testing for specs that share expensive database setup code. email: code@jeremyevans.net executables: [] extensions: [] extra_rdoc_files: - README.rdoc - CHANGELOG - MIT-LICENSE files: - CHANGELOG - MIT-LICENSE - README.rdoc - Rakefile - lib/minitest/hooks.rb - lib/minitest/hooks/default.rb - lib/minitest/hooks/test.rb - spec/errors/example.rb - spec/helper.rb - spec/minitest_hooks_direct_spec.rb - spec/minitest_hooks_errors_spec.rb - spec/minitest_hooks_spec.rb - spec/minitest_hooks_test.rb homepage: http://github.com/jeremyevans/minitest-hooks licenses: - MIT metadata: {} post_install_message: rdoc_options: - "--quiet" - "--line-numbers" - "--inline-source" - "--title" - 'minitest-hooks: around and before_all/after_all/around_all hooks for Minitest' - "--main" - README.rdoc require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.4.5.1 signing_key: specification_version: 4 summary: Around and before_all/after_all/around_all hooks for Minitest test_files: [] ruby-minitest-hooks-1.4.0/spec/000077500000000000000000000000001265131707100164055ustar00rootroot00000000000000ruby-minitest-hooks-1.4.0/spec/errors/000077500000000000000000000000001265131707100177215ustar00rootroot00000000000000ruby-minitest-hooks-1.4.0/spec/errors/example.rb000066400000000000000000000012441265131707100217020ustar00rootroot00000000000000require './spec/helper' require 'minitest/hooks/default' error = ENV['MINITEST_HOOKS_ERRORS'] describe 'Minitest::Hooks error handling' do before(:all) do raise if error == 'before-all' end before do raise if error == 'before' end after do raise if error == 'after' end after(:all) do raise if error == 'after-all' end around do |&block| raise if error == 'around-before' super(&block) raise if error == 'around-after' end around(:all) do |&block| raise if error == 'around-all-before' super(&block) raise if error == 'around-all-after' end 3.times do |i| it "should work try #{i}" do end end end ruby-minitest-hooks-1.4.0/spec/helper.rb000066400000000000000000000001161265131707100202070ustar00rootroot00000000000000require 'rubygems' require 'sequel' gem 'minitest' require 'minitest/autorun' ruby-minitest-hooks-1.4.0/spec/minitest_hooks_direct_spec.rb000066400000000000000000000051141265131707100243360ustar00rootroot00000000000000require './spec/helper' require 'minitest/hooks' NDB = Sequel.connect(ENV['DATABASE_URL'] || 'sqlite:/') MiniTest::Spec.register_spec_type(/no_default/, Minitest::Spec) describe 'Minitest::Hooks with transactions/savepoints no_default' do include Minitest::Hooks before(:all) do @ds_ba = @ds_aa @ds_ba.count.must_equal 1 + @i end before do @ds_be = @ds_ae @ds_be.count.must_equal 2 + @i * 2 end after do @ds_be.count.must_equal 2 + @i * 2 end after(:all) do @ds_ba.count.must_equal 1 + @i end around do |&block| @ds_aa.count.must_equal 1 + @i NDB.transaction(:rollback=>:always, :savepoint=>true, :auto_savepoint=>true) do @ds_ae = @ds_aa @ds_ae.insert(1) super(&block) end @ds_aa.count.must_equal 1 + @i end around(:all) do |&block| @i ||= 0 NDB.transaction(:rollback=>:always) do NDB.create_table(:a){Integer :a} @ds_aa = NDB[:a] @ds_aa.count.must_equal 0 @ds_aa.insert(1) super(&block) end NDB.table_exists?(:a).must_equal false end 3.times do |i| it "should work try #{i}" do @ds_aa.count.must_equal 2 @ds_ae.count.must_equal 2 @ds_ba.count.must_equal 2 @ds_be.count.must_equal 2 end end describe "in nested describe" do before(:all) do @ds_ba3 = @ds_ba @ds_ba2 = @ds_aa2 @ds_ba2.count.must_equal 2 end before do @ds_be3 = @ds_be @ds_be2 = @ds_ae2 @ds_be2.count.must_equal 4 end after do @ds_be2.count.must_equal 4 end after(:all) do @ds_ba2.count.must_equal 2 end around do |&block| @ds_aa.count.must_equal 2 super() do @ds_aa.count.must_equal 3 @ds_ae3 = @ds_ae @ds_ae2 = @ds_aa2 @ds_ae2.insert(1) block.call @ds_aa.count.must_equal 4 end @ds_aa.count.must_equal 2 end around(:all) do |&block| @i ||= 1 super() do @ds_aa.count.must_equal 1 @ds_aa2 = @ds_aa @ds_aa2.insert(1) block.call @ds_aa.count.must_equal 2 end NDB.table_exists?(:a).must_equal false end 3.times do |i| it "should work try #{i}" do @ds_aa.count.must_equal 4 @ds_ae.count.must_equal 4 @ds_ba.count.must_equal 4 @ds_be.count.must_equal 4 @ds_aa2.count.must_equal 4 @ds_ae2.count.must_equal 4 @ds_ba2.count.must_equal 4 @ds_be2.count.must_equal 4 @ds_ae3.count.must_equal 4 @ds_ba3.count.must_equal 4 @ds_be3.count.must_equal 4 end end end end ruby-minitest-hooks-1.4.0/spec/minitest_hooks_errors_spec.rb000066400000000000000000000014241265131707100244000ustar00rootroot00000000000000require './spec/helper' require 'minitest/hooks/default' require 'open3' RUBY = ENV['RUBY'] || 'ruby' describe 'Minitest::Hooks error handling' do def self.run_test(desc, runs, errors) it "should handle errors in #{desc}" do ENV['MINITEST_HOOKS_ERRORS'] = desc Open3.popen3(RUBY, "spec/errors/example.rb") do |_, o, e, w| o.read.must_match /#{runs} runs, 0 assertions, 0 failures, #{errors} errors, 0 skips/ e.read.must_equal '' w.value.exitstatus.wont_equal 0 if w end end end run_test "before-all", 1, 1 run_test "before", 3, 3 run_test "after", 3, 3 run_test "after-all", 4, 1 run_test "around-before", 1, 1 run_test "around-after", 1, 1 run_test "around-all-before", 1, 1 run_test "around-all-after", 4, 1 end ruby-minitest-hooks-1.4.0/spec/minitest_hooks_spec.rb000066400000000000000000000047451265131707100230150ustar00rootroot00000000000000require './spec/helper' require 'minitest/hooks/default' DB = Sequel.connect(ENV['DATABASE_URL'] || 'sqlite:/') describe 'Minitest::Hooks with transactions/savepoints' do before(:all) do @ds_ba = @ds_aa @ds_ba.count.must_equal 1 + @i end before do @ds_be = @ds_ae @ds_be.count.must_equal 2 + @i * 2 end after do @ds_be.count.must_equal 2 + @i * 2 end after(:all) do @ds_ba.count.must_equal 1 + @i end around do |&block| @ds_aa.count.must_equal 1 + @i DB.transaction(:rollback=>:always, :savepoint=>true, :auto_savepoint=>true) do @ds_ae = @ds_aa @ds_ae.insert(1) super(&block) end @ds_aa.count.must_equal 1 + @i end around(:all) do |&block| @i ||= 0 DB.transaction(:rollback=>:always) do DB.create_table(:a){Integer :a} @ds_aa = DB[:a] @ds_aa.count.must_equal 0 @ds_aa.insert(1) super(&block) end DB.table_exists?(:a).must_equal false end 3.times do |i| it "should work try #{i}" do @ds_aa.count.must_equal 2 @ds_ae.count.must_equal 2 @ds_ba.count.must_equal 2 @ds_be.count.must_equal 2 end end describe "in nested describe" do before(:all) do @ds_ba3 = @ds_ba @ds_ba2 = @ds_aa2 @ds_ba2.count.must_equal 2 end before do @ds_be3 = @ds_be @ds_be2 = @ds_ae2 @ds_be2.count.must_equal 4 end after do @ds_be2.count.must_equal 4 end after(:all) do @ds_ba2.count.must_equal 2 end around do |&block| @ds_aa.count.must_equal 2 super() do @ds_aa.count.must_equal 3 @ds_ae3 = @ds_ae @ds_ae2 = @ds_aa2 @ds_ae2.insert(1) block.call @ds_aa.count.must_equal 4 end @ds_aa.count.must_equal 2 end around(:all) do |&block| @i ||= 1 super() do @ds_aa.count.must_equal 1 @ds_aa2 = @ds_aa @ds_aa2.insert(1) block.call @ds_aa.count.must_equal 2 end DB.table_exists?(:a).must_equal false end 3.times do |i| it "should work try #{i}" do @ds_aa.count.must_equal 4 @ds_ae.count.must_equal 4 @ds_ba.count.must_equal 4 @ds_be.count.must_equal 4 @ds_aa2.count.must_equal 4 @ds_ae2.count.must_equal 4 @ds_ba2.count.must_equal 4 @ds_be2.count.must_equal 4 @ds_ae3.count.must_equal 4 @ds_ba3.count.must_equal 4 @ds_be3.count.must_equal 4 end end end end ruby-minitest-hooks-1.4.0/spec/minitest_hooks_test.rb000066400000000000000000000052421265131707100230330ustar00rootroot00000000000000require './spec/helper' require 'minitest/hooks/test' class MyTest < Minitest::Test include Minitest::Hooks end class TestMinitestHooks < MyTest DB = Sequel.connect(ENV['DATABASE_URL'] || 'sqlite:/') def before_all super @ds_ba = @ds_aa assert_equal @ds_ba.count, 1 + @i end def setup super @ds_be = @ds_ae assert_equal @ds_be.count, 2 + @i * 2 end def teardown assert_equal @ds_be.count, 2 + @i * 2 super end def after_all assert_equal @ds_ba.count, 1 + @i super end def around assert_equal @ds_aa.count, 1 + @i DB.transaction(:rollback=>:always, :savepoint=>true, :auto_savepoint=>true) do @ds_ae = @ds_aa @ds_ae.insert(1) super end assert_equal @ds_aa.count, 1 + @i end def around_all @i ||= 0 DB.transaction(:rollback=>:always) do DB.create_table(:a){Integer :a} @ds_aa = DB[:a] assert_equal @ds_aa.count, 0 @ds_aa.insert(1) super end assert_equal DB.table_exists?(:a), false end 3.times do |i| define_method(:"test_should_work_#{i}") do assert_equal @ds_aa.count, 2 assert_equal @ds_ae.count, 2 assert_equal @ds_ba.count, 2 assert_equal @ds_be.count, 2 end end class TestMinitestHooks2 < self def before_all super @ds_ba3 = @ds_ba @ds_ba2 = @ds_aa2 assert_equal @ds_ba2.count, 2 end def setup super @ds_be3 = @ds_be @ds_be2 = @ds_ae2 assert_equal @ds_be2.count, 4 end def teardown assert_equal @ds_be2.count, 4 super end def after_all assert_equal @ds_ba2.count, 2 super end def around assert_equal @ds_aa.count, 2 super do assert_equal @ds_aa.count, 3 @ds_ae3 = @ds_ae @ds_ae2 = @ds_aa2 @ds_ae2.insert(1) yield assert_equal @ds_aa.count, 4 end assert_equal @ds_aa.count, 2 end def around_all @i ||= 1 super do assert_equal @ds_aa.count, 1 @ds_aa2 = @ds_aa @ds_aa2.insert(1) yield assert_equal @ds_aa.count, 2 end assert_equal DB.table_exists?(:a), false end 3.times do |i| define_method(:"test_should_work_#{i}") do assert_equal @ds_aa.count, 4 assert_equal @ds_ae.count, 4 assert_equal @ds_ba.count, 4 assert_equal @ds_be.count, 4 assert_equal @ds_aa2.count, 4 assert_equal @ds_ae2.count, 4 assert_equal @ds_ba2.count, 4 assert_equal @ds_be2.count, 4 assert_equal @ds_ae3.count, 4 assert_equal @ds_ba3.count, 4 assert_equal @ds_be3.count, 4 end end end end