Skip to content

Instantly share code, notes, and snippets.

@simlegate
Last active January 27, 2016 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save simlegate/5925629 to your computer and use it in GitHub Desktop.
Save simlegate/5925629 to your computer and use it in GitHub Desktop.
describe how to spec rubycas with rspec.

rubycas client configuration options in config/envirement.rb
[more details] (https://github.com/rubycas/rubycas-client)

# enable detailed CAS logging
cas_logger = CASClient::Logger.new(::Rails.root+'/log/cas.log')
cas_logger.level = Logger::DEBUG

CASClient::Frameworks::Rails::Filter.configure(
  :cas_base_url  => "https://cas.example.foo/",
  :login_url     => "https://cas.example.foo/login",
  :logout_url    => "https://cas.example.foo/logout",
  :validate_url  => "https://cas.example.foo/proxyValidate",
  :username_session_key => :cas_user,
  :extra_attributes_session_key => :cas_extra_attributes,
  :logger => cas_logger,
  :enable_single_sign_out => true
)

testing description
you can set your test data for rubycas as following example

# the key `cas_user` determined by `username_session_key`   
#   session[:cas_user]  => homer
# the key `cas_extra_attributes` determined by `extra_attributes_session_key`
#   session[:cas_extra_attributes] => {:role => "user", :email => "homer@test.foo"}

# fake method argument
#   first: cas_user
#   second: cas_extra_attributes
CASClient::Frameworks::Rails::Filter.fake("homer", {:role => "user", :email => "homer@test.foo"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment