Sha256: 6bc9ddb197546d708d67cb26ab3b140da7df0bbbe57c44afa8b02d41c8b01684

Contents?: true

Size: 1.84 KB

Versions: 35

Compression:

Stored size: 1.84 KB

Contents

RSpec.describe Symphonia::ApplicationHelper do
  describe "#title" do
    it "returns the default title" do
      expect(helper.title("Holub")).to match /<(h1)\s.*id=\Wpage_header\W.*Holub<\/\1>/
    end

    it "with symbol" do
      expect(helper.title(:title)).to match /<(h1)\s.*id=\Wpage_header\W.*Title<\/\1>/
    end

    it "with back" do
      expect(helper.title("Head", back: true)).to include "history.back()"
    end

    it "with custom back" do
      expect(helper.title("Head", back: "/path")).to include "/path"
    end

    it "xhr without back" do
      allow(helper.request).to receive(:xhr?).and_return true
      expect(helper.title("Head", back: true)).to match /<(h5)\s.*id=\Wpage_header\W.*Head<\/\1>/
    end
  end

  describe "#render_flash_messages" do
    it "render error" do
      r = helper.render_flash_messages(error: "flash message")
      expect(r).to include "danger"
    end
    it "render notice" do
      r = helper.render_flash_messages(notice: "flash message")
      expect(r).to include "success"
    end
    it "render warning" do
      r = helper.render_flash_messages(warning: "flash message")
      expect(r).to include "warning"
    end
    it "render info" do
      r = helper.render_flash_messages(info: "flash message")
      expect(r).to include "info"
    end
  end

  describe "#format_html" do
    it "plain text" do
      expect(helper.format_html("sojka")).to eq "<div class=\"formatted-text\"><p>sojka</p>\n</div>"
    end
    it "plain text" do
      expect(helper.format_html("# sojka")).to eq "<div class=\"formatted-text\"><h1>sojka</h1>\n</div>"
    end
  end

  describe "#render_no_data" do
    it "default" do
      expect(helper.render_no_data).to include t(:text_no_data), "nodata"
    end

    it "custom message" do
      expect(helper.render_no_data("Sorry bro")).to include "Sorry bro", "nodata"
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
symphonia-6.0.1 spec/helpers/symphonia/application_helper_spec.rb
symphonia-6.0.0 spec/helpers/symphonia/application_helper_spec.rb
symphonia-5.0.6 spec/helpers/symphonia/application_helper_spec.rb
symphonia-5.0.5 spec/helpers/symphonia/application_helper_spec.rb
symphonia-5.0.4 spec/helpers/symphonia/application_helper_spec.rb
symphonia-5.0.3 spec/helpers/symphonia/application_helper_spec.rb
symphonia-5.0.0 spec/helpers/symphonia/application_helper_spec.rb
symphonia-4.2.0 spec/helpers/symphonia/application_helper_spec.rb
symphonia-4.1.3 spec/helpers/symphonia/application_helper_spec.rb
symphonia-4.1.2 spec/helpers/symphonia/application_helper_spec.rb
symphonia-4.1.1 spec/helpers/symphonia/application_helper_spec.rb
symphonia-4.1.0 spec/helpers/symphonia/application_helper_spec.rb
symphonia-4.0.1 spec/helpers/symphonia/application_helper_spec.rb
symphonia-4.0.0 spec/helpers/symphonia/application_helper_spec.rb
symphonia-3.4.0 spec/helpers/symphonia/application_helper_spec.rb
symphonia-3.3.4 spec/helpers/symphonia/application_helper_spec.rb
symphonia-3.3.3 spec/helpers/symphonia/application_helper_spec.rb
symphonia-3.3.2 spec/helpers/symphonia/application_helper_spec.rb
symphonia-3.3.0 spec/helpers/symphonia/application_helper_spec.rb
symphonia-3.2.4 spec/helpers/symphonia/application_helper_spec.rb