Class: Camping::Test
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- Camping::Test
- Extended by:
- Mosquito::Dusty
- Defined in:
- lib/mosquito.rb
Overview
The basic Mosquito-wielding test case with some infrastructure
Class Method Summary collapse
-
.use_transactional_fixtures ⇒ Object
This is needed because Rails fixtures actually try to setup twice.
Instance Method Summary collapse
- #assert_difference(object, method = :count, difference = 1) ⇒ Object
-
#assert_no_difference(object, method, &block) ⇒ Object
See
assert_difference
. -
#deny(condition, message = '') ⇒ Object
The reverse of the reverse of the reverse of assert(condition).
-
#test_default ⇒ Object
:nodoc.
Methods included from Mosquito::Dusty
Class Method Details
.use_transactional_fixtures ⇒ Object
This is needed because Rails fixtures actually try to setup twice
382 |
# File 'lib/mosquito.rb', line 382 def self.use_transactional_fixtures; false; end |
Instance Method Details
#assert_difference(object, method = :count, difference = 1) ⇒ Object
project.ioni.st/post/217#post-217
def test_new_publication
assert_difference(Publication, :count) do
post :create, :publication_title => ...
# ...
end
end
Is the number of items different?
Can be used for increment and decrement.
402 403 404 405 406 |
# File 'lib/mosquito.rb', line 402 def assert_difference(object, method = :count, difference = 1) initial_value = object.send(method) yield assert_equal initial_value + difference, object.send(method), "#{object}##{method}" end |
#assert_no_difference(object, method, &block) ⇒ Object
See assert_difference
409 410 411 |
# File 'lib/mosquito.rb', line 409 def assert_no_difference(object, method, &block) assert_difference object, method, 0, &block end |
#deny(condition, message = '') ⇒ Object
The reverse of the reverse of the reverse of assert(condition)
385 386 387 |
# File 'lib/mosquito.rb', line 385 def deny(condition, ='') assert !condition, end |
#test_default ⇒ Object
:nodoc
379 |
# File 'lib/mosquito.rb', line 379 def test_default; end |