| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There are two main reasons why `assert_called_with` should require
`args` argument:
1) If we want to assert that some method should be called and we don't
need to check with which arguments it should be called then we should use
`assert_called`.
2) `assert_called_with` without `args` argument doesn't assert anything!
```ruby
assert_called_with(@object, :increment) do
@object.decrement
end
```
It causes false assertions in tests that could cause regressions in the project.
I found this bug by working on
[minitest-mock_expectations](https://github.com/bogdanvlviv/minitest-mock_expectations) gem.
This gem is an extension for minitest that provides almost the same method call
assertions.
I was wondering whether you would consider adding "minitest-mock_expectations"
to `rails/rails` instead of private `ActiveSupport::Testing::MethodCallAssertions` module.
If yes, I'll send a patch - https://github.com/bogdanvlviv/rails/commit/a970ecc42c3a9637947599f2c13e3762e4b59208
|
|\
| |
| | |
Stop using Mocha
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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]
|
|/
|
|
|
|
|
|
| |
- 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
|
|
|
|
| |
It includes via `require "abstract_unit"`.
|
| |
|
| |
|
|
|
|
|
| |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
| |
|
|
|
|
|
| |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
| |
|
| |
|
| |
|
| |
|
|
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.
|