The following are custom assertions that people have written. See also the Plugins and HowToWriteYourOwnCustomAssertions.
Most of these duplicate existing functionality, in a more terse, time-saving fashion.
def assert_tag_name(name, opts={})
opts.symbolize_keys!
opts[:attributes] ||= {}
opts[:attributes].merge!(:name => name)
assert_tag opts
end
def assert_tag_id(id, opts={})
opts.symbolize_keys!
opts[:attributes] ||= {}
opts[:attributes].merge!(:id => id)
assert_tag opts
end
def assert_input_field(name, opts={})
assert_tag_name name, opts.merge(:tag => ’input’)
end
def assert_input_fields(*names)
names.each {|name| assert_input_field name}
end
def assert_uniqueness_err(object, field)
assert !object.save
assert_equal 1, object.errors.count
assert_equal “has already been taken”, object.errors.on(field.to_sym)
end
def assert_presence_of_err(object, field)
assert !object.save
assert_equal 1, object.errors.count
assert_equal “can’t be blank”, object.errors.on(field.to_sym)
end