The bang (!) inverts the result of post.save
assert post.save
reads assert that the post does save
assert !post.save
reads assert that the post doesn't save
Check out the Ruby Logical Operators section at http://www.tutorialspoint.com/ruby/ruby_operators.htm
Edit for extended question:
assert
looks for a true result. If the result is true, it returns a pass for that test. If the result is not true, it returns a fail for that test.
Some pseudo code for the asset
method,
def assert(result)
if result == true
return 'Pass'
else
return 'Fail'
end
end
assert true
=> 'Pass'
assert false
=> 'Fail'
If there is an exception in the test or code, the test
method will rescue the exception and return (E).
Some pseudo code for the test
method,
def test(description, &block)
begin
yield
rescue
return 'Exception'
end
end
test 'test description' do
raise 'An error occurred'
end
=> 'Exception'