-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Form::CheckBoxComponent #14
Conversation
c7afc65
to
f2aa263
Compare
%(<input name="user[admin]" type="hidden" value="0">) + | ||
%(<input type="checkbox" value="1" name="user[admin]" id="user_admin">) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolas-brousse idea for a better syntax? (without newlines and whitespace between the input
s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In our current project, I use to have this kind of tests.
expect(component.to_html.tr("\n", "")).to eq <<~HTML.tr("\n", "").strip
<label class="form-checkbox" for="user_is_enabled">
<input name="user[is_enabled]" type="hidden" value="0">
<input class="form-checkbox__input" type="checkbox" value="1" name="user[is_enabled]" id="user_is_enabled">
<span class="form-checkbox__label">Actif</span>
</label>
HTML
It's not the cleanest. Maybe we may create a custom matcher like
expect(component).to have_html <<~HTML
<label class="form-checkbox" for="user_is_enabled">
<input name="user[is_enabled]" type="hidden" value="0">
<input class="form-checkbox__input" type="checkbox" value="1" name="user[is_enabled]" id="user_is_enabled">
<span class="form-checkbox__label">Actif</span>
</label>
HTML
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's create a custom matcher, can you open a PR for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
Related to #4