Sha256: 9e1e379828bfb162e9679449dff9cc3297e5891402984044bd0b11d0a8058b3b

Contents?: true

Size: 1.8 KB

Versions: 4

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'

describe TopHat::RobotsHelper do

  before(:all) do
    @template = ActionView::Base.new
  end

  describe ".nofollow" do
    it "defaults to all robots" do
      expect(@template.nofollow).to eq("<meta content=\"nofollow\" name=\"robots\" />")
    end

    it "uses a descriptor if one is provided" do
      expect(@template.nofollow('googlebot')).to eq("<meta content=\"nofollow\" name=\"googlebot\" />")
    end

    it "generates a default tag when passed nil" do
      expect(@template.nofollow(nil)).to eq("<meta content=\"nofollow\" name=\"robots\" />")
    end

    it 'stores a descriptor' do
      @template.nofollow('twitterbot')
      expect(@template.nofollow).to eq("<meta content=\"nofollow\" name=\"twitterbot\" />")
    end
  end

  describe ".noindex" do
    it "defaults to all robots" do
      expect(@template.noindex).to eq("<meta content=\"noindex\" name=\"robots\" />")
    end

    it "uses a descriptor if one is provided" do
      expect(@template.noindex('googlebot')).to eq("<meta content=\"noindex\" name=\"googlebot\" />")
    end

    it "generates a default tag when passed nil" do
      expect(@template.noindex(nil)).to eq("<meta content=\"noindex\" name=\"robots\" />")
    end

    it 'stores a descriptor' do
      @template.noindex('twitterbot')
      expect(@template.noindex).to eq("<meta content=\"noindex\" name=\"twitterbot\" />")
    end
  end

  describe ".canonical" do
    it "returns nil when not passed a path" do
      expect(@template.canonical).to be_nil
    end

    it "renders a tag when passed a path" do
      expect(@template.canonical('http://mysite.com/somepath/')).to eq("<link href=\"http://mysite.com/somepath/\" rel=\"canonical\" />")
    end

    it "returns nil when passed nil" do
      expect(@template.canonical(nil)).to be_nil
    end
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/tophat-2.3.1/spec/tophat/robots_helper_spec.rb
tophat-2.3.1 spec/tophat/robots_helper_spec.rb
tophat-2.3.0 spec/tophat/robots_helper_spec.rb
tophat-2.2.1 spec/tophat/robots_helper_spec.rb