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 68 69 70 71 72
|
require 'spec_helper'
require 'rack/test'
require 'tdiary/application'
describe TDiary::Application do
include Rack::Test::Methods
before do
end
describe '#call' do
let(:app) { TDiary::Application.new }
context "when is accessed to index"
it do
get '/'
expect(last_response.status).to eq 200
end
context "when is accessed to update" do
it do
get '/update.rb'
expect(last_response.status).to eq 401
end
end
context "with base_dir" do
before do
TDiary.configuration.options['base_url'] = 'http://example.com/diary/'
end
after do
TDiary.configuration.options['base_url'] = ''
end
let(:app) { TDiary::Application.new }
it do
get '/diary/'
expect(last_response.status).to eq 200
end
context "when access to root directory" do
it do
get '/'
expect(last_response.status).to eq 404
end
end
end
context "when the application raises exception" do
before do
allow(TDiary::Dispatcher).to receive_message_chain(:index).and_return(
lambda {|env| raise StandardError.new }
)
end
it do
get '/'
expect(last_response.status).to eq 500
expect(last_response.body).to match(/^StandardError/)
end
end
end
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
|