<commit_before>module Vigia
  module Sail
    class Example < Vigia::Sail::RSpecObject
      class << self
        def register(name, options)
          @collection = {} if collection.nil?
          @collection.merge!(name => options)
        end

        def run_in_context(context, rspec_context)
          @collection.each do |name, options|
            setup_and_run(name, rspec_context) if example_contexts_include?(context, options[:contexts])
          end
        end

        def example_contexts_include?(context, enabled_contexts)
          [ *(enabled_contexts || :default) ].include?(context.name)
        end
      end

      def run
        instance = self
        rspec.it instance do
          skip              if instance.skip?(self)     || (respond_to?(:skip?)     and send(:skip?))
          skip('__vigia__') if instance.disabled?(self) || (respond_to?(:disabled?) and send(:disabled?))

          instance_exec(&instance.expectation)
        end
      end

      def expectation
        must_be_a_block(options[:expectation], "Example `#{ name }` expectation must be a block")
      end

      def to_s
        return contextual_object(option_name: :description) if options[:description]

        name.to_s
      end

      def skip?(in_context)
        return false unless options[:skip_if]
        contextual_object(option_name: :skip_if, context: in_context)
      end

      def disabled?(in_context)
        return false unless options[:disable_if]
        contextual_object(option_name: :disable_if, context: in_context)<commit_msg>dont run the expectation if it is disabled<commit_after>module Vigia
  module Sail
    class Example < Vigia::Sail::RSpecObject
      class << self
        def register(name, options)
          @collection = {} if collection.nil?
          @collection.merge!(name => options)
        end

        def run_in_context(context, rspec_context)
          @collection.each do |name, options|
            setup_and_run(name, rspec_context) if example_contexts_include?(context, options[:contexts])
          end
        end

        def example_contexts_include?(context, enabled_contexts)
          [ *(enabled_contexts || :default) ].include?(context.name)
        end
      end

      def run
        instance = self
        rspec.it instance do
          skip              if instance.skip?(self)     || (respond_to?(:skip?)     and send(:skip?))

          unless instance.disabled?(self) || (respond_to?(:disabled?) and send(:disabled?))
            instance_exec(&instance.expectation)
          end
        end
      end

      def expectation
        must_be_a_block(options[:expectation], "Example `#{ name }` expectation must be a block")
      end

      def to_s
        return contextual_object(option_name: :description) if options[:description]

        name.to_s
      end

      def skip?(in_context)
        return false unless options[:skip_if]
        contextual_object(option_name: :skip_if, context: in_context)
      end

      def disabled?(in_context)
        return false unless options[:disable_if]
        contextual_object(option_name: :disable_if, context: in_context)
{'fraction_non_alphanumeric': 0.09387884554392642, 'fraction_numerical': 0.0, 'mean_word_length': 2.4583333333333335, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '3594118', 'n_tokens_mistral': 882, 'n_tokens_neox': 876, 'n_words': 212}