Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Preserve return value in MiniTest example #521

Merged
merged 1 commit into from

2 participants

@mjackson

The return value of MiniTest::Unit::TestCase is significant and needs
to be returned in order for the test reporter to work properly.

I also added an example for overriding the base implementation instead
of doing it in a subclass.

@mjackson mjackson Preserve return value in MiniTest example
The return value of MiniTest::Unit::TestCase is significant and needs
to be returned in order for the test reporter to work properly.

I also added an example for overriding the base implementation instead
of doing it in a subclass.
fd7fe65
@jeremyevans
Owner

This makes sense, I'll merge it tomorrow. Thanks for the help!

Glad to see you are using the block-based transaction API. :)

@jeremyevans jeremyevans merged commit fd7fe65 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 19, 2012
  1. @mjackson

    Preserve return value in MiniTest example

    mjackson authored
    The return value of MiniTest::Unit::TestCase is significant and needs
    to be returned in order for the test reporter to work properly.
    
    I also added an example for overriding the base implementation instead
    of doing it in a subclass.
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 1 deletion.
  1. +16 −1 doc/testing.rdoc
View
17 doc/testing.rdoc
@@ -45,7 +45,22 @@ Make sure you are using Sequel 3.29.0 or above when using these examples, as old
# Must use this class as the base class for your tests
class SequelTestCase < MiniTest::Unit::TestCase
def run(*args, &block)
- Sequel::Model.db.transaction(:rollback=>:always){super}
+ result = nil
+ Sequel::Model.db.transaction(:rollback=>:always){ result = super }
+ result
+ end
+ end
+
+ # Or you could override the base implementation like this
+ class MiniTest::Unit::TestCase
+ alias_method :_original_run, :run
+
+ def run(*args, &block)
+ result = nil
+ Sequel::Model.db.transaction(:rollback => :always) do
+ result = _original_run(*args, &block)
+ end
+ result
end
end
Something went wrong with that request. Please try again.