Sha256: 330a640c6783de0458255d1bd35a001a0a19a5cbf031dfcc7b4cdc2c4bdc3ccf

Contents?: true

Size: 1.25 KB

Versions: 69

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
  subject(:component) { described_class.new(message: message, type: type) }

  let(:view_context) { controller.view_context }
  let(:render) do
    component.render_in(view_context)
  end

  let(:rendered) do
    Capybara::Node::Simple.new(render)
  end
  let(:message) { 'This is an important message' }
  let(:type) { 'whatever' }

  it 'renders a message inside an alert' do
    expect(rendered).to have_selector 'div.alert.alert-whatever', text: message
  end

  context 'with a success message' do
    let(:type) { 'success' }

    it 'adds some styling' do
      expect(rendered).to have_selector 'div.alert-success'
    end
  end

  context 'with a notice message' do
    let(:type) { 'notice' }

    it 'adds some styling' do
      expect(rendered).to have_selector 'div.alert-info'
    end
  end

  context 'with an alert message' do
    let(:type) { 'alert' }

    it 'adds some styling' do
      expect(rendered).to have_selector 'div.alert-warning'
    end
  end

  context 'with an error message' do
    let(:type) { 'error' }

    it 'adds some styling' do
      expect(rendered).to have_selector 'div.alert-danger'
    end
  end
end

Version data entries

69 entries across 69 versions & 2 rubygems

Version Path
blacklight-7.40.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.39.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.38.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-8.2.2 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-8.2.1 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-8.2.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.37.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.36.2 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.36.1 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.36.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.35.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-8.1.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.34.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-8.0.1 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-8.0.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-8.0.0.beta8 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-8.0.0.beta7 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-8.0.0.beta6 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-8.0.0.beta5 spec/components/blacklight/system/flash_message_component_spec.rb