Skip to content
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

Merged
merged 6 commits into from
Jun 30, 2021
Merged

Add Form::CheckBoxComponent #14

merged 6 commits into from
Jun 30, 2021

Conversation

Spone
Copy link
Collaborator

@Spone Spone commented Jun 26, 2021

Related to #4

@Spone Spone self-assigned this Jun 26, 2021
@Spone Spone mentioned this pull request Jun 26, 2021
71 tasks
Comment on lines +14 to +15
%(<input name="user[admin]" type="hidden" value="0">) +
%(<input type="checkbox" value="1" name="user[admin]" id="user_admin">)
Copy link
Collaborator Author

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 inputs)

Copy link
Member

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

Copy link
Collaborator Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

@Spone Spone merged commit 588e716 into main Jun 30, 2021
@Spone Spone deleted the check-box-component branch June 30, 2021 10:11
@Spone Spone added this to the v0.1 milestone Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants