module RBS::UnitTest::TypeAssertions::ClassMethods
Attributes
target
[R]
[ target_type, Definition ]?
Public Instance Methods
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/unit_test/type_assertions.rb, line 32 def builder @builder ||= RBS::DefinitionBuilder.new(env: env) end
() → Environment
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/unit_test/type_assertions.rb, line 20 def env @env = @@env_cache[@libs] ||= begin loader = RBS::EnvironmentLoader.new (@libs || []).each do |lib| loader.add(library: lib, version: nil) end RBS::Environment.from_loader(loader).resolve_type_names end end
(*String) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/unit_test/type_assertions.rb, line 8 def library(*libs) if @libs raise "Multiple #library calls are not allowed" end @libs = libs @env = nil @target = nil end
(String | target_type) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/unit_test/type_assertions.rb, line 36 def testing(type_or_string) type = case type_or_string when String RBS::Parser.parse_type(type_or_string, variables: []) || raise else type_or_string end definition = case type when RBS::Types::ClassInstance builder.build_instance(type.name) when RBS::Types::ClassSingleton builder.build_singleton(type.name) else raise "Test target should be class instance or class singleton: #{type}" end @target = [type, definition] #: [target_type, Definition] end
testing is to tell the framework which class is being tested
testing "::String" testing "::Array[Integer]" testing "singleton(::Integer)"