Sha256: d49cc20e47c0167f0d950ed6694b75d7e9c919482c47212b50ef666665a4efc0

Contents?: true

Size: 1.35 KB

Versions: 46

Compression:

Stored size: 1.35 KB

Contents

# Test::Unit
# Place this file into your test/shoulda_macros directory
#
# Example:
# 
# class UserTest
#   should_have_authlogic
# end
#
# Rspec
# Place this file into your spec/support/shoulda directory
#
# Example:
#
# describe User do
#   it { should have_authlogic }
# end

module Authlogic
  module Shoulda

    module Matchers
      def have_authlogic
        HaveAuthlogic.new
      end
      alias_method :be_authentic, :have_authlogic

      class HaveAuthlogic

        def matches?(subject)
          subject.respond_to?(:password=) && subject.respond_to?(:valid_password?)
        end

        def failure_message
          "Add the line 'acts_as_authentic' to your model"
        end

        def description
          "have Authlogic"
        end
      end
      
    end
    
    module Macros
      include Matchers
      
      def should_have_authlogic
        klass = described_type rescue model_class
        matcher = HaveAuthlogic.new
        
        should matcher.description do
          assert matcher.matches?(klass.new), matcher.failure_message
        end
      end
      alias_method :should_be_authentic, :should_have_authlogic
      
    end
    
  end
end

if defined? Spec
  Spec::Runner.configure do |config|
    config.include(Authlogic::Shoulda::Matchers)
  end
else
  Test::Unit::TestCase.class_eval { extend Authlogic::Shoulda::Macros }
end

Version data entries

46 entries across 46 versions & 18 rubygems

Version Path
authlogic-2.1.11 shoulda_macros/authlogic.rb
authlogic-2.1.10 shoulda_macros/authlogic.rb
authlogic-3.2.0 shoulda_macros/authlogic.rb
authlogic-3.1.3 shoulda_macros/authlogic.rb
authlogic-2.1.8 shoulda_macros/authlogic.rb
authlogic-2.1.7 shoulda_macros/authlogic.rb
authlogic-3.1.2 shoulda_macros/authlogic.rb
authlogic-3.1.1 shoulda_macros/authlogic.rb
nulogy-authlogic-3.1.0.1 shoulda_macros/authlogic.rb
Empact-authlogic-3.1.0 shoulda_macros/authlogic.rb
authlogic-3.1.0 shoulda_macros/authlogic.rb
Empact-authlogic-3.0.3 shoulda_macros/authlogic.rb
expertiza-authlogic-2.1.6.1 shoulda_macros/authlogic.rb
antlypls-authlogic-3.0.3 shoulda_macros/authlogic.rb
authlogic-3.0.3 shoulda_macros/authlogic.rb
authlogic-3.0.2 shoulda_macros/authlogic.rb
authlogic-3.0.1 shoulda_macros/authlogic.rb
authlogic-3.0.0 shoulda_macros/authlogic.rb
authlogic-rails3-2.2 shoulda_macros/authlogic.rb
kb-authlogic-2.1.7 shoulda_macros/authlogic.rb