Sha256: 979696b27cc58a20910308ec9da2717c677e3a8b87ea8256820da49bd0a18277

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require "spec_helper"

describe Devise::Models::CloudfujiAuthenticatable do
  
  class ExampleAuth
    include Devise::Models::CloudfujiAuthenticatable
  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 cloudfuji_extra_attributes method if it's defined on the devise resource" do
      @ticket.should_receive(:extra_attributes)
      @user.should_receive(:cloudfuji_extra_attributes)
      ExampleAuth.authenticate_with_cas_ticket(@ticket)
    end

    it "should *not* call the cloudfuji_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(:cloudfuji_extra_attributes)

      ExampleAuth.authenticate_with_cas_ticket(@ticket)
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
devise_cloudfuji_authenticatable-1.0.5 spec/devise_cas_authenticatable/model_spec.rb
devise_cloudfuji_authenticatable-1.0.4 spec/devise_cas_authenticatable/model_spec.rb