Sha256: de26a207bc150de240b68e47a7f4676bcbf49048baae4f5c06edf3c834a3ecfe

Contents?: true

Size: 881 Bytes

Versions: 5

Compression:

Stored size: 881 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

class GAuthApp < Sinatra::Base
  register Sinatra::GAuth
  set :gauth_redirect, '/not-protected'

  get '/not-protected' do
    "Hello! I'm not protected."
  end

  get '/protected' do
    protect_with_gauth!
    "Hello! I'm protected with gauth."
  end
end

describe Sinatra::GAuth do
  include Rack::Test::Methods
  def app
    GAuthApp.new
  end

  describe "if route is not protected" do
    it 'will not redirect user' do
      get '/not-protected'
      last_response.status.must_equal 200
    end
  end

  describe "if route is protected" do
    it 'will redirect user for authentication' do
      get '/protected'
      last_response.status.must_equal 302
    end

    it 'will redirect to /auth/g' do
      get '/protected'
      last_response.original_headers['Location'].must_equal 'http://example.org/auth/g'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sinatra-g_auth-0.0.5 spec/sinatra/g_auth_spec.rb
sinatra-g_auth-0.0.4 spec/sinatra/g_auth_spec.rb
sinatra-g_auth-0.0.3 spec/sinatra/g_auth_spec.rb
sinatra-g_auth-0.0.2 spec/sinatra/g_auth_spec.rb
sinatra-g_auth-0.0.1 spec/sinatra/g_auth_spec.rb