Sha256: cad2a33abf98a654fc592a5993bb03e809311cec5822067556ef38eb9787cf27

Contents?: true

Size: 1.35 KB

Versions: 30

Compression:

Stored size: 1.35 KB

Contents

module RSpec
  module Mocks
    # Provides configuration options for rspec-mocks.
    class Configuration
      # Adds `stub` and `should_receive` to the given
      # modules or classes. This is usually only necessary
      # if you application uses some proxy classes that
      # "strip themselves down" to a bare minimum set of
      # methods and remove `stub` and `should_receive` in
      # the process.
      #
      # @example
      #
      #   RSpec.configure do |rspec|
      #     rspec.mock_with :rspec do |mocks|
      #       mocks.add_stub_and_should_receive_to Delegator
      #     end
      #   end
      #
      def add_stub_and_should_receive_to(*modules)
        modules.each do |mod|
          Syntax.enable_should(mod)
        end
      end

      def syntax=(values)
        if Array(values).include?(:expect)
          Syntax.enable_expect
        else
          Syntax.disable_expect
        end

        if Array(values).include?(:should)
          Syntax.enable_should
        else
          Syntax.disable_should
        end
      end

      def syntax
        syntaxes = []
        syntaxes << :should  if Syntax.should_enabled?
        syntaxes << :expect if Syntax.expect_enabled?
        syntaxes
      end
    end

    def self.configuration
      @configuration ||= Configuration.new
    end

    configuration.syntax = [:should, :expect]
  end
end

Version data entries

30 entries across 30 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/lib/rspec/mocks/configuration.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/lib/rspec/mocks/configuration.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/lib/rspec/mocks/configuration.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/lib/rspec/mocks/configuration.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/lib/rspec/mocks/configuration.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/lib/rspec/mocks/configuration.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/lib/rspec/mocks/configuration.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/lib/rspec/mocks/configuration.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-mocks-2.14.6/lib/rspec/mocks/configuration.rb
dxruby_rp5-0.0.4 spec/vendor/rspec-mocks-2.14.4/lib/rspec/mocks/configuration.rb
rspec-mocks-2.14.6 lib/rspec/mocks/configuration.rb
rspec-mocks-2.14.5 lib/rspec/mocks/configuration.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-mocks-2.14.4/lib/rspec/mocks/configuration.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-mocks-2.14.4/lib/rspec/mocks/configuration.rb
dxruby_rp5-0.0.3 spec/vendor/rspec-mocks-2.14.4/lib/rspec/mocks/configuration.rb
tuktuk-rails-0.0.10 vendor/bundle/ruby/2.0.0/gems/rspec-mocks-2.14.4/lib/rspec/mocks/configuration.rb
tuktuk-rails-0.0.9 vendor/bundle/ruby/2.0.0/gems/rspec-mocks-2.14.4/lib/rspec/mocks/configuration.rb
tuktuk-rails-0.0.8 vendor/bundle/ruby/2.0.0/gems/rspec-mocks-2.14.4/lib/rspec/mocks/configuration.rb
tuktuk-rails-0.0.7 vendor/bundle/ruby/2.0.0/gems/rspec-mocks-2.14.4/lib/rspec/mocks/configuration.rb
dxruby_rp5-0.0.2 spec/vendor/rspec-mocks-2.14.4/lib/rspec/mocks/configuration.rb