Sha256: 6b0c4d2966d544ed80df8eb069ba112c2bf56edb912c550bd612cec55b225466

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require 'middleman-robots/generators/sitemap_uri'

RSpec.describe Middleman::Robots::Generators::SitemapUri do
  describe '#text' do
    subject { described_class.new(uri).text }

    context 'with uri value is' do
      context 'URL String' do
        let(:uri) { 'https://example.com/sitemap.xml' }

        it { is_expected.to eq "Sitemap: #{uri}" }
      end

      context 'nil' do
        let(:uri) { nil }

        it { is_expected.to be_nil }
      end

      context 'empty' do
        let(:uri) { '' }

        it { is_expected.to be_nil }
      end

      context 'ERROR when' do
        subject { -> { described_class.new(rule).text } }

        context 'Array' do
          let(:rule) { { uri: %w[a b] } }

          it { is_expected.to raise_error ArgumentError }
        end

        context 'Numeric' do
          let(:rule) { { uri: 1_000 } }

          it { is_expected.to raise_error ArgumentError }
        end

        context 'Symbol' do
          let(:rule) { { uri: :uri } }

          it { is_expected.to raise_error ArgumentError }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
middleman-robots-1.3.7 spec/lib/middleman-robots/generators/sitemap_uri_spec.rb
middleman-robots-1.3.6 spec/lib/middleman-robots/generators/sitemap_uri_spec.rb
middleman-robots-1.3.5 spec/lib/middleman-robots/generators/sitemap_uri_spec.rb