Sha256: b6913c79607d035b6c93c27dd35ea83a7e0be02330e95b25cb119c742e3c3eb1

Contents?: true

Size: 1.17 KB

Versions: 52

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module RBS
  module Test
    module SetupHelper
      class InvalidSampleSizeError < StandardError
        attr_reader :string

        def initialize(string)
          @string = string
          super("Sample size should be a positive integer: `#{string}`")
        end
      end

      DEFAULT_SAMPLE_SIZE = 100

      def get_sample_size(string)
        case string
        when ""
          DEFAULT_SAMPLE_SIZE
        when 'ALL'
          nil
        else
          int_size = string.to_i
          raise InvalidSampleSizeError.new(string) unless int_size.positive?
          int_size
        end
      end

      def to_double_class(double_suite)
        return nil unless double_suite

        case double_suite.downcase.strip
        when 'rspec'
          [
            '::RSpec::Mocks::Double',
            '::RSpec::Mocks::InstanceVerifyingDouble',
            '::RSpec::Mocks::ObjectVerifyingDouble',
            '::RSpec::Mocks::ClassVerifyingDouble',
          ]
        when 'minitest'
          ['::Minitest::Mock']
        else
          RBS.logger.warn "Unknown test suite - defaults to nil"
          nil
        end
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rbs-3.7.0.dev.1 lib/rbs/test/setup_helper.rb
rbs-3.6.1 lib/rbs/test/setup_helper.rb
rbs-3.6.0 lib/rbs/test/setup_helper.rb
rbs-3.6.0.pre.3 lib/rbs/test/setup_helper.rb
rbs-3.6.0.pre.2 lib/rbs/test/setup_helper.rb
rbs-3.6.0.pre.1 lib/rbs/test/setup_helper.rb
rbs-3.6.0.dev.1 lib/rbs/test/setup_helper.rb
rbs-3.5.3 lib/rbs/test/setup_helper.rb
rbs-3.5.2 lib/rbs/test/setup_helper.rb
rbs-3.5.1 lib/rbs/test/setup_helper.rb
rbs-3.5.1.pre.1 lib/rbs/test/setup_helper.rb
rbs-3.5.0 lib/rbs/test/setup_helper.rb
rbs-3.5.0.pre.2 lib/rbs/test/setup_helper.rb
rbs-3.5.0.pre.1 lib/rbs/test/setup_helper.rb
rbs-3.4.4 lib/rbs/test/setup_helper.rb
rbs-3.4.3 lib/rbs/test/setup_helper.rb
rbs-3.4.2 lib/rbs/test/setup_helper.rb
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/rbs-2.8.4/lib/rbs/test/setup_helper.rb
rbs-3.4.1 lib/rbs/test/setup_helper.rb
rbs-3.4.0 lib/rbs/test/setup_helper.rb