Follow-up from "Use Pajamas alert component for Rails flash"

The following discussion from !98358 (merged) should be addressed:

  • @splattael started a discussion:

    Suggestion Should we add a spec when variant is nil to test variant&.to_sym? 🙏

    Suggestion (non-blocking) Perhaps we could utilize RSpec::Parameterized::TableSyntax to make specs terse and also more readable like:

        context 'with setting variant type' do
          where(:input, :variant, :icon) do
            :info     | :info    | 'information-o'
            :warning  | :warning | 'warning'
            :success  | :success | 'check-circle'
            :danger   | :danger  | 'error'
            :tip      | :tip     | 'bulb'
            # fallback
            nil       | :info    | 'information-o'
            :foo      | :info    | 'information-o'
            # string
            'success' | :success | 'check-circle'
          end
    
          before do
            render_inline described_class.new(variant: input)
          end
    
          with_them do
            it 'renders the variant' do
              expect(page).to have_selector(".gl-alert-#{variant}")
              expect(page).to have_selector("[data-testid='#{info}-icon']")
            end
          end
        end

    Just a thought.

Edited by 🤖 GitLab Bot 🤖