title: Simple syntax for testing Validation errors
body: <p>I'm looking for clean and short code to test validations in Rails Unittests.</p>
  
  <p>Currently I do something like this</p>
  
  <pre><code>test "create thing without name" do
      assert_raise ActiveRecord::RecordInvalid do
          Thing.create! :param1 =&gt; "Something", :param2 =&gt; 123
      end
  end
  </code></pre>
  
  <p>I guess there is a better way that also shows the validation message?</p>
  
  <p><strong>Solution:</strong></p>
  
  <p>My current solution without an additional frameworks is:</p>
  
  <pre><code>test "create thing without name" do
      thing = Thing.new :param1 =&gt; "Something", :param2 =&gt; 123
      assert thing.invalid?
      assert thing.errors.on(:name).any?
  end
  </code></pre>