aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/testing/setup_and_teardown.rb
Commit message (Collapse)AuthorAgeFilesLines
* `SetupAndTeardown` has few caveats that breaks libraries:Edouard CHIN2018-04-271-9/+5
| | | | | | | | | | | | | | | | | | - In #32472 I introduced a fix in order for all `after_teardown` method provided by libraries and Rails to run, even if the application's `teardown` method raised an error (That's the default minitest behavior). However this change wasn't enough and doesn't take in consideration the ancestors chain. If a library's module containing an `after_teardown` method get included after the `SetupAndTeardown` module (one example is the [ActiveRecord::TestFixtures module](https://github.com/rails/rails/blob/7d2400ab61c8e3ed95e14d03ba3844e8ba2e36e4/activerecord/lib/active_record/fixtures.rb#L855-L856), then the ancestors of the test class would look something like ```ruby class MyTest < ActiveSupport::TestCase end puts MyTest.ancestors # [MyTest, ActiveSupport::TestCase, ActiveRecord::TestFixtures, ActiveSupport::Testing::SetupAndTeardown] ``` Any class/module in the ancestors chain that are **before** the `ActiveSupport::Testing::SetupAndTeardown` will behave incorrectly: - Their `before_setup` method will get called **after** all regular setup method - Their `after_teardown` method won't even get called in case an exception is raised inside a regular's test `teardown` A simple reproduction script of the problem here https://gist.github.com/Edouard-chin/70705542a59a8593f619b02e1c0a188c - One solution to this problem is to have the `AS::SetupAndTeardown` module be the very first in the ancestors chain. By doing that we ensure that no `before_setup` / `after_teardown` get executed prior to running the teardown callbacks
* `SetupAndTeardown#teardown` should call any subsequent after_teardown:Edouard CHIN2018-04-061-1/+8
| | | | | | | | If you have a regular test that have a teardown block, and for any reason an exception get raised, ActiveSupport will not run subsequent after_teardown method provided by other module or gems. One of them being the ActiveRecord::TestFixtures which won't rollback the transation when the test ends making all subsequent test to be in a weird state. The default implementation of minitest is to run all teardown methods from the user's test, rescue all exceptions, run all after_teardown methods provided by libraries and finally re-raise the exception that happened in the user's teardown method. Rails should do the same.
* [Active Support] require_relative => requireAkira Matsuda2017-10-211-2/+2
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* [Active Support] require => require_relativeAkira Matsuda2017-07-011-2/+2
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-061-2/+2
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* add documentation for `ActiveSupport::Testing::SetupAndTeardown`.Yves Senn2013-06-191-2/+17
|
* Kill not used constant since removal of runner methodCarlos Antonio da Silva2012-07-031-9/+0
| | | | Runner method was removed in ada571bfcdbad669ae43a4dd18277ef227680a0b.
* remove the runner method copied from minitestAaron Patterson2012-07-031-20/+7
|
* Avoid dependency on MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.James Mead2012-05-291-2/+10
|
* Exceptions like Interrupt should not be rescued.James Mead2012-05-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | Neither Test::Unit nor MiniTest rescue exceptions like Interrupt or NoMemoryError, but ActiveSupport::Testing::SetupAndTeardown#run which overrides MiniTest::Unit::TestCase#run rescues them. Rescuing an Interrupt exception is annoying, because it means when you are running a lot of tests e.g. when running one of the rake test tasks, you cannot break out using ctrl-C. Rescuing exceptions like NoMemoryError is foolish, because the most sensible thing to happen is for the process to terminate as soon as possible. This solution probably needs some finessing e.g. I'm not clear whether the assumption is that only MiniTest is supported. Also early versions of MiniTest did not have this behaviour. However, hopefully it's a start. Integrating with Test::Unit & MiniTest has always been a pain. It would be great if both of them provided sensible extension points for the kind of things that both Rails and Mocha want to do.
* just mix the run method in for minitestAaron Patterson2012-01-061-14/+11
|
* remove ForClassicTestUnit support for ruby 1.8Vishnu Atrai2011-12-261-64/+1
|
* Use run_callbacks; the generated _run_<name>_callbacks method is not a ↵John Firebaugh2011-01-311-4/+4
| | | | | | public interface. Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Removes unused varsSantiago Pastorino2010-07-241-1/+1
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Missing requires addedSantiago Pastorino2010-04-201-0/+3
| | | | Signed-off-by: Xavier Noria <fxn@hashref.com>
* Setup and teardown now use new callbacks.José Valim2009-12-301-27/+46
|
* Ruby 1.9: use method_name to work around miniunit API changesJeremy Kemper2009-11-081-2/+2
|
* Revert "Get AS TestCase off deprecated callbacks"Jeremy Kemper2009-10-141-13/+1
| | | | This reverts commit 29b280666b6a8216a46b8349fa76c85f5b5dcc55.
* Revert "Rewrite AS::TestCase setup/teardown as a single callback chain"Jeremy Kemper2009-10-141-30/+27
| | | | This reverts commit 610e94c097fcc41aaf11bf5ddd45898718aeeb55.
* Revert "Missing requires"Jeremy Kemper2009-10-141-1/+0
| | | | | | These rely on constant autoloads. This reverts commit d39f397dc6726b27cc2c60a6e24e15cb1944ec58.
* Missing requiresMichael Koziarski2009-10-151-0/+1
|
* Rewrite AS::TestCase setup/teardown as a single callback chainJoshua Peek2009-10-121-27/+30
|
* Get AS TestCase off deprecated callbacksJoshua Peek2009-10-121-1/+13
|
* Callbacks, DeprecatedCallbacks = NewCallbacks, CallbacksJoshua Peek2009-10-121-4/+2
|
* Remove stray checks for Rspec in the testing setup.Carl Lerche2009-06-301-2/+0
|
* Bring abstract_controller up to date with rails/masterCarl Lerche & Yehuda Katz2009-04-131-2/+7
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolved all the conflicts since 2.3.0 -> HEAD. Following is a list of commits that could not be applied cleanly or are obviated with the abstract_controller refactor. They all need to be revisited to ensure that fixes made in 2.3 do not reappear in 3.0: 2259ecf368e6a6715966f69216e3ee86bf1a82a7 AR not available * This will be reimplemented with ActionORM or equivalent 06182ea02e92afad579998aa80144588e8865ac3 implicitly rendering a js response should not use the default layout [#1844 state:resolved] * This will be handled generically 893e9eb99504705419ad6edac14d00e71cef5f12 Improve view rendering performance in development mode and reinstate template recompiling in production [#1909 state:resolved] * We will need to reimplement rails-dev-boost on top of the refactor; the changes here are very implementation specific and cannot be cleanly applied. The following commits are implicated: 199e750d46c04970b5e7684998d09405648ecbd4 3942cb406e1d5db0ac00e03153809cc8dc4cc4db f8ea9f85d4f1e3e6f3b5d895bef6b013aa4b0690 e3b166aab37ddc2fbab030b146eb61713b91bf55 ae9f258e03c9fd5088da12c1c6cd216cc89a01f7 44423126c6f6133a1d9cf1d0832b527e8711d40f 0cb020b4d6d838025859bd60fb8151c8e21b8e84 workaround for picking layouts based on wrong view_paths [#1974 state:resolved] * The specifics of this commit no longer apply. Since it is a two-line commit, we will reimplement this change. 8c5cc66a831aadb159f3daaffa4208064c30af0e make action_controller/layouts pick templates from the current instance's view_paths instead of the class view_paths [#1974 state:resolved] * This does not apply at all. It should be trivial to apply the feature to the reimplemented ActionController::Base. 87e8b162463f13bd50d27398f020769460a770e3 fix HTML fallback for explicit templates [#2052 state:resolved] * There were a number of patches related to this that simply compounded each other. Basically none of them apply cleanly, and the underlying issue needs to be revisited. After discussing the underlying problem with Koz, we will defer these fixes for further discussion.
| * The latest trunk of Mocha > 0.9.5 which addresses issue with MiniUnit ↵Ken Collins2009-03-101-1/+6
| | | | | | | | | | | | | | | | compatibility uses namespaced integration classes. [#2060 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
| * Tightening the condition for including ↵Matthias Hennemeyer2009-02-061-1/+1
| | | | | | | | | | | | | | | | ActiveSupport::Testing::SetupAndTeardown::ForMiniTest. [#1871 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* | Revert rspec-runner change. TODO: Add back support for the rspec T::U runner.Carl Lerche & Yehuda Katz2009-04-091-11/+5
| |
* | Changes necessary to run the T::U tests with the rspec runnerYehuda Katz and Carl Lerche2009-04-061-2/+10
|/
* Get ActiveSupport::TestCase working with classic Test::Unit and MiniTest. ↵Jeremy Kemper2008-11-221-75/+37
| | | | Fix broken Mocha + MiniTest. Assume ruby-core applies patch #771 fixing libraries which extend Test::Unit.
* Mocha 0.9.0 compatibility for test setup/teardown callbacksJeremy Kemper2008-11-201-4/+6
|
* Require callbacks so AS::TestCase may be required in isolationJeremy Kemper2008-11-151-0/+2
|
* Rework testing extensions to reflect the recent miniunit upheavalJeremy Kemper2008-11-071-14/+14
|
* Undefine old run methodJoshua Peek2008-07-191-0/+3
|
* Rubinious: setup/teardown override for miniunitJeremy Kemper2008-06-101-7/+31
|
* Workaround missing Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS in Ruby < ↵Jeremy Kemper2008-05-191-2/+10
| | | | 1.8.6. [#224 state:resolved]
* Extract ActiveSupport::Callbacks from Active Record, test case setup and ↵Jeremy Kemper2008-01-191-46/+4
| | | | | | teardown, and ActionController::Dispatcher. Closes #10727. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8664 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* * Continue evolution toward ActiveSupport::TestCase and friends. #10679 ↵Jeremy Kemper2008-01-051-0/+127
[Josh Peek] * TestCase: introduce declared setup and teardown callbacks. Pass a list of methods and an optional block to call before setup or after teardown. Setup callbacks are run in the order declared; teardown callbacks are run in reverse. [Jeremy Kemper] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8570 5ecf4fe2-1ee6-0310-87b1-e25e094e27de