File: static_spec.rb

package info (click to toggle)
tdiary 5.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,092 kB
  • sloc: ruby: 23,031; javascript: 1,029; xml: 325; makefile: 26; sh: 2
file content (43 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'spec_helper'
require 'rack/test'
require 'tdiary/rack/static'

describe TDiary::Rack::Static do
	include Rack::Test::Methods

	describe "reserve static files" do
		let(:app) { TDiary::Rack::Static.new(
			lambda{|env| [500, {}, ['Internal Server Error']]}, ['doc'])}

		it 'should return the file in static directory' do
			get '/README.md'
			expect(last_response).to be_ok
		end

		it 'should run the app if file is not exist' do
			get '/index.rb'
			expect(last_response.status).to be 500
		end

		it 'should run the app when post method' do
			post '/index.rb'
			expect(last_response.status).to be 500
		end
	end

	describe "resurve mutiple static files" do
		let(:app) { TDiary::Rack::Static.new(
			lambda{|env| [500, {}, ['Internal Server Error']]}, ['js', 'theme'])}

		it 'should return the file in js directory' do
			get '/00default.js'
			expect(last_response).to be_ok
		end

		it 'should return the file in theme directory' do
			get '/base.css'
			expect(last_response).to be_ok
		end

	end
end