Class: Nitrous::RailsTest
- Inherits:
-
Test
- Object
- Test
- Nitrous::RailsTest
show all
- Defined in:
- lib/nitrous/rails_test.rb
Instance Method Summary
collapse
Methods inherited from Test
callbacks, #callbacks, #collect_errors, exclude, inherited, #initialize, #register_callback, register_callback, #run, run, #running, #setup, setup, stest, #teardown, teardown, test, test_classes, tests, ztest
Methods included from Assertions
#assert!, #assert_equal!, #assert_match!, #assert_nil!, #assert_not_equal!, #assert_not_raised!, #assert_raise!, #fail, included, method_added
Constructor Details
This class inherits a constructor from Nitrous::Test
Instance Method Details
#assert_created!(type) {|instance| ... } ⇒ Object
8
9
10
11
12
13
|
# File 'lib/nitrous/rails_test.rb', line 8
def assert_created!(type)
instance = created(type)
fail("Should have created a #{type}.#{invalid(type) ? " Errors: #{invalid(type).errors.full_messages.to_sentence}" : ''}") unless instance
yield(instance) if block_given?
instance
end
|
#assert_destroyed!(type) {|instance| ... } ⇒ Object
43
44
45
46
47
48
|
# File 'lib/nitrous/rails_test.rb', line 43
def assert_destroyed!(type)
instance = destroyed(type)
fail("Should have destroyed a #{type}.") unless instance
yield(instance) if block_given?
instance
end
|
#assert_email_sent!(count = 1, &block) ⇒ Object
21
22
23
24
25
26
|
# File 'lib/nitrous/rails_test.rb', line 21
def assert_email_sent!(count=1, &block)
assert_equal! @emails + count, ActionMailer::Base.deliveries.size
block.call(*ActionMailer::Base.deliveries[-count..-1]) if block_given?
ensure
@emails = ActionMailer::Base.deliveries.size
end
|
#assert_no_email_sent!(&block) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/nitrous/rails_test.rb', line 28
def assert_no_email_sent!(&block)
assert_equal! @emails, ActionMailer::Base.deliveries.size
block.call if block_given?
ensure
@emails = ActionMailer::Base.deliveries.size
end
|
#assert_not_created!(type) ⇒ Object
15
16
17
18
19
|
# File 'lib/nitrous/rails_test.rb', line 15
def assert_not_created!(type)
instance = created(type).reload rescue nil
fail("Should not have created a #{type}. Instance: #{instance.inspect}") if instance
yield if block_given?
end
|
#created(type) ⇒ Object
4
5
6
|
# File 'lib/nitrous/rails_test.rb', line 4
def created(type)
lookup(type, ActiveRecord::Base.saved_objects)
end
|
#destroyed(type) ⇒ Object
39
40
41
|
# File 'lib/nitrous/rails_test.rb', line 39
def destroyed(type)
lookup(type, ActiveRecord::Base.destroyed_objects)
end
|
#invalid(type) ⇒ Object
35
36
37
|
# File 'lib/nitrous/rails_test.rb', line 35
def invalid(type)
lookup(type, ActiveRecord::Base.invalid_objects)
end
|