sonic-pi
https://github.com/sonic-pi-net/sonic-pi
C++
Code. Music. Live.
ActiveSupport::Testing::Assertions#assert_difference
Test numeric difference between the return value of an expression as a
result of what is evaluated in the yielded block.
assert_difference 'Article.count' do
post :create, article: {...}
end
An arbitrary expression is passed in and evaluated.
assert_difference 'assigns(:article).comments(:reload).size' do
post :create, comment: {...}
end
An arbitrary positive or negative difference can be specified.
The default is <tt>1</tt>.
assert_difference 'Article.count', -1 do
post :delete, id: ...
end
An array of expressions can also be passed in and evaluated.
assert_difference [ 'Article.count', 'Post.count' ], 2 do
post :create, article: {...}
end
A lambda or a list of lambdas can be passed in and evaluated:
assert_difference ->{ Article.count }, 2 do
post :create, article: {...}
end
assert_difference [->{ Article.count }, ->{ Post.count }], 2 do
post :create, article: {...}
end
An error message can be specified.
assert_difference 'Article.count', -1, 'An Article should be destroyed' do
post :delete, id: ...
endEdit
git clone [email protected]:sonic-pi-net/sonic-pi.git
cd sonic-pi
open app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/testing/assertions.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-ActiveSupport--Testing--Assertions-assert_difference-for-pr
# Commit to gitgit add app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/testing/assertions.rbgit commit -m "better docs for ActiveSupport::Testing::Assertions#assert_difference"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-ActiveSupport--Testing--Assertions-assert_difference-for-pr
hub pull-request
# Celebrate!