Sha256: fe6ef5e911b9488e65669784a09cdf4d4be0622e745bd9f60c87803fa3c4e0d8

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require "spec_helper"

describe Devise::Models::BushidoAuthenticatable do
  
  class ExampleAuth
    include Devise::Models::BushidoAuthenticatable
  end
  
  describe "authenticate_with_cas_ticket" do

    before :each do
      @ticket = Object.new
      @user = Object.new

      @ticket.should_receive(:user).and_return(@user)
      @ticket.should_receive(:has_been_validated?).and_return(true)
      @ticket.should_receive(:is_valid?).and_return(true)
      ::Devise.cas_create_user = true

      ExampleAuth.should_receive(:find_for_authentication).and_return(@user)
      @user.should_receive(:save)
    end
    
    it "should call the bushido_extra_attributes method if it's defined on the devise resource" do
      @ticket.should_receive(:extra_attributes)
      @user.should_receive(:bushido_extra_attributes)
      ExampleAuth.authenticate_with_cas_ticket(@ticket)
    end

    it "should *not* call the bushido_extra_attributes method if it's *not* defined on the devise resource" do

      @user.should_receive(:respond_to?).and_return(false)      
      @user.should_not_receive(:bushido_extra_attributes)

      ExampleAuth.authenticate_with_cas_ticket(@ticket)
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
devise_bushido_authenticatable-1.0.3 spec/devise_cas_authenticatable/model_spec.rb
devise_bushido_authenticatable-1.0.2 spec/devise_cas_authenticatable/model_spec.rb
devise_bushido_authenticatable-1.0.1 spec/devise_cas_authenticatable/model_spec.rb