sinatra-authentication /test/route_tests.rb

Language Ruby Lines 30
MD5 Hash 1fc0dce85f1c59734b97d41f89acbe26 Estimated Cost $491 (why?)
Repository https://github.com/yrgoldteeth/sinatra-authentication.git View Raw File
 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
Test::Unit::TestCase.send :include, Rack::Test::Methods

class SinatraAuthDataMapperTest < Test::Unit::TestCase

  def setup
    post '/signup', TestHelper.gen_user
    follow_redirect!
    get '/logout'
  end

  def test_should_login
    post '/login', {'email' => TestHelper.gen_user['user[email]'], 'password' => TestHelper.gen_user['user[password]']}
    follow_redirect!

    assert_equal 'http://example.org/', last_request.url
    #assert cookie_jar['user']
    assert last_request.env['rack.session'][:user]
    assert last_response.ok?
  end

  def test_should_logout
    post '/login', {'email' => TestHelper.gen_user['user[email]'], 'password' => TestHelper.gen_user['user[password]']}
    get '/logout'
    follow_redirect!

    assert !last_request.env['rack.session'][:user]
    assert_equal 'http://example.org/', last_request.url
  end
end
Back to Top