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.23.0.1 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.23.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.22.2 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.22.1 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.22.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.21.2 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.21.1 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.21.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.20.1 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.20.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.19.2 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.19.1 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.19.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.18.1 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.18.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.17.2 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.17.1 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.17.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.16.0 spec/components/blacklight/system/flash_message_component_spec.rb
blacklight-7.15.2 spec/components/blacklight/system/flash_message_component_spec.rb