Sha256: ece343235299723037ad704495b624d730857d47feb849a44af69e1ed7b8783d

Contents?: true

Size: 1.91 KB

Versions: 74

Compression:

Stored size: 1.91 KB

Contents

module Mocha # :nodoc:
  
  # Configuration settings
  class Configuration
    
    DEFAULTS = { :stubbing_method_unnecessarily => :allow, :stubbing_method_on_non_mock_object => :allow, :stubbing_non_existent_method => :allow, :stubbing_non_public_method => :allow }
    
    class << self
    
      # :call-seq: allow(action)
      #
      # Allow the specified <tt>action</tt> (as a symbol).
      # The <tt>actions</tt> currently available are <tt>:stubbing_method_unnecessarily, :stubbing_method_on_non_mock_object, :stubbing_non_existent_method, :stubbing_non_public_method</tt>.
      def allow(action)
        configuration[action] = :allow
      end
    
      def allow?(action) # :nodoc:
        configuration[action] == :allow
      end
    
      # :call-seq: warn_when(action)
      #
      # Warn if the specified <tt>action</tt> (as a symbol) is attempted.
      # The <tt>actions</tt> currently available are <tt>:stubbing_method_unnecessarily, :stubbing_method_on_non_mock_object, :stubbing_non_existent_method, :stubbing_non_public_method</tt>.
      def warn_when(action)
        configuration[action] = :warn
      end
    
      def warn_when?(action) # :nodoc:
        configuration[action] == :warn
      end
    
      # :call-seq: prevent(action)
      #
      # Raise a StubbingError if the specified <tt>action</tt> (as a symbol) is attempted.
      # The <tt>actions</tt> currently available are <tt>:stubbing_method_unnecessarily, :stubbing_method_on_non_mock_object, :stubbing_non_existent_method, :stubbing_non_public_method</tt>.
      def prevent(action)
        configuration[action] = :prevent
      end
    
      def prevent?(action) # :nodoc:
        configuration[action] == :prevent
      end
    
      def reset_configuration # :nodoc:
        @configuration = nil
      end
    
      private
    
      def configuration # :nodoc:
        @configuration ||= DEFAULTS.dup
      end
    
    end
    
  end
  
end

Version data entries

74 entries across 74 versions & 8 rubygems

Version Path
dradis-mediawiki-4.15.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.14.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.13.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.11.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.10.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.9.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.8.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.7.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.6.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.5.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.4.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.3.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.2.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.1.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-4.0.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-3.22.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-3.21.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-3.20.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-3.19.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb
dradis-mediawiki-3.18.0 test/vendor/mocha-0.9.5/lib/mocha/configuration.rb