Sha256: d8992a200c64a8440fce10cf8809dad1ff35c079f7e941a73f65576e12de8bcd

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

# encoding: utf-8

require "spec_helper"

describe FoundationRailsHelper::FlashHelper do
  include ActionView::Context if defined?(ActionView::Context)
  include ActionView::Helpers::UrlHelper
  include ActionView::Helpers::TagHelper
  include FoundationRailsHelper::FlashHelper

  FoundationRailsHelper::FlashHelper::DEFAULT_KEY_MATCHING.each do |message_type, foundation_type|
    it "displays flash message with #{foundation_type} class for #{message_type} message" do
      allow(self).to receive(:flash).and_return({message_type => "Flash message"})
      node = Capybara.string display_flash_messages
      expect(node).to have_css("div.alert-box.#{foundation_type}", :text => "Flash message")
      expect(node).to have_css("div.alert-box a.close", :text => "×")
    end
  end

  it "displays flash message with overridden key matching" do
    allow(self).to receive(:flash).and_return({:notice => "Flash message"})
    node = Capybara.string display_flash_messages({:notice => :alert})
    expect(node).to have_css("div.alert-box.alert")
  end

  it "displays flash message with custom key matching" do
    allow(self).to receive(:flash).and_return({:custom_type => "Flash message"})
    node = Capybara.string display_flash_messages({:custom_type => :custom_class})
    expect(node).to have_css("div.alert-box.custom_class")
  end

  it "displays flash message with standard class if key doesn't match" do
    allow(self).to receive(:flash).and_return({:custom_type => "Flash message"})
    node = Capybara.string display_flash_messages
    expect(node).to have_css("div.alert-box.standard")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foundation_rails_helper-1.0.0 spec/foundation_rails_helper/flash_helper_spec.rb