Sha256: ee90020fb0817404c0e625139b0a469712b40739d0ba5e5c3d741b1e3d093718

Contents?: true

Size: 1.47 KB

Versions: 46

Compression:

Stored size: 1.47 KB

Contents

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

Version data entries

46 entries across 46 versions & 5 rubygems

Version Path
Pistos-ramaze-2008.12 examples/app/whywiki/spec/whywiki.rb
Pistos-ramaze-2009.01 examples/app/whywiki/spec/whywiki.rb
Pistos-ramaze-2009.02 examples/app/whywiki/spec/whywiki.rb
Pistos-ramaze-2009.04.08 examples/app/whywiki/spec/whywiki.rb
Pistos-ramaze-2009.06.12 examples/app/whywiki/spec/whywiki.rb
manveru-ramaze-2008.12 examples/app/whywiki/spec/whywiki.rb
manveru-ramaze-2009.01 examples/app/whywiki/spec/whywiki.rb
manveru-ramaze-2009.04.01 examples/app/whywiki/spec/whywiki.rb
manveru-ramaze-2009.04.08 examples/app/whywiki/spec/whywiki.rb
manveru-ramaze-2009.04.18 examples/app/whywiki/spec/whywiki.rb
manveru-ramaze-2009.04.22 examples/app/whywiki/spec/whywiki.rb
manveru-ramaze-2009.04 examples/app/whywiki/spec/whywiki.rb
manveru-ramaze-2009.05.08 examples/app/whywiki/spec/whywiki.rb
manveru-ramaze-2009.05 examples/app/whywiki/spec/whywiki.rb
manveru-ramaze-2009.06.04 examples/app/whywiki/spec/whywiki.rb
manveru-ramaze-2009.06.12 examples/app/whywiki/spec/whywiki.rb
manveru-ramaze-2009.06 examples/app/whywiki/spec/whywiki.rb
manveru-ramaze-2009.07 examples/app/whywiki/spec/whywiki.rb
ptomato-ramaze-2009.02.1 examples/app/whywiki/spec/whywiki.rb
ptomato-ramaze-2009.02 examples/app/whywiki/spec/whywiki.rb