Sha256: 8e2ab37536982b8e2ec00d98a7fcf9e789f46c77556a002542601b9861e9c475

Contents?: true

Size: 1.78 KB

Versions: 6

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'

describe 'Navigasmic::Builder::MapBuilder', type: :helper do

  subject { Navigasmic::Builder::MapBuilder }

  def clean(string)
    string.gsub(/\n(\s+)|\n|^\s+/, '')
  end

  describe "rendering" do

    it "outputs basic example" do
      builder = subject.new helper, :primary, {} do |n|
        n.group(class: 'group') { n.item "Label", '/path' }
        n.item('Level 1', class: 'item') { n.item 'Level 2' }
      end

      xml = <<-XML
        <urlset changefreq="yearly" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
          <url>
            <loc>http://test.host/path</loc>
            <name>Label</name>
          </url>
        </urlset>
      XML

      builder.render.should match(clean(xml))
    end

    it "handles builder configurations" do
      builder = subject.new helper, :primary, {changefreq: 'weekly'} do |n|
        n.group('Group', class: 'group') { n.item "Label", '/path' }
        n.item('Level 1', class: 'item') { n.item 'Level 2' }
        n.item('Foo', '/other_path')
      end

      xml = <<-XML
        <urlset changefreq="weekly" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
          <url>
            <loc>http://test.host/path</loc>
            <name>Label</name>
          </url>
          <url>
            <loc>http://test.host/other_path</loc>
            <name>Foo</name>
          </url>
        </urlset>
      XML

      builder.render.should match(clean(xml))
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
navigasmic-1.1.0 spec/builders/map_builder_spec.rb
navigasmic-1.0.5 spec/builders/map_builder_spec.rb
navigasmic-1.0.4 spec/builders/map_builder_spec.rb
navigasmic-1.0.3 spec/builders/map_builder_spec.rb
navigasmic-1.0.2 spec/builders/map_builder_spec.rb
navigasmic-1.0.1 spec/builders/map_builder_spec.rb