Sha256: bc995a6df6b1d10aa8e6f9ba30258e895f5479c3c9b347c3fa0b564038f45a1b

Contents?: true

Size: 1.36 KB

Versions: 68

Compression:

Stored size: 1.36 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe YARD::Server::StaticCaching do
  include StaticCaching

  describe '#check_static_cache' do
    def adapter; @adapter ||= mock_adapter end
    def request; @request ||= OpenStruct.new end

    it "should return nil if document root is not set" do
      adapter.document_root = nil
      check_static_cache.should be_nil
    end

    it "should read a file from document root if path matches file on system" do
      request.path = '/hello/world.html'
      File.should_receive(:file?).with('/public/hello/world.html').and_return(true)
      File.should_receive(:open).with('/public/hello/world.html', anything).and_return('body')
      s, h, b = *check_static_cache
      s.should == 200
      b.should == ["body"]
    end

    it "should read a file if path matches file on system + .html" do
      request.path = '/hello/world'
      File.should_receive(:file?).with('/public/hello/world.html').and_return(true)
      File.should_receive(:open).with('/public/hello/world.html', anything).and_return('body')
      s, h, b = *check_static_cache
      s.should == 200
      b.should == ["body"]
    end

    it "should return nil if no matching file is found" do
      request.path = '/hello/foo'
      File.should_receive(:file?).with('/public/hello/foo.html').and_return(false)
      check_static_cache.should == nil
    end
  end
end

Version data entries

68 entries across 52 versions & 7 rubygems

Version Path
yard-0.8.7.6 spec/server/static_caching_spec.rb
yard-0.8.7.5 spec/server/static_caching_spec.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/static_caching_spec.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/spec/server/static_caching_spec.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/static_caching_spec.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/static_caching_spec.rb
yard-0.8.7.4 spec/server/static_caching_spec.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/static_caching_spec.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/static_caching_spec.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/spec/server/static_caching_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/static_caching_spec.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/static_caching_spec.rb
climine-0.0.2 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/static_caching_spec.rb
climine-0.0.1 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/static_caching_spec.rb
yard-0.8.7.3 spec/server/static_caching_spec.rb
yard-0.8.7.2 spec/server/static_caching_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/yard-0.8.7/spec/server/static_caching_spec.rb
candlepin-api-0.4.0 bundle/ruby/gems/yard-0.8.7/spec/server/static_caching_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/yard-0.8.7/spec/server/static_caching_spec.rb
yard-0.8.7.1 spec/server/static_caching_spec.rb