Sha256: 6be545f6e4f8fab7fce36e3113236727b5e491f6e26e8645e015c89d1959e73b
Contents?: true
Size: 1.38 KB
Versions: 5
Compression:
Stored size: 1.38 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 "returns nil if document root is not set" do adapter.document_root = nil expect(check_static_cache).to be nil end it "reads a file from document root if path matches file on system" do request.path = '/hello/world.html' expect(File).to receive(:file?).with('/public/hello/world.html').and_return(true) expect(File).to receive(:open).with('/public/hello/world.html', anything).and_return('body') s, h, b = *check_static_cache expect(s).to eq 200 expect(b).to eq ["body"] end it "reads a file if path matches file on system + .html" do request.path = '/hello/world' expect(File).to receive(:file?).with('/public/hello/world.html').and_return(true) expect(File).to receive(:open).with('/public/hello/world.html', anything).and_return('body') s, h, b = *check_static_cache expect(s).to eq 200 expect(b).to eq ["body"] end it "returns nil if no matching file is found" do request.path = '/hello/foo' expect(File).to receive(:file?).with('/public/hello/foo.html').and_return(false) expect(check_static_cache).to eq nil end end end
Version data entries
5 entries across 4 versions & 2 rubygems