Sha256: 5736b901bb2bf72b747af4bec33d2fda993d215179eb5c3136903506691008f2

Contents?: true

Size: 1.51 KB

Versions: 29

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

describe SitemapGenerator::Application do
  before :all do
    SitemapGenerator::Utilities.with_warnings(nil) do
      Object.const_set(:Rails, Object.new)
    end
  end

  after :all do
    SitemapGenerator::Utilities.with_warnings(nil) do
      Object.const_set(:Rails, nil)
    end
  end

  before :each do
    @app = SitemapGenerator::Application.new
  end

  describe "rails3?" do
    tests = {
      :nil => false,
      '2.3.11' => false,
      '3.0.1' => true,
      '3.0.11' => true
    }

    it "should identify the rails version correctly" do
      tests.each do |version, result|
        Rails.expects(:version).returns(version)
        @app.rails3?.should == result
      end
    end
  end

  describe "with Rails" do
    before :each do
      @root = '/test'
      Rails.expects(:root).returns(@root).at_least_once
    end

    it "should use the Rails.root" do
      @app.root.should be_a(Pathname)
      @app.root.to_s.should == @root
      (@app.root + 'public/').to_s.should == File.join(@root, 'public/')
    end
  end

  describe "with no Rails" do
    before :each do
      @rails = Rails
      Object.send(:remove_const, :Rails)
    end

    after :each do
      Object::Rails = @rails
    end

    it "should not be Rails" do
      @app.rails?.should be_false
    end

    it "should use the current working directory" do
      @app.root.should be_a(Pathname)
      @app.root.to_s.should == Dir.getwd
      (@app.root + 'public/').to_s.should == File.join(Dir.getwd, 'public/')
    end
  end
end

Version data entries

29 entries across 29 versions & 3 rubygems

Version Path
sitemap_generator-5.2.0 spec/sitemap_generator/application_spec.rb
sitemap_generator-5.1.0 spec/sitemap_generator/application_spec.rb
sitemap_generator-5.0.5 spec/sitemap_generator/application_spec.rb
ftbpro_sitemap_generator-5.0.8 spec/sitemap_generator/application_spec.rb
sitemap_generator_ftbpro-5.0.6 spec/sitemap_generator/application_spec.rb
sitemap_generator_ftbpro-5.0.5 spec/sitemap_generator/application_spec.rb
sitemap_generator_ftbpro-5.0.4 spec/sitemap_generator/application_spec.rb
sitemap_generator-5.0.4 spec/sitemap_generator/application_spec.rb
sitemap_generator-5.0.3 spec/sitemap_generator/application_spec.rb
sitemap_generator-5.0.2 spec/sitemap_generator/application_spec.rb
sitemap_generator-5.0.1 spec/sitemap_generator/application_spec.rb
sitemap_generator-5.0.0 spec/sitemap_generator/application_spec.rb
sitemap_generator-5.0.0.beta1 spec/sitemap_generator/application_spec.rb
sitemap_generator-5.0.0.beta spec/sitemap_generator/application_spec.rb
sitemap_generator-4.3.1 spec/sitemap_generator/application_spec.rb
sitemap_generator-4.3.0 spec/sitemap_generator/application_spec.rb
sitemap_generator-4.2.0 spec/sitemap_generator/application_spec.rb
sitemap_generator-4.1.1 spec/sitemap_generator/application_spec.rb
sitemap_generator-4.1.0 spec/sitemap_generator/application_spec.rb
sitemap_generator-4.0.1 spec/sitemap_generator/application_spec.rb