Sha256: 1021177522e1cf765d3fb37e62be5f90540636d87fa807a4bfe0fa6d69a5a95b

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require 'test_helper'

class TitleTagTest < ActionView::TestCase
  include Metamagic::ViewHelper

  test "title tag" do
    meta title: "My Title"

    assert_equal %{<title>My Title</title>},
                 metamagic
  end

  test "shortcut helper" do
    title "My Title"

    assert_equal %{<title>My Title</title>},
                 metamagic
  end

  test "nil title" do
    title nil
    description "Test description"

    assert_equal %{<meta content="Test description" name="description" />},
                 metamagic
  end

  test "title template" do
    title "Test Title"

    assert_equal %{<title>Test Title — My Site</title>},
                 metamagic(site: "My Site", title_template: ":title — :site")
  end

  test "title template with default title" do
    assert_equal %{<title>Test Title — My Site</title>},
                 metamagic(site: "My Site", title: "Test Title", title_template: ":title — :site")
  end

  test "title template with nil site" do
    title "Test Title"

    assert_raises RuntimeError do
      metamagic(title_template: ":title — :site")
    end
  end

  test "title template proc" do
    title "Test Title"

    assert_equal %{<title>Site: My Site — Title: Test Title</title>},
                 metamagic(site: "My Site", title_template: -> { "Site: #{site} — Title: #{title}" })
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
metamagic-3.1.0 test/title_tag_test.rb