Sha256: 9c858b764d11b17ee8fbc184f8806bd1a3c4f161564d795648091bf010075ee3

Contents?: true

Size: 1.42 KB

Versions: 7

Compression:

Stored size: 1.42 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
      @template.nofollow.should == "<meta content=\"nofollow\" name=\"robots\" />"
    end

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

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

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

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

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

  describe ".canonical" do
    it "returns nil when not passed a path" do
      @template.canonical.should be_nil
    end

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

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

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tophat-2.1.0 spec/tophat/robots_helper_spec.rb
tophat-2.0.0 spec/tophat/robots_helper_spec.rb
tophat-1.7.2 spec/tophat/robots_helper_spec.rb
tophat-1.7.1 spec/tophat/robots_helper_spec.rb
tophat-1.7.0 spec/tophat/robots_helper_spec.rb
tophat-1.6.1 spec/tophat/robots_helper_spec.rb
tophat-1.6.0 spec/tophat/robots_helper_spec.rb