<commit_before>module RSpec
  module Expectations
    # @api private
    # Provides methods for enabling and disabling the available
    # syntaxes provided by rspec-expectations.
    module Syntax
      extend self

      # @api private
      # Enables the `should` syntax.
      def enable_should(syntax_host = ::Kernel)
        return if should_enabled?(syntax_host)

        syntax_host.module_eval do
          # Passes if +matcher+ returns true.  Available on every +Object+.
          # @example
          #   actual.should eq(expected)
          #   actual.should be > 4
          # @param [Matcher]
          #   matcher
          # @param [String] message optional message to display when the expectation fails
          # @return [Boolean] true if the expectation succeeds (else raises)
          # @see RSpec::Matchers
          def should(matcher=nil, message=nil, &block)
            RSpec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block)
          end

          # Passes if +matcher+ returns false.  Available on every +Object+.
          # @example
          #   actual.should_not eq(expected)
          # @param [Matcher]
          #   matcher
          # @param [String] message optional message to display when the expectation fails
          # @return [Boolean] false if the negative expectation succeeds (else raises)
          # @see RSpec::Matchers
          def should_not(matcher=nil, message=nil, &block)
            RSpec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block)
          end
        end
      end

      # @api private
      # Disables the `should` syntax.
      def disable_should(syntax_host = ::Kernel)
        return unless should_enabled?(syntax_host)

        syntax_host.module_eval do
          undef should
          undef should_not
        end
      end

      # @api private
      # Enables the `expect` syntax.
      def enable_expect(syntax_host = ::RSpec::Matchers)
        return if expect_enabled?(syntax_host)

        syntax_host.module_eval do
          def expect(*target, &target_block)
            target << target_block if block_given?
            raise ArgumentError.new("You must pass an argument or a block to #expect but not both.") unless target.size == 1
            ::RSpec::Expectations::ExpectationTarget.new(target.first)
          end
        end
      end

      # @api private
      # Disables the `expect` syntax.
      def disable_expect(syntax_host = ::RSpec::Matchers)
        return unless expect_enabled?(syntax_host)

        syntax_host.module_eval do
          undef expect
        end
      end

      # @api private
      # Indicates whether or not the `should` syntax is enabled.
      def should_enabled?(syntax_host = ::Kernel)
        syntax_host.method_defined?(:should)
      end

      # @api private
      # Indicates whether or not the `expect` syntax is enabled.
      def expect_enabled?(syntax_host = ::RSpec::Matchers)
        syntax_host.method_defined?(:expect)
      end
    end
  end
end
<commit_msg>put the rdoc for should, should_not, and expect where yard can pick it up<commit_after>module RSpec
  module Expectations
    # @api private
    # Provides methods for enabling and disabling the available
    # syntaxes provided by rspec-expectations.
    module Syntax
      extend self

      # @method should
      # Passes if `matcher` returns true.  Available on every `Object`.
      # @example
      #   actual.should eq expected
      #   actual.should match /expression/
      # @param [Matcher]
      #   matcher
      # @param [String] message optional message to display when the expectation fails
      # @return [Boolean] true if the expectation succeeds (else raises)
      # @see RSpec::Matchers

      # @method should_not
      # Passes if `matcher` returns false.  Available on every `Object`.
      # @example
      #   actual.should_not eq expected
      # @param [Matcher]
      #   matcher
      # @param [String] message optional message to display when the expectation fails
      # @return [Boolean] false if the negative expectation succeeds (else raises)
      # @see RSpec::Matchers

      # @method expect
      # Wraps `target` in an `ExpectationTarget`
      # @return [ExpectationTarget]

      # @api private
      # Enables the `should` syntax.
      def enable_should(syntax_host = ::Kernel)
        return if should_enabled?(syntax_host)

        syntax_host.module_eval do
          def should(matcher=nil, message=nil, &block)
            RSpec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block)
          end

          def should_not(matcher=nil, message=nil, &block)
            RSpec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block)
          end
        end
      end

      # @api private
      # Disables the `should` syntax.
      def disable_should(syntax_host = ::Kernel)
        return unless should_enabled?(syntax_host)

        syntax_host.module_eval do
          undef should
          undef should_not
        end
      end

      # @api private
      # Enables the `expect` syntax.
      def enable_expect(syntax_host = ::RSpec::Matchers)
        return if expect_enabled?(syntax_host)

        syntax_host.module_eval do
          def expect(*target, &target_block)
            target << target_block if block_given?
            raise ArgumentError.new("You must pass an argument or a block to #expect but not both.") unless target.size == 1
            ::RSpec::Expectations::ExpectationTarget.new(target.first)
          end
        end
      end

      # @api private
      # Disables the `expect` syntax.
      def disable_expect(syntax_host = ::RSpec::Matchers)
        return unless expect_enabled?(syntax_host)

        syntax_host.module_eval do
          undef expect
        end
      end

      # @api private
      # Indicates whether or not the `should` syntax is enabled.
      def should_enabled?(syntax_host = ::Kernel)
        syntax_host.method_defined?(:should)
      end

      # @api private
      # Indicates whether or not the `expect` syntax is enabled.
      def expect_enabled?(syntax_host = ::RSpec::Matchers)
        syntax_host.method_defined?(:expect)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07806573957016436, 'fraction_numerical': 0.0004740834386852086, 'mean_word_length': 2.3433703116745908, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '797063', 'n_tokens_mistral': 1739, 'n_tokens_neox': 1682, 'n_words': 526}