Sha256: e36a50000c2ae3c284480c1d4c2585681c03a389d45b3cb22095921d5923dfce

Contents?: true

Size: 1.83 KB

Versions: 35

Compression:

Stored size: 1.83 KB

Contents

require 'innate/spec'

FileUtils.rm_f('todo.pstore')

require 'start'
require 'hpricot'

describe Todo do
  behaves_like :mock, :multipart

  it 'starts out without tasks' do
    doc = Hpricot(get('/').body)
    doc.at(:table).inner_text.strip.should.be.empty
  end

  it 'adds a task and redirects back' do
    got = post('/create', multipart('title' => 'first task'))
    got.status.should == 302
    got['Location'].should == 'http://example.org/'
  end

  it 'shows the task as pending' do
    doc = Hpricot(get('/').body)
    doc.at('td/input[@name=title]')['value'].should == 'first task'
    doc.at('td/input[@name=done]')['checked'].should.be.nil
  end

  it 'updates the task title and redirects back' do
    got = post('/update', multipart('id' => 'first task', 'title' => 'wash dishes'))
    got.status.should == 302
    got['Location'].should == 'http://example.org/'
  end

  it 'shows the changed task title' do
    doc = Hpricot(get('/').body)
    doc.at('td/input[@name=title]')['value'].should == 'wash dishes'
    doc.at('td/input[@name=done]')['checked'].should.be.nil
  end

  it 'marks the task as done and redirects back' do
    mp = multipart('id' => 'wash dishes', 'title' => 'wash dishes', 'done' => 'on')
    got = post('/update', mp)
    got.status.should == 302
    got['Location'].should == 'http://example.org/'
  end

  it 'shows the task as done' do
    doc = Hpricot(get('/').body)
    doc.at('td/input[@name=title]')['value'].should == 'wash dishes'
    doc.at('td/input[@name=done]')['checked'].should == 'checked'
  end

  it 'deletes the task and redirects back' do
    got = post('/delete', multipart('id' => 'wash dishes'))
    got.status.should == 302
    got['Location'].should == 'http://example.org/'
  end

  it 'shows no tasks' do
    doc = Hpricot(get('/').body)
    doc.at(:table).inner_text.strip.should.be.empty
  end
end

Version data entries

35 entries across 35 versions & 3 rubygems

Version Path
innate-2023.01.06 example/app/todo/spec/todo.rb
innate-2015.10.28 example/app/todo/spec/todo.rb
manveru-innate-2009.02.25 example/app/todo/spec/todo.rb
manveru-innate-2009.03.24 example/app/todo/spec/todo.rb
manveru-innate-2009.04.01 example/app/todo/spec/todo.rb
manveru-innate-2009.04.08 example/app/todo/spec/todo.rb
manveru-innate-2009.04.18 example/app/todo/spec/todo.rb
manveru-innate-2009.04 example/app/todo/spec/todo.rb
manveru-innate-2009.05 example/app/todo/spec/todo.rb
manveru-innate-2009.06.12 example/app/todo/spec/todo.rb
manveru-innate-2009.06 example/app/todo/spec/todo.rb
manveru-innate-2009.07 example/app/todo/spec/todo.rb
rjspotter-innate-2009.06.29 example/app/todo/spec/todo.rb
rjspotter-innate-2009.06.30 example/app/todo/spec/todo.rb
rjspotter-innate-2009.06.31 example/app/todo/spec/todo.rb
innate-2013.02.21 example/app/todo/spec/todo.rb
innate-2013.02 example/app/todo/spec/todo.rb
innate-2012.12 example/app/todo/spec/todo.rb
innate-2012.03 example/app/todo/spec/todo.rb
innate-2011.12 example/app/todo/spec/todo.rb