Sha256: 76412d26209392004bb357f808ea6b5c966e6a09447262d04a6c26af0a434fb3
Contents?: true
Size: 1.68 KB
Versions: 3
Compression:
Stored size: 1.68 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 ||= MockRequest.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_info = '/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_info = '/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_info = '/hello/foo' expect(File).to receive(:file?).with('/public/hello/foo.html').and_return(false) expect(check_static_cache).to eq nil end it "adds mount point to cache location" do request.path_info = '/hello/world.html' request.script_name = '/mount/point' expect(File).to receive(:file?).with('/public/mount/point/hello/world.html').and_return(false) expect(check_static_cache).to eq nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yard-0.9.5 | spec/server/static_caching_spec.rb |
yard-0.9.4 | spec/server/static_caching_spec.rb |
yard-0.9.3 | spec/server/static_caching_spec.rb |