Skip to content

Instantly share code, notes, and snippets.

@cannikin cannikin/output.html
Created Nov 23, 2016

Embed
What would you like to do?
<div class="field">
<header class="field-header">
<label class="field-label" for="wnw_form_builder_test_model_name">
Name <small>(required)</small>
</label>
</header>
<div class="field-feedback">
<span class="field-errors"></span>
<span class="field-success"></span>
<span class="field-warning"></span>
</div>
content
</div>
# <div> that wraps everything
assert_select document, wrapper_selector do |wrapper|
# <header> that wraps label
assert_select wrapper, "header.#{default_classes(:header)}" do |header|
# label has classes and `for` attribute
assert_select header, "label.#{default_classes(:label)}" do |label|
# field required output
assert_select label, "small" do |small|
# actual "(required)" text
assert_equal I18n.t('forms.field_required'), small.children.first.text
end
# label text
assert_equal 'Name', label.children.first.text
end
end
# validation error output
assert_select wrapper, error_selector
# validation success output
assert_select wrapper, success_selector
# actual content of field
assert_equal 'content', wrapper.children.last.text
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.