aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/test_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add `#travel` and `#travel_to` to AS::TestCasePrem Sichanugrist2013-11-201-2/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add `ActiveSupport::Testing::TimeHelpers#travel` and `#travel_to`. These methods change current time to the given time or time difference by stubbing `Time.now` and `Date.today` to return the time or date after the difference calculation, or the time or date that got passed into the method respectively. These methods also accept a block, which will return current time back to its original state at the end of the block. Example for `#travel`: Time.now # => 2013-11-09 15:34:49 -05:00 travel 1.day Time.now # => 2013-11-10 15:34:49 -05:00 Date.today # => Sun, 10 Nov 2013 Example for `#travel_to`: Time.now # => 2013-11-09 15:34:49 -05:00 travel_to Time.new(2004, 11, 24, 01, 04, 44) Time.now # => 2004-11-24 01:04:44 -05:00 Date.today # => Wed, 24 Nov 2004 Both of these methods also accept a block, which will return the current time back to its original state at the end of the block: Time.now # => 2013-11-09 15:34:49 -05:00 travel 1.day do User.create.created_at # => Sun, 10 Nov 2013 15:34:49 EST -05:00 end travel_to Time.new(2004, 11, 24, 01, 04, 44) do User.create.created_at # => Wed, 24 Nov 2004 01:04:44 EST -05:00 end Time.now # => 2013-11-09 15:34:49 -05:00 This module is included in `ActiveSupport::TestCase` automatically.
* remove deprecated `assert_present` and `assert_blank`.Yves Senn2013-07-011-48/+0
|
* Updates to make rails 4 happy with minitest 5:Ryan Davis2013-05-061-1/+1
| | | | | | | | | | + Namespace changes, overhaul of runners. + Internal ivar name changes - Removed a logger globally applied to tests that spew everywhere?!? + Override Minitest#__run to sort tests by name. + Reworked testing isolation to work with the new cleaner architecture. - Removed a bunch of tests that just test minitest straight up. I think these changes were all merged to minitest 4 a long time ago. - Minor report output differences.
* deprecate `assert_blank` and `assert_present`.Yves Senn2013-01-051-14/+22
| | | | | They don't add any benefits over `assert object.blank?` and `assert object.present?`
* Test that assert_not returns true. Use assert_raises instead of doing ↵Jeremy Kemper2012-12-281-17/+7
| | | | begin/rescue/else.
* Introduce assert_not to replace 'assert !foo'Jeremy Kemper2012-12-281-0/+21
|
* Make test logs easier to read.Jeremy Kemper2012-12-261-2/+1
| | | | | | Tagging every message in tests makes the logs really wide. It's great for grepping, but annoying to open in an editor or a narrow terminal. Try out a different approach: spit out a heading before each test.
* Prevent callback from being set twice.Dmitriy Kiriyenko2012-12-201-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When you add one callack in two separate `set_callback` calls - it is only called once. When you do it in one `set_callback` call - it is called twice. This violates the principle of least astonishment for me. Duplicating callback is usually an error. There is a correct and obvious way to do anything without this "feature". If you want to do before_save :clear_balance, :calculate_tax, :clear_balance or whatever, you should better do before_save :carefully_calculate_tax def carefully_calculate_tax clear_balance calculate_tax clear_balance end And this even opens gates for some advanced refactorings, unlike the first approach. My assumptions are: - Principle of least astonishment is violated, when callbacks are either prevented from duplication, or not. - Duplicating callbacks is usually an error. When it is intentional - it's a smell of a bad design and can be approached without abusing this "feature". My suggestion is: do not allow duplicating callbacks in one callback call, like it is not allowed in separate callbacks call.
* Changed test names to match proper contextWojciech Wnętrzak2012-09-281-2/+2
|
* Tests tag the Rails log with the current test class and test caseJeremy Kemper2012-09-261-0/+15
|
* Proc always respond_to :bindingAkira Matsuda2012-06-121-43/+39
|
* rescue the assertion exceptionAaron Patterson2012-01-061-13/+8
|
* Removing extra requires from the test. Already loaded in abstract_unit.Arun Agrawal2011-07-311-1/+0
|
* remove warning: assigned but unused variableSantiago Pastorino2011-06-081-1/+1
|
* removing AS::Testing::Default in favor of just undefing default_testAaron Patterson2010-10-011-7/+0
|
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-10/+10
| | | | 's/[ \t]*$//' -i {} \;)
* Removes unused varsSantiago Pastorino2010-07-241-1/+1
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* avoid method redefined; discarding old empty? warning [#4302 state:committed]Santiago Pastorino2010-03-301-8/+0
| | | | Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* New assertion: assert_present [#4299 state:committed]Juanjo Bazan2010-03-301-1/+21
| | | | Signed-off-by: Xavier Noria <fxn@hashref.com>
* new assertion: assert_blankJuanjo Bazan2010-03-301-0/+28
| | | | Signed-off-by: Xavier Noria <fxn@hashref.com>
* Setup and teardown now use new callbacks.José Valim2009-12-301-4/+5
|
* Revert "Get AS TestCase off deprecated callbacks"Jeremy Kemper2009-10-141-0/+52
| | | | This reverts commit 29b280666b6a8216a46b8349fa76c85f5b5dcc55.
* Get AS TestCase off deprecated callbacksJoshua Peek2009-10-121-54/+2
|
* Fix dependencies revealed by testing in isolationJeremy Kemper2009-04-221-0/+1
|
* Include failed difference expression in assert messageJeremy Kemper2009-02-061-2/+5
|
* Ruby 1.9 compat: don't use defined? on complex expressionsJeremy Kemper2008-11-221-1/+1
|
* Just rescue exception rather than checking for both miniunit and test/unitJeremy Kemper2008-11-071-7/+2
|
* Rework testing extensions to reflect the recent miniunit upheavalJeremy Kemper2008-11-071-2/+8
|
* Remove direct TestCase mixins. Add miniunit compatibility.Jeremy Kemper2008-11-071-2/+2
|
* Fix mismatched assertions.Michael Koziarski2008-10-041-2/+2
|
* added nicer failure reporting to #assert_difference to tell you the ↵madlep2008-10-031-0/+18
| | | | | | | expression that failed rather than just the expected and actual values Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1161 state:committed]
* Add empty setup and teardown methods to rule out default setup behavior in ↵Jeremy Kemper2008-06-091-0/+6
| | | | base class
* Extract ActiveSupport::Callbacks from Active Record, test case setup and ↵Jeremy Kemper2008-01-191-4/+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/+46
| | | | | | | | | [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
* require abstract_unit directly since test is in load pathJeremy Kemper2008-01-051-1/+2
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8563 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Make sure default_test is tested for ActiveSupport::TestCase tooMichael Koziarski2007-10-261-3/+5
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8041 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Make Default Test work with both ruby 1.8.4 and 1.8.6. [DrMark] Closes #10003Michael Koziarski2007-10-261-0/+6
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8040 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Mark Test::Unit#assert_difference incompatibility with Ruby 2 due to ↵Jeremy Kemper2007-09-291-32/+35
| | | | | | Proc#binding usage git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7682 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Enhance assert_difference to accept arrays of strings which are then evaledTobias Lütke2007-06-011-0/+6
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6926 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Silence some warnings.Jeremy Kemper2007-05-181-2/+2
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6772 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Evaluate expression for assert_difference in the scope of the blockMarcel Molina2007-05-081-0/+7
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6701 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Simplify API of assert_difference by passing in an expression that is ↵Marcel Molina2007-05-081-16/+31
| | | | | | evaluated before and after the passed in block. See documenation for examples of new API. [Marcel Molina Jr.] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6693 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added assert_difference and assert_no_difference to test/unit assertionsTobias Lütke2007-05-011-0/+34
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6647 5ecf4fe2-1ee6-0310-87b1-e25e094e27de