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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
require 'spec_helper'
require 'rack/test'
require 'tdiary/rack/valid_request_path'
describe TDiary::Rack::ValidRequestPath do
include Rack::Test::Methods
describe "valid request" do
let(:app) { TDiary::Rack::ValidRequestPath.new(
lambda{|env| [200, {}, ['Awesome']]} )}
it 'should return 200 for latest' do
get '/'
expect(last_response).to be_ok
end
it 'should return 200 for a nyear' do
get '/0501.html'
expect(last_response).to be_ok
end
it 'should return 200 for a month' do
get '/201205.html'
expect(last_response).to be_ok
end
it 'should return 200 for a day' do
get '/20120501.html'
expect(last_response).to be_ok
end
it 'should return 200 for a day with section_permalink_anchor plugin' do
get '/20120501p01.html'
expect(last_response).to be_ok
end
it 'should return 200 for a day with query' do
get '/?date=20120501'
expect(last_response).to be_ok
end
it 'should return 200 for a day with query and section_permalink_anchor plugin' do
get '/?date=20120501&p=01'
expect(last_response).to be_ok
end
it 'should return 200 for a day with index.rb and query' do
get '/index.rb?date=20120501'
expect(last_response).to be_ok
end
it 'should return 404 for access to the invalid file' do
get '/20120501'
expect(last_response.status).to be 404
get '/invalid'
expect(last_response.status).to be 404
head '/invalid'
expect(last_response.status).to be 404
expect(last_response.body.length).to be 0
end
it 'should return 404 for access to the invalid directory' do
get '/invalid/'
expect(last_response.status).to eq(404)
end
end
end
|