Last active
May 27, 2019 23:30
Revisions
-
e2 revised this gist
Nov 18, 2014 . 1 changed file with 4 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,33 +9,15 @@ require 'rspec/matchers' RSpec::Core::Runner.disable_autorun! RSpec.configure do |c| c.expect_with :minitest end module MiniTest class Test end end at_exit do constants = Object.constants.select selected = constants.select do |const| @@ -53,9 +35,8 @@ def assert(condition, message = nil) meths = klass.public_instance_methods.select { |meth| /^test_/ =~ meth } group.around do |example| klass.include(RSpec::Matchers) @__rspec_test_instance = klass.new(klass.to_s) @__rspec_test_instance.setup if @instance.respond_to?(:setup) example.run @__rspec_test_instance.teardown if @instance.respond_to?(:teardown) -
e2 revised this gist
Nov 17, 2014 . 1 changed file with 11 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ # HOW TO USE: # # 1) save this to /some_path/lib/minitests/autorun.rb # 2) run your test with RSpec, e.g. # # $ RUBYLIB=/some_path/lib rspec -f d test/hello_test.rb @@ -18,12 +17,22 @@ class Test end module Assertions def __filter_backtrace__(bt) bt.reject { |x| x.start_with?("#{__FILE__}:") } end def assert_equal(expected, actual, message = nil) expect(actual).to eq(expected) rescue RSpec::Expectations::ExpectationNotMetError => e e.set_backtrace(__filter_backtrace__(e.backtrace)) fail end def assert(condition, message = nil) expect(condition).to be_truthy rescue RSpec::Expectations::ExpectationNotMetError => e e.set_backtrace(__filter_backtrace__(e.backtrace)) fail end end -
e2 revised this gist
Nov 17, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ # HOW TO USE: # # Given you have a minitest-based test requiring "minitest/autorun" # 1) save this to /some_path/lib/minitest/autorun.rb # 2) run your test with RSpec, e.g. # # $ RUBYLIB=/some_path/lib rspec -f d test/hello_test.rb -
e2 created this gist
Nov 17, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,62 @@ # HOW TO USE: # # 1) save this to /some_path/lib/minitests/autorun.rb # 2) run your test with RSpec, e.g. # # $ RUBYLIB=/some_path/lib rspec -f d test/hello_test.rb require 'rspec/core' require 'rspec/matchers' RSpec::Core::Runner.disable_autorun! RSpec.configure { |c| } module MiniTest class Test end end module Assertions def assert_equal(expected, actual, message = nil) expect(actual).to eq(expected) end def assert(condition, message = nil) expect(condition).to be_truthy end end at_exit do constants = Object.constants.select selected = constants.select do |const| next unless const =~ /Test$/ klass = Object.const_get(const) next unless klass.respond_to?(:superclass) klass.superclass == MiniTest::Test end klasses = selected.map { |name| Object.const_get(name) } klasses.each do |klass| group = RSpec.describe(klass) meths = klass.public_instance_methods.select { |meth| /^test_/ =~ meth } group.around do |example| klass.include(Assertions) klass.include(RSpec::Matchers) @__rspec_test_instance = klass.new @__rspec_test_instance.setup if @instance.respond_to?(:setup) example.run @__rspec_test_instance.teardown if @instance.respond_to?(:teardown) end meths.each do |meth| group.it(meth.to_s[/^test_(.*)/,1].tr('_',' ')) do |example| @__rspec_test_instance.method(meth).call end end end RSpec::Core::Runner.run([]) end