/usr/share/doc/ruby-ramaze/examples/app/whywiki/spec/whywiki.rb is in ruby-ramaze 2012.12.08-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | require 'ramaze'
require 'ramaze/spec/helper'
spec_require 'bluecloth', 'hpricot'
$LOAD_PATH.unshift base = __DIR__('..')
Db = Ramaze::YAMLStoreCache.new("#{base}/testwiki.yaml")
require 'start'
describe 'WikiController' do
behaves_like 'http'
def page(name)
page = get(name)
page.status.should == 200
page.body.should.not == nil
doc = Hpricot(page.body)
title = doc.at('title').inner_html
body = doc.at('body')
return title, body
end
it 'should start' do
ramaze :public_root => base/:public,
:view_root => base/:template
get('/').status.should == 302
end
it 'should have main page' do
t,body = page('/show/Home')
t.should.match(/^MicroWiki Home$/)
body.at('h1').inner_html.should == 'Home'
body.at('a[@href=/edit/Home]').inner_html.should == 'Create Home'
end
it 'should have edit page' do
t,body = page('/edit/Home')
t.should.match(/^MicroWiki Edit Home$/)
body.at('a[@href=/]').inner_html.should == '< Home'
body.at('h1').inner_html.should == 'Edit Home'
body.at('form/textarea').should.not == nil
end
it 'should create pages' do
post('/save','text'=>'the text','page'=>'ThePage').status.should == 302
page = Hpricot(get('/show/ThePage').body)
body = page.at('body>div')
body.should.not == nil
body.at('a[@href=/edit/ThePage]').inner_html.should =='Edit ThePage'
body.at('p').inner_html.should == 'the text'
end
FileUtils.rm("#{base}/testwiki.yaml")
end
|