Class: Camping::Test

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

Overview

The basic Mosquito-wielding test case with some infrastructure

Direct Known Subclasses

ModelTest, WebTest

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mosquito::Dusty

test

Class Method Details

.use_transactional_fixturesObject

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, message='')
  assert !condition, message
end

#test_defaultObject

:nodoc



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

def test_default; end