Sha256: bd5ddef38976bf3845e832ff6ecaadef0b6118e00f54b9a5e16953ee42f05ea8

Contents?: true

Size: 1.56 KB

Versions: 10

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'

describe SitemapGenerator::Utilities do

  describe "assert_valid_keys" do
    it "should raise error on invalid keys" do
      lambda {
        SitemapGenerator::Utilities.assert_valid_keys({ :name => "Rob", :years => "28" }, :name, :age)
      }.should raise_exception(ArgumentError)
      lambda {
        SitemapGenerator::Utilities.assert_valid_keys({ :name => "Rob", :age => "28" }, "name", "age")
      }.should raise_exception(ArgumentError)
    end

    it "should not raise error on valid keys" do
      lambda {
        SitemapGenerator::Utilities.assert_valid_keys({ :name => "Rob", :age => "28" }, :name, :age)
      }.should_not raise_exception

      lambda {
        SitemapGenerator::Utilities.assert_valid_keys({ :name => "Rob" }, :name, :age)
      }.should_not raise_exception
    end
  end

  describe "titleize" do
    it "should titleize words and replace underscores" do
      SitemapGenerator::Utilities.titleize('google').should == 'Google'
      SitemapGenerator::Utilities.titleize('amy_and_jon').should == 'Amy And Jon'
    end
  end

  describe "truthy?" do
    it "should be truthy" do
      ['1', 1, 't', 'true', true].each do |value|
        SitemapGenerator::Utilities.truthy?(value).should be_true
      end
      SitemapGenerator::Utilities.truthy?(nil).should be_false
    end
  end

  describe "falsy?" do
    it "should be falsy" do
      ['0', 0, 'f', 'false', false].each do |value|
        SitemapGenerator::Utilities.falsy?(value).should be_true
      end
      SitemapGenerator::Utilities.falsy?(nil).should be_false
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sitemap_generator-4.0.1 spec/sitemap_generator/utilities_spec.rb
sitemap_generator-4.0 spec/sitemap_generator/utilities_spec.rb
sitemap_generator-4.0.alpha spec/sitemap_generator/utilities_spec.rb
sitemap_generator-3.4 spec/sitemap_generator/utilities_spec.rb
sitemap_generator-3.3 spec/sitemap_generator/utilities_spec.rb
sitemap_generator-3.2.1 spec/sitemap_generator/utilities_spec.rb
sitemap_generator-3.2 spec/sitemap_generator/utilities_spec.rb
sitemap_generator-3.1.1 spec/sitemap_generator/utilities_spec.rb
sitemap_generator-3.1.0 spec/sitemap_generator/utilities_spec.rb
sitemap_generator-3.0.0 spec/sitemap_generator/utilities_spec.rb