Sha256: 23c7602756f3717c99b8e1de9f1dc5d5afc4dbc2b5bf0755401c4b8811e51c52

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require 'middleman-robots/generators/blocks'

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

    context 'with all options' do
      let(:rules) do
        [
          {
            user_agent: 'GoogleBot',
            disallow: %w[tmp/* /someting/dir/disallow.html],
            allow: %w[allow/* /someting/dir/allow.html]
          },
          {
            user_agent: 'GoogleBot-Image',
            disallow: %w[tmp/* /someting/dir/disallow.html],
            allow: %w[allow/* /someting/dir/allow.html]
          }
        ]
      end
      let(:expected) do
        expected = <<~ROBOTS
          User-Agent: GoogleBot
          Disallow: /tmp/*
          Disallow: /someting/dir/disallow.html
          Allow: /allow/*
          Allow: /someting/dir/allow.html

          User-Agent: GoogleBot-Image
          Disallow: /tmp/*
          Disallow: /someting/dir/disallow.html
          Allow: /allow/*
          Allow: /someting/dir/allow.html
        ROBOTS
        expected.chomp
      end

      it { is_expected.to eq expected }
    end

    context 'without option' do
      let(:rules) { {} }

      it { is_expected.to be_nil }
    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/blocks_spec.rb
middleman-robots-1.3.6 spec/lib/middleman-robots/generators/blocks_spec.rb
middleman-robots-1.3.5 spec/lib/middleman-robots/generators/blocks_spec.rb