Skip to content

Instantly share code, notes, and snippets.

@terabyte
Created December 21, 2012 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terabyte/4356189 to your computer and use it in GitHub Desktop.
Save terabyte/4356189 to your computer and use it in GitHub Desktop.
how do you test something raises an error while also testing activerecord object classes?
require 'test_helper'
class EventTest < ActiveSupport::TestCase
test "event requires a username and a timestamp" do
e1 = Event.new
e1.id = 1
e1.username = nil
e1.timestamp = Time.now
e1.description = "some description"
lambda { e1.save }.should_throw Error
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment