Class: Camping::Test

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

Direct Known Subclasses

FunctionalTest, UnitTest

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.



114
115
116
117
118
# File 'lib/junebug/ext/mosquito.rb', line 114

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



119
120
121
# File 'lib/junebug/ext/mosquito.rb', line 119

def assert_no_difference(object, method, &block)
  assert_difference object, method, 0, &block
end

#deny(condition, message = '') ⇒ Object



97
98
99
# File 'lib/junebug/ext/mosquito.rb', line 97

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

#test_dummyObject



95
# File 'lib/junebug/ext/mosquito.rb', line 95

def test_dummy; end