Class: Camping::Test

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/mosquito.rb

Direct Known Subclasses

ModelTest, WebTest

Instance Method Summary collapse

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.



391
392
393
394
395
# File 'lib/mosquito.rb', line 391

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



398
399
400
# File 'lib/mosquito.rb', line 398

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)



374
375
376
# File 'lib/mosquito.rb', line 374

def deny(condition, message='')
  assert !condition, message
end

#test_dummyObject

:nodoc



371
# File 'lib/mosquito.rb', line 371

def test_dummy; end