aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/testing/method_call_assertions_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #33162 from utilum/stop_using_mochaKasper Timm Hansen2018-08-221-0/+83
|\ | | | | Stop using Mocha
| * Add method_call_assertions and use them instead of Mochautilum2018-08-131-0/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Six Mocha calls prove quite resistant to Minitestification. For example, if we replace ``` ActiveRecord::Associations::HasManyAssociation .any_instance .expects(:reader) .never ``` with `assert_not_called`, Minitest wisely raises ``` NameError: undefined method `reader' for class `ActiveRecord::Associations::HasManyAssociation' ``` as `:reader` comes from a deeply embedded abstract class, `ActiveRecord::Associations::CollectionAssociation`. This patch tackles this difficulty by adding `ActiveSupport::Testing::MethodCallAsserts#assert_called_on_instance_of` which injects a stubbed method into `klass`, and verifies the number of times it is called, similar to `assert_called`. It also adds a convenience method, `assert_not_called_on_instance_of`, mirroring `assert_not_called`. It uses the new method_call_assertions to replace the remaining Mocha calls in `ActiveRecord` tests. [utilum + bogdanvlviv + kspath]
* | Test `assert_called` and `assert_called_with`bogdanvlviv2018-08-141-0/+10
|/ | | | | | | | - ActiveSupport::Testing::MethodCallAssertions#assert_called - Ensure that the method stubbed by `assert_called` returns correct value after - ActiveSupport::Testing::MethodCallAssertions#assert_called_with - Ensure that `#assert_called_with` stubs the method to return a specific value - Ensure that the method stubbed by `assert_called_with` returns correct value after
* Remove extra `include ActiveSupport::Testing::MethodCallAssertions`bogdanvlviv2018-06-081-3/+0
| | | | It includes via `require "abstract_unit"`.
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* applies new string literal convention in activesupport/testXavier Noria2016-08-061-3/+3
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Cleaned up generators tests using internal assertion helperRonak Jangir2015-08-201-0/+6
|
* Replacing lambda with proc getting argument error because of it.Ronak Jangir2015-08-171-0/+6
|
* Added helper methods to stub any instanceRonak Jangir2015-08-131-0/+13
|
* Add multiple expected calls to assert_called_with.Kasper Timm Hansen2015-07-101-0/+7
|
* Add method call assertions for internal use.Kasper Timm Hansen2015-07-081-0/+91
Add `assert_called` and `assert_not_called` to boil down the boilerplate we need to write to assert methods are called certain number of times.