Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FooTest < Test::Unit::TestCase
- include PresenceAssertions
- # The options required to get a valid Foo.
- @valid_options = { :name => 'qux', :other => 'bar' }
- def test_should_require_name
- assert_presence_of 'Foo', :name
- end
- end
- module PresenceAssertions
- def assert_presence_of(klass, attribute)
- obj = create_valid(klass, attribute => nil)
- assert_equal false, obj.valid?
- end
- def create_valid(klass, options)
- Object.const_get(klass).create(@valid_options.merge(options))
- end
- end
Add Comment
Please, Sign In to add comment