├── sorbet ├── config └── rbi │ ├── todo.rbi │ ├── gems │ ├── rspec.rbi │ ├── sorbet-coerce.rbi │ ├── simplecov-cobertura.rbi │ ├── simplecov-html.rbi │ ├── docile.rbi │ ├── safe_type.rbi │ ├── polyfill.rbi │ ├── rspec-support.rbi │ ├── simplecov.rbi │ ├── rexml.rbi │ ├── byebug.rbi │ └── rspec-mocks.rbi │ └── sorbet-typed │ └── lib │ └── sorbet-coerce │ └── >=0.2.4 │ └── sorbet-coerce.rbi ├── .rspec ├── lib ├── sorbet-coerce.rb ├── sorbet-coerce │ ├── configuration.rb │ └── converter.rb └── bundled_rbi │ └── sorbet-coerce.rbi ├── bin └── publish-gem.sh ├── spec ├── spec_helper.rb ├── sorbet_test_cases.rb ├── soft_error_spec.rb ├── nested_spec.rb └── coerce_spec.rb ├── SECURITY.md ├── .github ├── ISSUE_TEMPLATE │ └── bug.md └── workflows │ ├── publish-gem.yml │ └── ci.yml ├── Gemfile ├── .gitignore ├── sorbet-coerce.gemspec ├── LICENSE ├── CONTRIBUTING.md └── README.md /sorbet/config: -------------------------------------------------------------------------------- 1 | --dir 2 | . 3 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /lib/sorbet-coerce.rb: -------------------------------------------------------------------------------- 1 | # typed: ignore 2 | require 'sorbet-coerce/converter' 3 | 4 | module TypeCoerce 5 | def self.[](type) 6 | TypeCoerce::Converter.new(type) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /bin/publish-gem.sh: -------------------------------------------------------------------------------- 1 | mkdir -p ~/.gem 2 | touch ~/.gem/credentials 3 | chmod 600 ~/.gem/credentials 4 | echo "---" >> ~/.gem/credentials 5 | echo ":github: Bearer ${GITHUB_TOKEN}" >> ~/.gem/credentials 6 | echo ":rubygems_api_key: ${RUBYGEMS_API_KEY}" >> ~/.gem/credentials 7 | gem build *.gemspec 8 | gem push *.gem 9 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | require "byebug" 3 | require "simplecov" 4 | require "simplecov-cobertura" 5 | 6 | SimpleCov.start 7 | SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter 8 | 9 | RSpec.configure do |config| 10 | config.expect_with(:rspec) { |c| c.syntax = :expect } 11 | end 12 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting Security Vulnerabilities 2 | 3 | The Chan Zuckerberg Initiative takes security issues seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions. 4 | 5 | If you believe you have found a security issue, please contact us at security@chanzuckerberg.com. 6 | -------------------------------------------------------------------------------- /lib/sorbet-coerce/configuration.rb: -------------------------------------------------------------------------------- 1 | # typed: true 2 | require 'sorbet-runtime' 3 | 4 | module TypeCoerce 5 | module Configuration 6 | class << self 7 | extend T::Sig 8 | 9 | sig { returns(T::Boolean) } 10 | attr_accessor :raise_coercion_error 11 | end 12 | end 13 | end 14 | 15 | TypeCoerce::Configuration.raise_coercion_error = true 16 | -------------------------------------------------------------------------------- /sorbet/rbi/todo.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi todo 3 | 4 | # typed: strong 5 | module ::Anonymous_Delegator_4; end 6 | module T::CompatibilityPatches::RSpecCompatibility::MethodDoubleExtensions; end 7 | module T::CompatibilityPatches::RSpecCompatibility::RecorderExtensions; end 8 | module T::Private::Methods::SingletonMethodHooks; end 9 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/rspec.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi gems 3 | 4 | # typed: strict 5 | # 6 | # If you would like to make changes to this file, great! Please create the gem's shim here: 7 | # 8 | # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/rspec/all/rspec.rbi 9 | # 10 | # rspec-3.11.0 11 | 12 | module RSpec 13 | end 14 | module RSpec::Version 15 | end 16 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/sorbet-coerce.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi gems 3 | 4 | # typed: strict 5 | # 6 | # If you would like to make changes to this file, great! Please create the gem's shim here: 7 | # 8 | # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/sorbet-coerce/all/sorbet-coerce.rbi 9 | # 10 | # sorbet-coerce-0.5.0 11 | 12 | module TypeCoerce 13 | def self.[](type); end 14 | end 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Report a bug 3 | about: Create a report to help us improve 4 | labels: bug 5 | --- 6 | 7 | **Describe the bug:** 8 | 9 | 10 | **Steps to reproduce:** 11 | 12 | 13 | **Expected behavior:** 14 | 15 | 16 | **Versions:** 17 | 22 | - Ruby: 23 | - Sorbet: 24 | - Sorbet-Coerce: 25 | -------------------------------------------------------------------------------- /lib/bundled_rbi/sorbet-coerce.rbi: -------------------------------------------------------------------------------- 1 | # typed: false 2 | module SafeType 3 | class CoercionError < StandardError; end 4 | end 5 | 6 | module TypeCoerce 7 | extend T::Sig 8 | extend T::Generic 9 | 10 | Elem = type_member 11 | 12 | sig { params(args: T.untyped, raise_coercion_error: T.nilable(T::Boolean), coerce_empty_to_nil: T::Boolean).returns(Elem) } 13 | def from(args, raise_coercion_error: nil, coerce_empty_to_nil: false); end 14 | 15 | class CoercionError < SafeType::CoercionError; end 16 | class ShapeError < SafeType::CoercionError; end 17 | end 18 | -------------------------------------------------------------------------------- /.github/workflows/publish-gem.yml: -------------------------------------------------------------------------------- 1 | name: Create and publish sorbet-coerce 2 | 3 | # see: https://github.com/chanzuckerberg/redcord/blob/master/.github/workflows/publish.yml 4 | 5 | on: 6 | workflow_dispatch: 7 | release: 8 | types: [published] 9 | jobs: 10 | publish-gem: 11 | runs-on: ubuntu-latest 12 | env: 13 | GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}" 14 | RUBYGEMS_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}" 15 | steps: 16 | - uses: actions/checkout@v2 17 | - uses: ruby/setup-ruby@v1 18 | with: 19 | ruby-version: 2.7 20 | - name: Publish gems to package repositry 21 | run: | 22 | ./bin/publish-gem.sh 23 | -------------------------------------------------------------------------------- /spec/sorbet_test_cases.rb: -------------------------------------------------------------------------------- 1 | # typed: false 2 | require 'sorbet-coerce' 3 | 4 | T.assert_type!(TypeCoerce[Integer].new.from('1'), Integer) 5 | T.assert_type!( 6 | TypeCoerce[T.nilable(Integer)].new.from('invalid', raise_coercion_error: false), 7 | T.nilable(Integer), 8 | ) 9 | 10 | TypeCoerce::Configuration.raise_coercion_error = true 11 | coercion_error = nil 12 | begin 13 | TypeCoerce[T.nilable(Integer)].new.from('invalid') 14 | rescue TypeCoerce::CoercionError => e 15 | coercion_error = e 16 | end 17 | raise 'no coercion error is raised' unless coercion_error 18 | 19 | T.assert_type!( 20 | TypeCoerce[T.nilable(Integer)].new.from('invalid', raise_coercion_error: false), 21 | T.nilable(Integer), 22 | ) 23 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | 5 | group :test do 6 | gem 'rake', require: false 7 | gem 'simplecov', require: false 8 | #Simplecov-cobertura to generate an xml coverage file which can then be uploaded to Codecov 9 | gem 'simplecov-cobertura' 10 | end 11 | 12 | sorbet_version = ENV["SORBET_VERSION"] 13 | if sorbet_version 14 | # mostly used to test against a stable version of Sorbet in Travis. 15 | gem 'sorbet', sorbet_version 16 | gem 'sorbet-runtime', sorbet_version 17 | else 18 | # prefer to test against latest version because sorbet is updated frequently 19 | gem 'sorbet' 20 | gem 'sorbet-runtime' 21 | end 22 | 23 | gem 'safe_type', '>= 1.1.1' 24 | gem 'polyfill', '~> 1.8' 25 | -------------------------------------------------------------------------------- /sorbet/rbi/sorbet-typed/lib/sorbet-coerce/>=0.2.4/sorbet-coerce.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi sorbet-typed 3 | # 4 | # If you would like to make changes to this file, great! Please upstream any changes you make here: 5 | # 6 | # https://github.com/sorbet/sorbet-typed/edit/master/lib/sorbet-coerce/>=0.2.4/sorbet-coerce.rbi 7 | # 8 | # typed: false 9 | module SafeType 10 | class CoercionError < StandardError; end 11 | end 12 | 13 | module TypeCoerce 14 | extend T::Sig 15 | extend T::Generic 16 | 17 | Elem = type_member 18 | 19 | sig { params(args: T.untyped, raise_coercion_error: T.nilable(T::Boolean)).returns(Elem) } 20 | def from(args, raise_coercion_error: nil); end 21 | 22 | class CoercionError < SafeType::CoercionError; end 23 | class ShapeError < SafeType::CoercionError; end 24 | end 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | /.config 4 | /coverage/ 5 | /InstalledFiles 6 | /pkg/ 7 | /spec/reports/ 8 | /spec/examples.txt 9 | /test/tmp/ 10 | /test/version_tmp/ 11 | /tmp/ 12 | 13 | ## Documentation cache and generated files: 14 | /.yardoc/ 15 | /_yardoc/ 16 | /doc/ 17 | /rdoc/ 18 | 19 | ## Environment normalization: 20 | /.bundle/ 21 | /vendor/bundle 22 | /lib/bundler/man/ 23 | 24 | # for a library or gem, you might want to ignore these files since the code is 25 | # intended to run in multiple environments; otherwise, check them in: 26 | /Gemfile.lock 27 | .ruby-version 28 | .ruby-gemset 29 | 30 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 31 | .rvmrc 32 | 33 | .byebug_history 34 | 35 | # editor swap files 36 | *.swp 37 | *.swo 38 | *.swn 39 | *.swm 40 | *.swl 41 | *.swk 42 | .vscode 43 | 44 | /sorbet/rbi/hidden-definitions/errors.txt 45 | -------------------------------------------------------------------------------- /sorbet-coerce.gemspec: -------------------------------------------------------------------------------- 1 | Gem::Specification.new do |s| 2 | s.name = %q{sorbet-coerce} 3 | s.version = "0.7.0" 4 | s.date = %q{2019-10-04} 5 | s.summary = %q{A type coercion lib works with Sorbet's static type checker and type definitions; raises an error if the coercion fails.} 6 | s.authors = ["Chan Zuckerberg Initiative"] 7 | s.email = "opensource@chanzuckerberg.com" 8 | s.homepage = "https://github.com/chanzuckerberg/sorbet-coerce" 9 | s.license = 'MIT' 10 | s.require_paths = ["lib"] 11 | s.files = Dir.glob('lib/**/*') 12 | s.files += Dir.glob('spec/**/*') 13 | s.files += Dir.glob('rbi/**/*') 14 | 15 | s.required_ruby_version = '>= 2.7.0' 16 | 17 | s.add_runtime_dependency 'polyfill', '~> 1.8' 18 | s.add_runtime_dependency 'safe_type', '~> 1.1', '>= 1.1.1' 19 | s.add_runtime_dependency 'sorbet-runtime', '>= 0.4.4704' 20 | 21 | s.add_development_dependency 'sorbet', '>= 0.4.4704' 22 | s.add_development_dependency 'rspec', '~> 3.8', '>= 3.8' 23 | s.add_development_dependency 'byebug', '~>11.0.1', '>=11.0.1' 24 | end 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Chan Zuckerberg Initiative 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/simplecov-cobertura.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi gems 3 | 4 | # typed: strict 5 | # 6 | # If you would like to make changes to this file, great! Please create the gem's shim here: 7 | # 8 | # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/simplecov-cobertura/all/simplecov-cobertura.rbi 9 | # 10 | # simplecov-cobertura-2.1.0 11 | 12 | module SimpleCov 13 | end 14 | module SimpleCov::Formatter 15 | end 16 | class SimpleCov::Formatter::CoberturaFormatter 17 | def coverage_output(result); end 18 | def extract_rate(percent); end 19 | def format(result); end 20 | def initialize(result_file_name: nil); end 21 | def project_root; end 22 | def resolve_filename(filename); end 23 | def result_to_xml(result); end 24 | def set_branch_attributes(line, file_line, branched_lines, branched_lines_covered); end 25 | def set_class_attributes(class_, file); end 26 | def set_coverage_attributes(coverage, result); end 27 | def set_line_attributes(line, file_line); end 28 | def set_package_attributes(package, name, result); end 29 | def set_xml_head(lines = nil); end 30 | end 31 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: # Trigger only on the main branch to avoid duplicate runs on PR branches 6 | - main 7 | pull_request: # Trigger All PRs 8 | 9 | jobs: 10 | rspec: 11 | runs-on: ubuntu-latest 12 | 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | ruby: ['2.7', '3.0', '3.1', 'ruby-head'] 17 | include: 18 | - ruby: 'ruby-head' 19 | experimental: true # a hack to allow tests to fail for ruby-head, https://github.com/actions/toolkit/issues/399 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | - uses: ruby/setup-ruby@v1 24 | with: 25 | ruby-version: ${{ matrix.ruby }} 26 | # note: bundler-cache: true causes problems since we don't commit `Gemfile.lock`, etc. 27 | - run: bundle install 28 | - run: bundle exec srb tc 29 | - run: bundle exec rspec || ${{ matrix.experimental == true }} # the eq forces a boolean instead of an empty string 30 | - run: bundle exec ruby spec/sorbet_test_cases.rb || ${{ matrix.experimental == true }} 31 | - name: Upload to Codecov 32 | uses: codecov/codecov-action@v3 33 | with: 34 | file: coverage/coverage.xml 35 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/simplecov-html.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi gems 3 | 4 | # typed: strict 5 | # 6 | # If you would like to make changes to this file, great! Please create the gem's shim here: 7 | # 8 | # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/simplecov-html/all/simplecov-html.rbi 9 | # 10 | # simplecov-html-0.12.3 11 | 12 | module SimpleCov 13 | end 14 | module SimpleCov::Formatter 15 | end 16 | class SimpleCov::Formatter::HTMLFormatter 17 | def asset_output_path; end 18 | def assets_path(name); end 19 | def branchable_result?; end 20 | def coverage_css_class(covered_percent); end 21 | def covered_percent(percent); end 22 | def format(result); end 23 | def formatted_file_list(title, source_files); end 24 | def formatted_source_file(source_file); end 25 | def id(source_file); end 26 | def initialize; end 27 | def line_status?(source_file, line); end 28 | def link_to_source_file(source_file); end 29 | def output_message(result); end 30 | def output_path; end 31 | def shortened_filename(source_file); end 32 | def strength_css_class(covered_strength); end 33 | def template(name); end 34 | def timeago(time); end 35 | end 36 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/docile.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi gems 3 | 4 | # typed: strict 5 | # 6 | # If you would like to make changes to this file, great! Please create the gem's shim here: 7 | # 8 | # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/docile/all/docile.rbi 9 | # 10 | # docile-1.4.0 11 | 12 | module Docile 13 | def dsl_eval(dsl, *args, &block); end 14 | def dsl_eval_immutable(dsl, *args, &block); end 15 | def dsl_eval_with_block_return(dsl, *args, &block); end 16 | def self.dsl_eval(dsl, *args, &block); end 17 | def self.dsl_eval_immutable(dsl, *args, &block); end 18 | def self.dsl_eval_with_block_return(dsl, *args, &block); end 19 | extend Docile::Execution 20 | end 21 | module Docile::Execution 22 | def exec_in_proxy_context(dsl, proxy_type, *args, &block); end 23 | def self.exec_in_proxy_context(dsl, proxy_type, *args, &block); end 24 | end 25 | class Docile::FallbackContextProxy 26 | def initialize(receiver, fallback); end 27 | def instance_variables; end 28 | def method_missing(method, *args, &block); end 29 | end 30 | class Docile::ChainingFallbackContextProxy < Docile::FallbackContextProxy 31 | def method_missing(method, *args, &block); end 32 | end 33 | module Docile::BacktraceFilter 34 | def backtrace; end 35 | def backtrace_locations; end 36 | end 37 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Sorbet Coerce 2 | 3 | Thank you for taking the time to contribute to this project! 4 | 5 | This project adheres to the Contributor Covenant 6 | [code of conduct](https://github.com/chanzuckerberg/.github/tree/master/CODE_OF_CONDUCT.md). 7 | By participating, you are expected to uphold this code. Please report unacceptable behavior 8 | to opensource@chanzuckerberg.com. 9 | 10 | This project is licensed under the [MIT license](LICENSE.md). 11 | 12 | ## Need Help? 13 | 14 | If you are trying to integrate Sorbet into your project, consider these venues: 15 | 16 | * **Stack Overflow**: Try the [sorbet](https://stackoverflow.com/questions/tagged/sorbet) tag 17 | * **Slack**: [the Sorbet community](https://sorbet.org/en/community) includes 18 | [#discuss](https://sorbet-ruby.slack.com/app_redirect?channel=discuss) and 19 | [#coerce](https://sorbet-ruby.slack.com/app_redirect?channel=coerce) channels 20 | 21 | If you've come here to report an issue, you're in the right place! 22 | 23 | ## Reporting Bugs and Adding Functionality 24 | 25 | We're excited you'd like to contribute to Sorbet Coerce! 26 | 27 | When reporting a bug, please include: 28 | * Steps to reproduce 29 | * The versions of Ruby, Sorbet, and this gem that you are using 30 | * A test case, if you are able 31 | 32 | **If you believe you have found a security issue, please contact us at security@chanzuckerberg.com** 33 | rather than filing an issue here. 34 | 35 | When proposing new functionality, please include test coverage. We're also available in 36 | the Sorbet Slack [#coerce](https://sorbet-ruby.slack.com/app_redirect?channel=coerce) channel 37 | to discuss your idea before you get started, just to make sure everyone is on the same page. 38 | 39 | ## Local Development 40 | 41 | 1. Clone `sorbet-coerce` locally: 42 | 43 | ```sh 44 | ❯ git clone https://github.com/chanzuckerberg/sorbet-coerce.git 45 | ``` 46 | 47 | 2. Point your project's Gemfile to your local clone: 48 | 49 | ``` 50 | # -- Gemfile -- 51 | 52 | gem 'sorbet-coerce', path: "~/sorbet-coerce" 53 | ``` 54 | 55 | ## Tests 56 | 57 | Tests are written using [RSpec](https://rspec.info/). Each pull request is run against 58 | multiple versions of both Ruby and sorbet-coerce. A code coverage report is also generated. 59 | 60 | ### Running Tests 61 | 62 | You can run tests using `bundle exec rspec`. 63 | -------------------------------------------------------------------------------- /spec/soft_error_spec.rb: -------------------------------------------------------------------------------- 1 | # typed: false 2 | require 'sorbet-coerce' 3 | require 'sorbet-runtime' 4 | 5 | describe TypeCoerce do 6 | context 'when type errors are soft errors' do 7 | class SoftErrorTestEnum < T::Enum 8 | enums do 9 | Other = new 10 | end 11 | end 12 | 13 | let(:ignore_error) { Proc.new {} } 14 | 15 | before(:each) do 16 | allow(TypeCoerce::Configuration).to receive( 17 | :raise_coercion_error, 18 | ).and_return(false) 19 | 20 | allow(T::Configuration).to receive( 21 | :inline_type_error_handler, 22 | ).and_return(ignore_error) 23 | 24 | allow(T::Configuration).to receive( 25 | :call_validation_error_handler, 26 | ).and_return(ignore_error) 27 | 28 | allow(T::Configuration).to receive( 29 | :sig_builder_error_handler, 30 | ).and_return(ignore_error) 31 | end 32 | 33 | class ParamsWithSortError < T::Struct 34 | const :a, Integer 35 | end 36 | 37 | class CustomTypeRaisesHardError 38 | def initialize(value) 39 | raise StandardError.new('value cannot be 1') if value == 1 40 | end 41 | end 42 | 43 | class CustomTypeDoesNotRiaseHardError 44 | def self.new(a); 1; end 45 | end 46 | 47 | let(:invalid_arg) { 'invalid integer string' } 48 | 49 | it 'overwrites the global config when inline config is set' do 50 | expect { 51 | TypeCoerce[Integer].new.from(invalid_arg, raise_coercion_error: true) 52 | }.to raise_error(TypeCoerce::CoercionError) 53 | end 54 | 55 | it 'works as expected' do 56 | expect(TypeCoerce[Integer].new.from(invalid_arg)).to eql(nil) 57 | expect(TypeCoerce[SoftErrorTestEnum].new.from('bad_key')).to eql(nil) 58 | 59 | expect{TypeCoerce[T::Array[Integer]].new.from(1)}.to raise_error(TypeCoerce::ShapeError) 60 | expect(TypeCoerce[T::Array[Integer]].new.from({a: 1})).to eql([nil]) 61 | 62 | expect { 63 | TypeCoerce[CustomTypeRaisesHardError].new.from(1) 64 | }.to raise_error(StandardError) 65 | expect(TypeCoerce[CustomTypeDoesNotRiaseHardError].new.from(1)).to eql(1) 66 | 67 | sorbet_version = Gem.loaded_specs['sorbet-runtime'].version 68 | if sorbet_version >= Gem::Version.new('0.4.4948') 69 | expect(TypeCoerce[ParamsWithSortError].new.from({a: invalid_arg}).a).to eql(nil) 70 | end 71 | end 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /spec/nested_spec.rb: -------------------------------------------------------------------------------- 1 | # typed: false 2 | require 'sorbet-coerce' 3 | require 'sorbet-runtime' 4 | 5 | describe TypeCoerce do 6 | context 'when given nested types' do 7 | class User < T::Struct 8 | const :id, Integer 9 | const :valid, T.nilable(T::Boolean) 10 | end 11 | 12 | class NestedParam < T::Struct 13 | const :users, T::Array[User] 14 | const :params, T.nilable(NestedParam) 15 | end 16 | 17 | it 'works with nest T::Struct' do 18 | converted = TypeCoerce[NestedParam].new.from({ 19 | users: [{id: '1'}], 20 | params: { 21 | users: [{id: '2', valid: 'true'}], 22 | params: { 23 | users: [{id: '3', valid: 'true'}], 24 | }, 25 | }, 26 | }) 27 | # => ] 32 | # >, 33 | # users=[] 34 | # >, 35 | # users=[] 36 | # > 37 | 38 | expect(converted.users.map(&:id)).to eql([1]) 39 | expect(converted.params.users.map(&:id)).to eql([2]) 40 | expect(converted.params.params.users.map(&:id)).to eql([3]) 41 | end 42 | 43 | it 'works with nest T::Array' do 44 | expect { 45 | TypeCoerce[T::Array[T.nilable(Integer)]].new.from(['1', 'invalid', '3']) 46 | }.to raise_error(TypeCoerce::CoercionError) 47 | expect( 48 | TypeCoerce[T::Array[T::Array[Integer]]].new.from([nil]) 49 | ).to eql([[]]) 50 | expect( 51 | TypeCoerce[T::Array[T::Array[Integer]]].new.from([['1'], ['2'], ['3']]), 52 | ).to eql [[1], [2], [3]] 53 | 54 | expect(TypeCoerce[ 55 | T::Array[ 56 | T::Array[ 57 | T::Array[User] 58 | ] 59 | ] 60 | ].new.from([[[{id: '1'}]]]).flatten.first.id).to eql(1) 61 | 62 | expect(TypeCoerce[ 63 | T::Array[ 64 | T::Array[ 65 | T::Array[ 66 | T::Array[ 67 | T::Array[User] 68 | ] 69 | ] 70 | ] 71 | ] 72 | ].new.from([[[[[{id: 1}]]]]]).flatten.first.id).to eql 1 73 | 74 | expect(TypeCoerce[ 75 | T.nilable(T::Array[T.nilable(T::Array[T.nilable(User)])]) 76 | ].new.from([[{id: '1'}]]).flatten.map(&:id)).to eql([1]) 77 | end 78 | 79 | it 'works with nested T::Hash' do 80 | expect( 81 | TypeCoerce[T::Hash[Symbol, T::Hash[Symbol, Integer]]].new.from({ 82 | a: nil, 83 | b: {c: '1'} 84 | }) 85 | ).to eql({a: {}, b: {c: 1}}) 86 | end 87 | end 88 | end 89 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/safe_type.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi gems 3 | 4 | # typed: strict 5 | # 6 | # If you would like to make changes to this file, great! Please create the gem's shim here: 7 | # 8 | # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/safe_type/all/safe_type.rbi 9 | # 10 | # safe_type-1.1.1 11 | 12 | module SafeType 13 | def self.coerce!(input, rule); end 14 | def self.coerce(input, rule, coerce_key = nil); end 15 | end 16 | class SafeType::Converter 17 | def self.to_bool(input); end 18 | def self.to_date(input); end 19 | def self.to_date_time(input); end 20 | def self.to_false(input); end 21 | def self.to_float(input); end 22 | def self.to_int(input); end 23 | def self.to_time(input); end 24 | def self.to_true(input); end 25 | def self.to_type(input, type); end 26 | end 27 | class SafeType::CoercionError < StandardError 28 | def desired_type; end 29 | def initialize(value, desired_type, key = nil); end 30 | def key; end 31 | def value; end 32 | end 33 | class SafeType::ValidationError < StandardError 34 | def desired_type; end 35 | def initialize(value, desired_type, key = nil); end 36 | def key; end 37 | def value; end 38 | end 39 | class SafeType::EmptyValueError < StandardError 40 | def desired_type; end 41 | def initialize(desired_type, key = nil); end 42 | def key; end 43 | end 44 | class SafeType::InvalidRuleError < ArgumentError 45 | def initialize; end 46 | end 47 | class SafeType::Rule 48 | def after(input); end 49 | def before(input); end 50 | def coerce(input, key = nil); end 51 | def initialize(type:, default: nil, required: nil, **args); end 52 | def is_valid?(input); end 53 | def self.coerce(input); end 54 | def self.default; end 55 | def self.strict; end 56 | end 57 | module SafeType::BooleanMixin 58 | end 59 | class TrueClass 60 | include SafeType::BooleanMixin 61 | end 62 | class FalseClass 63 | include SafeType::BooleanMixin 64 | end 65 | class SafeType::Boolean < SafeType::Rule 66 | def initialize(type: nil, **args); end 67 | def self.default(value = nil); end 68 | end 69 | class SafeType::Date < SafeType::Rule 70 | def initialize(type: nil, from: nil, to: nil, **args); end 71 | def is_valid?(input); end 72 | def self.default(value = nil, from: nil, to: nil); end 73 | def self.strict(from: nil, to: nil); end 74 | end 75 | class SafeType::DateTime < SafeType::Rule 76 | def initialize(type: nil, from: nil, to: nil, **args); end 77 | def is_valid?(input); end 78 | def self.default(value = nil, from: nil, to: nil); end 79 | def self.strict(from: nil, to: nil); end 80 | end 81 | class SafeType::Float < SafeType::Rule 82 | def initialize(type: nil, min: nil, max: nil, **args); end 83 | def is_valid?(input); end 84 | def self.default(value = nil, min: nil, max: nil); end 85 | def self.strict(min: nil, max: nil); end 86 | end 87 | class SafeType::Integer < SafeType::Rule 88 | def initialize(type: nil, min: nil, max: nil, **args); end 89 | def is_valid?(input); end 90 | def self.default(value = nil, min: nil, max: nil); end 91 | def self.strict(min: nil, max: nil); end 92 | end 93 | class SafeType::String < SafeType::Rule 94 | def after(input); end 95 | def initialize(type: nil, min_length: nil, max_length: nil, **args); end 96 | def is_valid?(input); end 97 | def self.default(value = nil, min_length: nil, max_length: nil); end 98 | def self.strict(min_length: nil, max_length: nil); end 99 | end 100 | class SafeType::Symbol < SafeType::Rule 101 | def after(input); end 102 | def initialize(type: nil, min_length: nil, max_length: nil, **args); end 103 | def is_valid?(input); end 104 | def self.default(value = nil, min_length: nil, max_length: nil); end 105 | def self.strict(min_length: nil, max_length: nil); end 106 | end 107 | class SafeType::Time < SafeType::Rule 108 | def initialize(type: nil, from: nil, to: nil, **args); end 109 | def is_valid?(input); end 110 | def self.default(value = nil, from: nil, to: nil); end 111 | def self.strict(from: nil, to: nil); end 112 | end 113 | -------------------------------------------------------------------------------- /lib/sorbet-coerce/converter.rb: -------------------------------------------------------------------------------- 1 | # typed: ignore 2 | require 'polyfill' 3 | require 'safe_type' 4 | require 'set' 5 | require 'sorbet-runtime' 6 | require 'sorbet-coerce/configuration' 7 | 8 | using Polyfill(Hash: %w[#slice]) 9 | 10 | module TypeCoerce 11 | class CoercionError < SafeType::CoercionError; end 12 | class ShapeError < SafeType::CoercionError; end 13 | end 14 | 15 | class TypeCoerce::Converter 16 | def initialize(type) 17 | @type = type 18 | end 19 | 20 | def new 21 | self 22 | end 23 | 24 | def to_s 25 | "#{name}#[#{@type.to_s}]" 26 | end 27 | 28 | def from(args, raise_coercion_error: nil, coerce_empty_to_nil: false) 29 | if raise_coercion_error.nil? 30 | raise_coercion_error = TypeCoerce::Configuration.raise_coercion_error 31 | end 32 | 33 | T.let(_convert(args, @type, raise_coercion_error, coerce_empty_to_nil), @type) 34 | end 35 | 36 | private 37 | 38 | PRIMITIVE_TYPES = T.let(::Set[ 39 | Date, 40 | DateTime, 41 | Float, 42 | Integer, 43 | String, 44 | Symbol, 45 | Time, 46 | ], T.untyped) 47 | 48 | def _convert(value, type, raise_coercion_error, coerce_empty_to_nil) 49 | if type.is_a?(T::Types::Untyped) 50 | value 51 | elsif type.is_a?(T::Types::ClassOf) 52 | value 53 | elsif type.is_a?(T::Types::TypedArray) 54 | _convert_to_a(value, type.type, raise_coercion_error, coerce_empty_to_nil) 55 | elsif type.is_a?(T::Types::FixedArray) 56 | _convert_to_a(value, type.types, raise_coercion_error, coerce_empty_to_nil) 57 | elsif type.is_a?(T::Types::TypedSet) 58 | Set.new(_convert_to_a(value, type.type, raise_coercion_error, coerce_empty_to_nil)) 59 | elsif type.is_a?(T::Types::Simple) 60 | _convert(value, type.raw_type, raise_coercion_error, coerce_empty_to_nil) 61 | elsif type.is_a?(T::Types::Union) 62 | true_idx = T.let(nil, T.nilable(Integer)) 63 | false_idx = T.let(nil, T.nilable(Integer)) 64 | nil_idx = T.let(nil, T.nilable(Integer)) 65 | 66 | type.types.each_with_index do |t, i| 67 | nil_idx = i if t.is_a?(T::Types::Simple) && t.raw_type == NilClass 68 | true_idx = i if t.is_a?(T::Types::Simple) && t.raw_type == TrueClass 69 | false_idx = i if t.is_a?(T::Types::Simple) && t.raw_type == FalseClass 70 | end 71 | 72 | return value unless ( 73 | (!true_idx.nil? && !false_idx.nil? && !nil_idx.nil?) || # T.nilable(T::Boolean) 74 | (type.types.length == 2 && ( 75 | !nil_idx.nil? || (!true_idx.nil? && !false_idx.nil?) # T.nilable || T::Boolean 76 | )) 77 | ) 78 | 79 | if !true_idx.nil? && !false_idx.nil? 80 | _convert_simple(value, T::Boolean, raise_coercion_error, coerce_empty_to_nil) 81 | else 82 | _convert(value, type.types[nil_idx == 0 ? 1 : 0], raise_coercion_error, coerce_empty_to_nil) 83 | end 84 | elsif type.is_a?(T::Types::TypedHash) 85 | return {} if _nil_like?(value, type, coerce_empty_to_nil) 86 | 87 | unless value.respond_to?(:map) 88 | raise TypeCoerce::ShapeError.new(value, type) 89 | end 90 | 91 | value.map do |k, v| 92 | [ 93 | _convert(k, type.keys, raise_coercion_error, coerce_empty_to_nil), 94 | _convert(v, type.values, raise_coercion_error, coerce_empty_to_nil), 95 | ] 96 | end.to_h 97 | elsif Object.const_defined?('T::Private::Types::TypeAlias') && 98 | type.is_a?(T::Private::Types::TypeAlias) 99 | _convert(value, type.aliased_type, raise_coercion_error, coerce_empty_to_nil) 100 | elsif type.is_a?(Class) || type.is_a?(Module) 101 | return coerce_nil(value, type, coerce_empty_to_nil) if value.is_a?(type) 102 | 103 | if type < T::Struct 104 | args = _build_args(value, type, raise_coercion_error, coerce_empty_to_nil) 105 | type.new(args) 106 | elsif type < T::Enum 107 | _convert_enum(value, type, raise_coercion_error, coerce_empty_to_nil) 108 | else 109 | _convert_simple(value, type, raise_coercion_error, coerce_empty_to_nil) 110 | end 111 | else 112 | if raise_coercion_error 113 | raise TypeCoerce::CoercionError.new(value, type) 114 | else 115 | value 116 | end 117 | end 118 | end 119 | 120 | def _convert_enum(value, type, raise_coercion_error, coerce_empty_to_nil) 121 | if raise_coercion_error 122 | type.deserialize(value) 123 | else 124 | type.try_deserialize(value) 125 | end 126 | rescue KeyError 127 | raise TypeCoerce::CoercionError.new(value, type) 128 | end 129 | 130 | def _convert_simple(value, type, raise_coercion_error, coerce_empty_to_nil) 131 | return nil if _nil_like?(value, type, coerce_empty_to_nil) 132 | 133 | safe_type_rule = T.let(nil, T.untyped) 134 | 135 | if type == T::Boolean 136 | safe_type_rule = SafeType::Boolean.strict 137 | elsif value.is_a?(type) 138 | return value 139 | elsif type == BigDecimal 140 | return BigDecimal(value) 141 | elsif PRIMITIVE_TYPES.include?(type) 142 | safe_type_rule = SafeType.const_get(type.name).strict 143 | else 144 | safe_type_rule = type 145 | end 146 | 147 | if safe_type_rule.is_a?(SafeType::Rule) 148 | SafeType::coerce(value, safe_type_rule) 149 | else 150 | type.new(value) 151 | end 152 | rescue SafeType::EmptyValueError, SafeType::CoercionError 153 | if raise_coercion_error 154 | raise TypeCoerce::CoercionError.new(value, type) 155 | else 156 | nil 157 | end 158 | end 159 | 160 | def _convert_to_a(ary, type, raise_coercion_error, coerce_empty_to_nil) 161 | return [] if _nil_like?(ary, type, coerce_empty_to_nil) 162 | 163 | unless ary.respond_to?(:map) 164 | raise TypeCoerce::ShapeError.new(ary, type) 165 | end 166 | 167 | ary.map.with_index do |value, i| 168 | if type.is_a?(Array) 169 | _convert(value, type[i], raise_coercion_error, coerce_empty_to_nil) 170 | else 171 | _convert(value, type, raise_coercion_error, coerce_empty_to_nil) 172 | end 173 | end 174 | end 175 | 176 | def _build_args(args, type, raise_coercion_error, coerce_empty_to_nil) 177 | return {} if _nil_like?(args, Hash, coerce_empty_to_nil) 178 | 179 | unless args.respond_to?(:each_pair) 180 | raise TypeCoerce::ShapeError.new(args, type) 181 | end 182 | 183 | props = type.props 184 | args.map { |name, value| 185 | key = name.to_sym 186 | [ 187 | key, 188 | (!props.include?(key) || value.nil?) ? 189 | nil : _convert(value, props[key][:type], raise_coercion_error, coerce_empty_to_nil), 190 | ] 191 | }.to_h.slice(*props.keys) 192 | end 193 | 194 | def _nil_like?(value, type, coerce_empty_to_nil) 195 | return true if value.nil? 196 | return true if value == '' && coerce_empty_to_nil 197 | return true if value == '' && type != String 198 | 199 | false 200 | end 201 | 202 | def coerce_nil(value, type, coerce_empty_to_nil) 203 | return nil if _nil_like?(value, type, coerce_empty_to_nil) 204 | 205 | value 206 | end 207 | end 208 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sorbet-coerce 2 | [![Gem Version](https://badge.fury.io/rb/sorbet-coerce.svg)](https://badge.fury.io/rb/sorbet-coerce) 3 | [![GitHub Action: CI](https://github.com/chanzuckerberg/sorbet-coerce/actions/workflows/ci.yml/badge.svg)](https://github.com/chanzuckerberg/sorbet-coerce/actions/workflows/ci.yml) 4 | [![codecov](https://codecov.io/gh/chanzuckerberg/sorbet-coerce/branch/master/graph/badge.svg)](https://codecov.io/gh/chanzuckerberg/sorbet-coerce) 5 | 6 | A type coercion lib works with [Sorbet](https://sorbet.org)'s static type checker and type definitions; raises an error if the coercion fails. 7 | 8 | It provides a simple and generic way of coercing types in a sorbet-typed project. It is particularly useful when we're dealing with external API responses and controller parameters. 9 | 10 | ## Installation 11 | 1. Follow the steps [here](https://sorbet.org/docs/adopting) to set up the latest version of Sorbet and run `srb tc`. 12 | 2. Add `sorbet-coerce` to your Gemfile and install them with `Bundler`. 13 | ```ruby 14 | # -- Gemfile -- 15 | 16 | gem 'sorbet-coerce' 17 | ``` 18 | 19 | ```sh 20 | ❯ bundle install 21 | ``` 22 | 23 | ## Usage 24 | 25 | `TypeCoerce` takes a valid sorbet type and coerce the input value into that type. It'll return a statically-typed object or throws errors when the coercion process cannot be handled as expected (more details in the [Errors](#errors) section). 26 | ```ruby 27 | converted = TypeCoerce[].new.from() 28 | 29 | T.reveal_type(converted) # 30 | ``` 31 | 32 | ### Supported Types 33 | - Simple Types 34 | - Custom Types: If the values can be coerced by `.new` 35 | - `T.untyped` (an escape hatch to ignore & return the given value) 36 | - `T::Boolean` 37 | - `T::Enum` 38 | - `T.nilable()` 39 | - `T::Array[]` 40 | - `T::Hash[, ]` 41 | - `T::Set[]` 42 | - `T.any(, ...)` 43 | - Subclasses of `T::Struct` 44 | 45 | We don't support 46 | - Experimental features (tuples and shapes) 47 | - passing in variables *as* types (ex `TypeCoerce[var]`) - please use at your own risk! 48 | - for more information, see [this Slack thread in the Sorbet Slack](https://sorbet-ruby.slack.com/archives/CHN2L03NH/p1658784723127889) 49 | 50 | ### Examples 51 | - Simple Types 52 | 53 | ```ruby 54 | TypeCoerce[T::Boolean].new.from('false') 55 | # => false 56 | 57 | TypeCoerce[T::Boolean].new.from('true') 58 | # => true 59 | 60 | TypeCoerce[Date].new.from('2019-08-05') 61 | # => # 62 | 63 | TypeCoerce[DateTime].new.from('2019-08-05') 64 | # => # 65 | 66 | TypeCoerce[Float].new.from('1') 67 | # => 1.0 68 | 69 | TypeCoerce[Integer].new.from('1') 70 | # => 1 71 | 72 | TypeCoerce[String].new.from(1) 73 | # => "1" 74 | 75 | TypeCoerce[Symbol].new.from('a') 76 | # => :a 77 | 78 | TypeCoerce[Time].new.from('2019-08-05') 79 | # => 2019-08-05 00:00:00 -0700 80 | ``` 81 | 82 | - `T.nilable` 83 | 84 | ```ruby 85 | TypeCoerce[T.nilable(Integer)].new.from('') 86 | # => nil 87 | TypeCoerce[T.nilable(Integer)].new.from(nil) 88 | # => nil 89 | TypeCoerce[T.nilable(Integer)].new.from('') 90 | # => nil 91 | ``` 92 | 93 | The behaviour for converting `''` for the `T.nilable(String)` type depends on an option flag called `coerce_empty_to_nil` (new in [v0.6.0](https://github.com/chanzuckerberg/sorbet-coerce/releases/tag/v0.6.0)): 94 | 95 | ```ruby 96 | # default behaviour 97 | TypeCoerce[T.nilable(String)].new.from('') 98 | # => "" 99 | 100 | # using the coerce_empty_to_nil flag 101 | TypeCoerce[T.nilable(String)].new.from('', coerce_empty_to_nil: true) 102 | # => nil 103 | ``` 104 | 105 | - `T::Array` 106 | 107 | ```ruby 108 | TypeCoerce[T::Array[Integer]].new.from([1.0, '2.0']) 109 | # => [1, 2] 110 | ``` 111 | 112 | - `T::Struct` 113 | 114 | ```ruby 115 | class Params < T::Struct 116 | const :id, Integer 117 | const :role, String, default: 'wizard' 118 | end 119 | 120 | TypeCoerce[Params].new.from({id: '1'}) 121 | # => 122 | ``` 123 | More examples: [nested params](https://github.com/chanzuckerberg/sorbet-coerce/blob/ffe1bed4de11ca832d9f76a157349ea03bbf29a1/spec/nested_spec.rb#L18-L26) 124 | 125 | ## Errors 126 | We will get `CoercionError`, `ShapeError`, or `TypeError` when the coercion doesn't work successfully. 127 | 128 | #### `TypeCoerce::CoercionError` (configurable) 129 | It raises a coercion error when it fails to convert a value into the specified type (i.e. `'bad string args' to Integer`). This can be configured globally or at each call-site. When configured to `true`, it will fill the result with `nil` instead of raising the errors. 130 | ```ruby 131 | TypeCoerce::Configuration.raise_coercion_error = false # default to true 132 | ``` 133 | We can use an inline flag to overwrite the global configuration: 134 | ```ruby 135 | TypeCoerce[T.nilable(Integer)].new.from('abc', raise_coercion_error: false) 136 | # => nil 137 | ``` 138 | 139 | #### `TypeCoerce::ShapeError` (NOT configurable) 140 | It raises a shape error when the shape of the input does not match the shape of input type (i.e. `'1' to T::Array[Integer]` or to `T::Struct`). This cannot be configured and always raise an error. 141 | 142 | #### `TypeError` (configurable) 143 | It raises a type error when the coerced input does not match the input type. This error is raised by Sorbet and can be configured through [`T::Configuration`](https://sorbet.org/docs/tconfiguration). 144 | 145 | 146 | #### Soft Errors vs. Hard Errors 147 | In an environment where type errors and coercion errors are configured to be silent (referred to as soft errors), when the coercion fails, `TypeCoerce` will fill the result with `nil` instead of actually raising the errors (referred to hard errors). 148 | 149 | With hard errors, 150 | ```ruby 151 | class Params < T::Struct 152 | const :a, Integer 153 | end 154 | 155 | TypeCoerce[Integer].new.from(nil) 156 | # => TypeError Exception: T.let: Expected type Integer, got type NilClass 157 | 158 | TypeCoerce[Integer].new.from('abc') 159 | # => TypeCoerce::CoercionError Exception: Could not coerce value ("abc") of type (String) to desired type (Integer) 160 | 161 | TypeCoerce[T.nilable(Integer)].new.from('abc', raise_coercion_error: false) 162 | # => nil 163 | 164 | TypeCoerce[Params].new.from({a: 'abc'}, raise_coercion_error: false) 165 | # => TypeError Exception: Parameter 'a': Can't set Params.a to nil (instance of NilClass) - need a Integer 166 | ``` 167 | 168 | With soft errors, 169 | ```ruby 170 | TypeCoerce[Integer].new.from('abc', raise_coercion_error: false) 171 | # => nil 172 | 173 | TypeCoerce[Params].new.from({a: 'abc'}, raise_coercion_error: false) # require sorbet version ~> 0.4.4948 174 | # => 175 | 176 | TypeCoerce[Params].new.from({a: 'abc'}, raise_coercion_error: true) 177 | # TypeCoerce::CoercionError Exception: Could not coerce value ("abc") of type (String) to desired type (Integer) 178 | ``` 179 | 180 | ## `null`, `''`, and `undefined` 181 | 182 | Sorbet-coerce is designed in the context of web development. When coercing into a `T::Struct`, the values that need to be coerced are often JSON-like. Suppose we send a JavaScript object 183 | ```javascript 184 | json_js = {"a": "1", "null_field": null, "blank_field": "", "missing_key": undefined} // javascript 185 | ``` 186 | to the server side and get a JSON hash 187 | ```ruby 188 | json_rb = {"a" => "1", "null_field" => nil, "blank_field" => ""} # ruby, note `missing_key` is removed from the hash 189 | ``` 190 | We expect the object to have shape 191 | ```ruby 192 | class Params < T::Struct 193 | const :a, Integer 194 | const :null_field, T.nilable(Integer) 195 | const :blank_field, T.nilable(Integer) 196 | const :missing_key, T::Array[Integer], default: [] 197 | end 198 | ``` 199 | 200 | Then we coerce the object `json_rb` into an instance of `Params`. 201 | ```ruby 202 | params = TypeCoerce[Params].new.from(json_rb) 203 | # => 204 | ``` 205 | - When `json_js["null_field"]` is `null`, `params.null_field` is `nil` 206 | - When `json_js["blank_field"]` is `""`, `params.blank_field` is `nil` 207 | - When `json_js["missing_key"]` is `undefined`, `params.missing_key` will use the default value `[]` 208 | 209 | ## Contributing 210 | 211 | Contributions and ideas are welcome! Please see [our contributing guide](CONTRIBUTING.md) and don't hesitate to open an issue or send a pull request to improve the functionality of this gem. 212 | 213 | This project adheres to the Contributor Covenant [code of conduct](https://github.com/chanzuckerberg/.github/tree/master/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to opensource@chanzuckerberg.com. 214 | 215 | ## License 216 | 217 | This project is licensed under [MIT](https://github.com/chanzuckerberg/sorbet-coerce/blob/master/LICENSE). 218 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/polyfill.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi gems 3 | 4 | # typed: strict 5 | # 6 | # If you would like to make changes to this file, great! Please create the gem's shim here: 7 | # 8 | # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/polyfill/all/polyfill.rbi 9 | # 10 | # polyfill-1.9.0 11 | 12 | module Polyfill 13 | def get(module_name, methods, options = nil); end 14 | def self.get(module_name, methods, options = nil); end 15 | end 16 | module Polyfill::InternalUtils 17 | def create_module(*args); end 18 | def current_ruby_version; end 19 | def ignore_warnings; end 20 | def keep_only_these_methods!(mod, whitelist); end 21 | def methods_to_keep(modules, methods, lead_symbol, module_name); end 22 | def modules_to_use(module_name, versions); end 23 | def namify_arguments(*args); end 24 | def polyfill_versions_to_use(desired_version = nil); end 25 | def self.create_module(*args); end 26 | def self.current_ruby_version; end 27 | def self.ignore_warnings; end 28 | def self.keep_only_these_methods!(mod, whitelist); end 29 | def self.methods_to_keep(modules, methods, lead_symbol, module_name); end 30 | def self.modules_to_use(module_name, versions); end 31 | def self.namify_arguments(*args); end 32 | def self.polyfill_versions_to_use(desired_version = nil); end 33 | def self.to_f(obj); end 34 | def self.to_hash(obj); end 35 | def self.to_int(obj); end 36 | def self.to_str(obj); end 37 | def to_f(obj); end 38 | def to_hash(obj); end 39 | def to_int(obj); end 40 | def to_str(obj); end 41 | end 42 | module Polyfill::V2_2 43 | end 44 | module Polyfill::V2_2::Enumerable 45 | def max(n = nil); end 46 | def max_by(n = nil); end 47 | def min(n = nil); end 48 | def min_by(n = nil); end 49 | def slice_after(pattern = nil); end 50 | def slice_when; end 51 | end 52 | module Polyfill::V2_2::Kernel 53 | def itself; end 54 | end 55 | module Polyfill::V2_2::Math 56 | end 57 | module Polyfill::V2_2::Math::ClassMethods 58 | def log(*args); end 59 | end 60 | module Polyfill::V2_2::Prime 61 | end 62 | module Polyfill::V2_2::Prime::ClassMethods 63 | def prime?(*args); end 64 | end 65 | module Polyfill::V2_2::Vector 66 | def +@; end 67 | end 68 | module Polyfill::V2_3 69 | end 70 | module Polyfill::V2_3::Array 71 | def bsearch_index; end 72 | def dig(head, *rest); end 73 | end 74 | module Polyfill::V2_3::Hash 75 | def <(other); end 76 | def <=(other); end 77 | def >(other); end 78 | def >=(other); end 79 | def dig(head, *rest); end 80 | def fetch_values(*keys); end 81 | def to_proc; end 82 | end 83 | module Polyfill::V2_3::Enumerable 84 | def chunk_while; end 85 | def grep_v(pattern); end 86 | def slice_before(*args); end 87 | end 88 | module Polyfill::V2_3::Enumerator 89 | end 90 | module Polyfill::V2_3::Enumerator::Lazy 91 | def grep_v(pattern); end 92 | end 93 | module Polyfill::V2_3::Kernel 94 | def loop; end 95 | end 96 | module Polyfill::V2_3::Numeric 97 | def negative?; end 98 | def positive?; end 99 | end 100 | module Polyfill::V2_3::String 101 | def +@; end 102 | def -@; end 103 | end 104 | module Polyfill::V2_3::String::ClassMethods 105 | def new(*args); end 106 | end 107 | module Polyfill::V2_3::Struct 108 | def dig(head, *rest); end 109 | end 110 | module Polyfill::V2_3::Prime 111 | end 112 | module Polyfill::V2_3::Prime::ClassMethods 113 | def prime?(*args); end 114 | end 115 | module Polyfill::V2_4 116 | end 117 | module Polyfill::V2_4::Numeric 118 | def clone(freeze: nil); end 119 | def dup; end 120 | def finite?; end 121 | def infinite?; end 122 | end 123 | module Polyfill::V2_4::Enumerable 124 | def chunk(*arg0); end 125 | def sum(init = nil); end 126 | def uniq; end 127 | end 128 | module Polyfill::Module::MezpOdW1lcmljPT5bIiNkdXAiXSwgOnZlcnNpb249PiIyLjQifQ__ 129 | end 130 | module Polyfill::V2_4::Array 131 | def concat(*others); end 132 | def sum(init = nil); end 133 | end 134 | module Polyfill::V2_4::Comparable 135 | def clamp(min, max); end 136 | end 137 | module Polyfill::V2_4::Dir 138 | end 139 | module Polyfill::V2_4::Dir::ClassMethods 140 | def empty?(path_name); end 141 | end 142 | module Polyfill::V2_4::Enumerator 143 | end 144 | module Polyfill::V2_4::Enumerator::Lazy 145 | def chunk_while; end 146 | def uniq; end 147 | end 148 | module Polyfill::Module::MezpFbnVtZXJhYmxlPT5bIiNjaHVua193aGlsZSJdLCA6dmVyc2lvbj0_1IjIuNCJ9 149 | end 150 | module Polyfill::V2_4::File 151 | end 152 | module Polyfill::V2_4::File::ClassMethods 153 | def empty?(file_name); end 154 | end 155 | module Polyfill::V2_4::Float 156 | def ceil(ndigits = nil); end 157 | def floor(ndigits = nil); end 158 | def truncate(ndigits = nil); end 159 | end 160 | module Polyfill::V2_4::Hash 161 | def compact!; end 162 | def compact; end 163 | def transform_values!; end 164 | def transform_values; end 165 | end 166 | module Polyfill::V2_4::Integer 167 | def ceil(ndigits = nil); end 168 | def digits(base = nil); end 169 | def floor(ndigits = nil); end 170 | def round(ndigits = nil, half: nil); end 171 | def truncate(ndigits = nil); end 172 | end 173 | module Polyfill::V2_4::IO 174 | def each_line(*args); end 175 | def gets(*args); end 176 | def lines(*args); end 177 | def readline(*args); end 178 | def readlines(*args); end 179 | end 180 | module Polyfill::V2_4::IO::ClassMethods 181 | def foreach(name, *args); end 182 | def readlines(file_name, *args); end 183 | end 184 | module Polyfill::V2_4::MatchData 185 | def named_captures; end 186 | def values_at(*indexes); end 187 | end 188 | module Polyfill::V2_4::Object 189 | def clone(freeze: nil); end 190 | end 191 | module Polyfill::V2_4::Regexp 192 | def match?(string, position = nil); end 193 | end 194 | module Polyfill::V2_4::String 195 | def casecmp?(other); end 196 | def concat(*others); end 197 | def each_line(*args); end 198 | def lines(*args); end 199 | def match?(pattern, position = nil); end 200 | def prepend(*others); end 201 | def unpack1(*args); end 202 | end 203 | module Polyfill::V2_4::String::ClassMethods 204 | def new(*args); end 205 | end 206 | module Polyfill::V2_4::StringIO 207 | def each_line(*args); end 208 | def gets(*args); end 209 | def lines(*args); end 210 | def readline(*args); end 211 | def readlines(*args); end 212 | end 213 | module Polyfill::V2_4::StringIO::ClassMethods 214 | def foreach(name, *args); end 215 | def readlines(file_name, *args); end 216 | end 217 | module Polyfill::V2_4::Symbol 218 | def casecmp?(other); end 219 | def match(*args); end 220 | def match?(pattern, position = nil); end 221 | end 222 | module Polyfill::V2_4::IPAddr 223 | def <=>(*arg0); end 224 | def ==(*arg0); end 225 | end 226 | module Polyfill::V2_4::Pathname 227 | def empty?; end 228 | end 229 | module Polyfill::V2_5 230 | end 231 | module Polyfill::V2_5::Array 232 | def append(*args); end 233 | def prepend(*args); end 234 | end 235 | module Polyfill::V2_5::Dir 236 | end 237 | module Polyfill::V2_5::Dir::ClassMethods 238 | def children(dirname, encoding: nil); end 239 | def each_child(dirname, encoding: nil); end 240 | end 241 | module Polyfill::V2_5::Enumerable 242 | def all?(*pattern); end 243 | def any?(*pattern); end 244 | def none?(*pattern); end 245 | def one?(*pattern); end 246 | end 247 | module Polyfill::V2_5::Hash 248 | def slice(*keys); end 249 | def transform_keys; end 250 | end 251 | module Polyfill::V2_5::Integer 252 | def allbits?(mask); end 253 | def anybits?(mask); end 254 | def ceil(*arg0); end 255 | def floor(*arg0); end 256 | def nobits?(mask); end 257 | def round(*arg0); end 258 | def truncate(*arg0); end 259 | end 260 | module Polyfill::Module::MezpJbnRlZ2VyPT5bIiNjZWlsIiwgIiNmbG9vciIsICIjcm91bmQiLCAiI3RydW5jYXRlIl0sIDp2ZXJzaW9uPT4iMi40In0_ 261 | end 262 | module Polyfill::V2_5::Integer::ClassMethods 263 | def sqrt(n); end 264 | end 265 | module Polyfill::V2_5::Kernel 266 | def yield_self; end 267 | end 268 | module Polyfill::V2_5::String 269 | def casecmp(other_str); end 270 | def casecmp?(other_str); end 271 | def delete_prefix!(prefix); end 272 | def delete_prefix(prefix); end 273 | def delete_suffix!(suffix); end 274 | def delete_suffix(suffix); end 275 | def each_grapheme_cluster; end 276 | def grapheme_clusters; end 277 | def start_with?(*prefixes); end 278 | end 279 | module Polyfill::V2_5::Struct 280 | end 281 | module Polyfill::V2_5::Struct::ClassMethods 282 | def new(*args, keyword_init: nil); end 283 | end 284 | module Polyfill::V2_5::Time 285 | end 286 | module Polyfill::V2_5::Time::ClassMethods 287 | def at(*args); end 288 | end 289 | module Polyfill::V2_5::BigDecimal 290 | def clone; end 291 | def dup; end 292 | end 293 | module Polyfill::V2_5::Set 294 | def ===(other); end 295 | def to_s; end 296 | end 297 | module Polyfill::V2_6 298 | end 299 | module Polyfill::V2_6::Array 300 | def difference(*arrays); end 301 | def to_h; end 302 | def union(*arrays); end 303 | end 304 | module Polyfill::V2_6::Enumerable 305 | def to_h; end 306 | end 307 | module Polyfill::V2_6::Hash 308 | def merge!(*args); end 309 | def merge(*args); end 310 | def to_h; end 311 | def update(*args); end 312 | end 313 | module Polyfill::V2_6::Kernel 314 | def Complex(*args, exception: nil); end 315 | def Float(arg, exception: nil); end 316 | def Integer(arg, exception: nil); end 317 | def Rational(*args, exception: nil); end 318 | def then; end 319 | end 320 | module Polyfill::Module::MezpLZXJuZWw9PlsiI3lpZWxkX3NlbGYiXSwgOnZlcnNpb249PiIyLjUifQ__ 321 | end 322 | module Polyfill::V2_6::OpenStruct 323 | def to_h; end 324 | end 325 | module Polyfill::V2_6::String 326 | def split(*arg0); end 327 | end 328 | module Polyfill::V2_6::Struct 329 | def to_h; end 330 | end 331 | module Polyfill::Module 332 | end 333 | class Object < BasicObject 334 | def Polyfill(options = nil); end 335 | end 336 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/rspec-support.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi gems 3 | 4 | # typed: true 5 | # 6 | # If you would like to make changes to this file, great! Please create the gem's shim here: 7 | # 8 | # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/rspec-support/all/rspec-support.rbi 9 | # 10 | # rspec-support-3.11.0 11 | 12 | module RSpec 13 | extend RSpec::Support::Warnings 14 | end 15 | module RSpec::Support 16 | def self.class_of(object); end 17 | def self.define_optimized_require_for_rspec(lib, &require_relative); end 18 | def self.deregister_matcher_definition(&block); end 19 | def self.failure_notifier; end 20 | def self.failure_notifier=(callable); end 21 | def self.is_a_matcher?(object); end 22 | def self.matcher_definitions; end 23 | def self.method_handle_for(object, method_name); end 24 | def self.notify_failure(failure, options = nil); end 25 | def self.register_matcher_definition(&block); end 26 | def self.require_rspec_support(f); end 27 | def self.rspec_description_for_object(object); end 28 | def self.thread_local_data; end 29 | def self.warning_notifier; end 30 | def self.warning_notifier=(arg0); end 31 | def self.with_failure_notifier(callable); end 32 | end 33 | module RSpec::Support::Version 34 | end 35 | class RSpec::Support::ComparableVersion 36 | def <=>(other); end 37 | def initialize(string); end 38 | def segments; end 39 | def string; end 40 | include Comparable 41 | end 42 | module RSpec::Support::OS 43 | def self.windows?; end 44 | def self.windows_file_path?; end 45 | def windows?; end 46 | def windows_file_path?; end 47 | end 48 | module RSpec::Support::Ruby 49 | def jruby?; end 50 | def jruby_9000?; end 51 | def jruby_version; end 52 | def mri?; end 53 | def non_mri?; end 54 | def rbx?; end 55 | def self.jruby?; end 56 | def self.jruby_9000?; end 57 | def self.jruby_version; end 58 | def self.mri?; end 59 | def self.non_mri?; end 60 | def self.rbx?; end 61 | def self.truffleruby?; end 62 | def truffleruby?; end 63 | end 64 | module RSpec::Support::RubyFeatures 65 | def caller_locations_supported?; end 66 | def fork_supported?; end 67 | def kw_args_supported?; end 68 | def module_prepends_supported?; end 69 | def module_refinement_supported?; end 70 | def optional_and_splat_args_supported?; end 71 | def required_kw_args_supported?; end 72 | def ripper_supported?; end 73 | def self.caller_locations_supported?; end 74 | def self.fork_supported?; end 75 | def self.kw_args_supported?; end 76 | def self.module_prepends_supported?; end 77 | def self.module_refinement_supported?; end 78 | def self.optional_and_splat_args_supported?; end 79 | def self.required_kw_args_supported?; end 80 | def self.ripper_supported?; end 81 | def self.supports_exception_cause?; end 82 | def self.supports_rebinding_module_methods?; end 83 | def self.supports_taint?; end 84 | def supports_exception_cause?; end 85 | def supports_rebinding_module_methods?; end 86 | def supports_taint?; end 87 | end 88 | module RSpec::Support::AllExceptionsExceptOnesWeMustNotRescue 89 | def self.===(exception); end 90 | end 91 | class RSpec::CallerFilter 92 | def self.first_non_rspec_line(skip_frames = nil, increment = nil); end 93 | end 94 | module RSpec::Support::Warnings 95 | def deprecate(deprecated, options = nil); end 96 | def warn_deprecation(message, options = nil); end 97 | def warn_with(message, options = nil); end 98 | def warning(text, options = nil); end 99 | end 100 | class RSpec::Support::EncodedString 101 | def <<(string); end 102 | def ==(*args, &block); end 103 | def detect_source_encoding(string); end 104 | def empty?(*args, &block); end 105 | def encoding(*args, &block); end 106 | def eql?(*args, &block); end 107 | def initialize(string, encoding = nil); end 108 | def lines(*args, &block); end 109 | def matching_encoding(string); end 110 | def remove_invalid_bytes(string); end 111 | def self.pick_encoding(source_a, source_b); end 112 | def source_encoding; end 113 | def split(regex_or_string); end 114 | def to_s; end 115 | def to_str; end 116 | end 117 | class RSpec::Support::ReentrantMutex 118 | def enter; end 119 | def exit; end 120 | def initialize; end 121 | def synchronize; end 122 | end 123 | class RSpec::Support::Mutex < Thread::Mutex 124 | def self.new; end 125 | end 126 | class RSpec::Support::DirectoryMaker 127 | def self.directory_exists?(dirname); end 128 | def self.generate_path(stack, part); end 129 | def self.generate_stack(path); end 130 | def self.mkdir_p(path); end 131 | end 132 | class RSpec::Support::MethodSignature 133 | def arbitrary_kw_args?; end 134 | def classify_arity(arity = nil); end 135 | def classify_parameters; end 136 | def could_contain_kw_args?(args); end 137 | def description; end 138 | def has_kw_args_in?(args); end 139 | def initialize(method); end 140 | def invalid_kw_args_from(given_kw_args); end 141 | def max_non_kw_args; end 142 | def min_non_kw_args; end 143 | def missing_kw_args_from(given_kw_args); end 144 | def non_kw_args_arity_description; end 145 | def optional_kw_args; end 146 | def required_kw_args; end 147 | def unlimited_args?; end 148 | def valid_non_kw_args?(positional_arg_count, optional_max_arg_count = nil); end 149 | end 150 | class RSpec::Support::MethodSignatureExpectation 151 | def empty?; end 152 | def expect_arbitrary_keywords; end 153 | def expect_arbitrary_keywords=(arg0); end 154 | def expect_unlimited_arguments; end 155 | def expect_unlimited_arguments=(arg0); end 156 | def initialize; end 157 | def keywords; end 158 | def keywords=(values); end 159 | def max_count; end 160 | def max_count=(number); end 161 | def min_count; end 162 | def min_count=(number); end 163 | end 164 | class RSpec::Support::BlockSignature < RSpec::Support::MethodSignature 165 | def classify_parameters; end 166 | end 167 | class RSpec::Support::MethodSignatureVerifier 168 | def arbitrary_kw_args?; end 169 | def error_message; end 170 | def initialize(signature, args = nil); end 171 | def invalid_kw_args; end 172 | def kw_args; end 173 | def max_non_kw_args; end 174 | def min_non_kw_args; end 175 | def missing_kw_args; end 176 | def non_kw_args; end 177 | def split_args(*args); end 178 | def unlimited_args?; end 179 | def valid?; end 180 | def valid_non_kw_args?; end 181 | def with_expectation(expectation); end 182 | end 183 | class RSpec::Support::LooseSignatureVerifier < RSpec::Support::MethodSignatureVerifier 184 | def split_args(*args); end 185 | end 186 | class RSpec::Support::LooseSignatureVerifier::SignatureWithKeywordArgumentsMatcher 187 | def has_kw_args_in?(args); end 188 | def initialize(signature); end 189 | def invalid_kw_args_from(_kw_args); end 190 | def missing_kw_args_from(_kw_args); end 191 | def non_kw_args_arity_description; end 192 | def valid_non_kw_args?(*args); end 193 | end 194 | module RSpec::Support::WithKeywordsWhenNeeded 195 | def class_exec(klass, *args, &block); end 196 | def self.class_exec(klass, *args, &block); end 197 | end 198 | module RSpec::Support::RecursiveConstMethods 199 | def const_defined_on?(mod, const_name); end 200 | def constants_defined_on(mod); end 201 | def get_const_defined_on(mod, const_name); end 202 | def normalize_const_name(const_name); end 203 | def recursive_const_defined?(const_name); end 204 | def recursive_const_get(const_name); end 205 | end 206 | class RSpec::Support::ObjectFormatter 207 | def format(object); end 208 | def initialize(max_formatted_output_length = nil); end 209 | def max_formatted_output_length; end 210 | def max_formatted_output_length=(arg0); end 211 | def prepare_array(array); end 212 | def prepare_element(element); end 213 | def prepare_for_inspection(object); end 214 | def prepare_hash(input_hash); end 215 | def recursive_structure?(object); end 216 | def self.default_instance; end 217 | def self.format(object); end 218 | def self.prepare_for_inspection(object); end 219 | def sort_hash_keys(input_hash); end 220 | def truncate_string(str, start_index, end_index); end 221 | def with_entering_structure(structure); end 222 | end 223 | class RSpec::Support::ObjectFormatter::InspectableItem < Struct 224 | def inspect; end 225 | def pretty_print(pp); end 226 | def self.[](*arg0); end 227 | def self.inspect; end 228 | def self.members; end 229 | def self.new(*arg0); end 230 | def text; end 231 | def text=(_); end 232 | end 233 | class RSpec::Support::ObjectFormatter::BaseInspector < Struct 234 | def formatter; end 235 | def formatter=(_); end 236 | def inspect; end 237 | def object; end 238 | def object=(_); end 239 | def pretty_print(pp); end 240 | def self.[](*arg0); end 241 | def self.can_inspect?(_object); end 242 | def self.inspect; end 243 | def self.members; end 244 | def self.new(*arg0); end 245 | end 246 | class RSpec::Support::ObjectFormatter::TimeInspector < RSpec::Support::ObjectFormatter::BaseInspector 247 | def inspect; end 248 | def self.can_inspect?(object); end 249 | end 250 | class RSpec::Support::ObjectFormatter::DateTimeInspector < RSpec::Support::ObjectFormatter::BaseInspector 251 | def inspect; end 252 | def self.can_inspect?(object); end 253 | end 254 | class RSpec::Support::ObjectFormatter::BigDecimalInspector < RSpec::Support::ObjectFormatter::BaseInspector 255 | def inspect; end 256 | def self.can_inspect?(object); end 257 | end 258 | class RSpec::Support::ObjectFormatter::DescribableMatcherInspector < RSpec::Support::ObjectFormatter::BaseInspector 259 | def inspect; end 260 | def self.can_inspect?(object); end 261 | end 262 | class RSpec::Support::ObjectFormatter::UninspectableObjectInspector < RSpec::Support::ObjectFormatter::BaseInspector 263 | def inspect; end 264 | def klass; end 265 | def native_object_id; end 266 | def self.can_inspect?(object); end 267 | end 268 | class RSpec::Support::ObjectFormatter::DelegatorInspector < RSpec::Support::ObjectFormatter::BaseInspector 269 | def inspect; end 270 | def self.can_inspect?(object); end 271 | end 272 | class RSpec::Support::ObjectFormatter::InspectableObjectInspector < RSpec::Support::ObjectFormatter::BaseInspector 273 | def inspect; end 274 | def self.can_inspect?(object); end 275 | end 276 | module RSpec::Support::FuzzyMatcher 277 | def self.arrays_match?(expected_list, actual_list); end 278 | def self.hashes_match?(expected_hash, actual_hash); end 279 | def self.values_match?(expected, actual); end 280 | end 281 | -------------------------------------------------------------------------------- /spec/coerce_spec.rb: -------------------------------------------------------------------------------- 1 | # typed: ignore 2 | require 'sorbet-coerce' 3 | require 'sorbet-runtime' 4 | 5 | describe TypeCoerce do 6 | context 'when given T::Struct' do 7 | class ParamInfo < T::Struct 8 | const :name, String 9 | const :lvl, T.nilable(Integer) 10 | const :skill_ids, T::Array[Integer] 11 | end 12 | 13 | class ParamInfo2 < T::Struct 14 | const :a, Integer 15 | const :b, Integer 16 | const :notes, T::Array[String], default: [] 17 | end 18 | 19 | class Param < T::Struct 20 | const :id, Integer 21 | const :role, String, default: 'wizard' 22 | const :price, BigDecimal 23 | const :info, ParamInfo 24 | const :opt, T.nilable(ParamInfo2) 25 | end 26 | 27 | class DefaultParams < T::Struct 28 | const :a, Integer, default: 1 29 | end 30 | 31 | class HashParams < T::Struct 32 | const :myhash, T::Hash[String, Integer] 33 | end 34 | 35 | class HashParamsWithDefault < T::Struct 36 | const :myhash, T::Hash[String, Integer], default: Hash['a' => 1] 37 | end 38 | 39 | class TestEnum < T::Enum 40 | enums do 41 | Test = new 42 | Other = new 43 | end 44 | end 45 | 46 | class WithEnum < T::Struct 47 | const :myenum, TestEnum 48 | end 49 | 50 | class WithNilableString < T::Struct 51 | const :myvalue, T.nilable(String) 52 | end 53 | 54 | class WithNilableInteger < T::Struct 55 | const :myvalue, T.nilable(Integer) 56 | end 57 | 58 | class CustomType 59 | attr_reader :a 60 | 61 | def initialize(a) 62 | @a = a 63 | end 64 | end 65 | 66 | class CustomType2 67 | def self.new(a); 1; end 68 | end 69 | 70 | class UnsupportedCustomType 71 | # Does not respond to new 72 | end 73 | 74 | class WithSupportedUnion < T::Struct 75 | const :nilable, T.nilable(String) 76 | const :nilable_boolean, T.nilable(T::Boolean) 77 | end 78 | 79 | class WithUnsupportedUnion < T::Struct 80 | const :union, T.any(String, Integer) 81 | end 82 | 83 | class WithFixedArray < T::Struct 84 | const :arr, [Integer, String, Integer] 85 | end 86 | 87 | class CustomString < String 88 | end 89 | 90 | let!(:param) { 91 | TypeCoerce[Param].new.from({ 92 | id: 1, 93 | price: BigDecimal('98.76'), 94 | info: { 95 | name: 'mango', 96 | lvl: 100, 97 | skill_ids: ['123', '456'], 98 | }, 99 | opt: { 100 | a: 1, 101 | b: 2, 102 | }, 103 | extra_attr: 'does not matter', 104 | }) 105 | } 106 | 107 | let!(:param2) { 108 | TypeCoerce[Param].new.from({ 109 | id: '2', 110 | price: '98.76', 111 | info: { 112 | name: 'honeydew', 113 | lvl: '5', 114 | skill_ids: [], 115 | }, 116 | opt: { 117 | a: '1', 118 | b: '2', 119 | notes: [], 120 | }, 121 | }) 122 | } 123 | 124 | it 'reveals the right type' do 125 | T.assert_type!(param, Param) 126 | T.assert_type!(param.id, Integer) 127 | T.assert_type!(param.price, BigDecimal) 128 | T.assert_type!(param.info, ParamInfo) 129 | T.assert_type!(param.info.name,String) 130 | T.assert_type!(param.info.lvl, Integer) 131 | T.assert_type!(param.opt, T.nilable(ParamInfo2)) 132 | end 133 | 134 | it 'coerces correctly' do 135 | expect(param.id).to eql 1 136 | expect(param.role).to eql 'wizard' 137 | expect(param.price).to eql BigDecimal('98.76') 138 | expect(param.info.lvl).to eql 100 139 | expect(param.info.name).to eql 'mango' 140 | expect(param.info.skill_ids).to eql [123, 456] 141 | expect(param.opt.notes).to eql [] 142 | expect(TypeCoerce[Param].new.from(param)).to eq(param) 143 | 144 | expect(param2.id).to eql 2 145 | expect(param2.price).to eql BigDecimal('98.76') 146 | expect(param2.info.name).to eql 'honeydew' 147 | expect(param2.info.lvl).to eql 5 148 | expect(param2.info.skill_ids).to eql [] 149 | expect(param2.opt.a).to eql 1 150 | expect(param2.opt.b).to eql 2 151 | expect(param2.opt.notes).to eql [] 152 | 153 | expect { 154 | TypeCoerce[Param].new.from({ 155 | id: 3, 156 | info: { 157 | # missing required name 158 | lvl: 2, 159 | }, 160 | }) 161 | }.to raise_error(ArgumentError) 162 | 163 | expect(TypeCoerce[DefaultParams].new.from(nil).a).to be 1 164 | expect(TypeCoerce[DefaultParams].new.from('').a).to be 1 165 | end 166 | end 167 | 168 | context 'when the given T::Struct is invalid' do 169 | class Param2 < T::Struct 170 | const :id, Integer 171 | const :param, Param 172 | end 173 | 174 | it 'raises an error' do 175 | expect { 176 | TypeCoerce[Param2].new.from({id: 1, info: {}}) 177 | }.to raise_error(ArgumentError) 178 | end 179 | end 180 | 181 | context 'when given primitive types' do 182 | it 'reveals the right type' do 183 | T.assert_type!(TypeCoerce[Integer].new.from(1), Integer) 184 | T.assert_type!(TypeCoerce[Integer].new.from('1.0'), Integer) 185 | T.assert_type!(TypeCoerce[T.nilable(Integer)].new.from(nil), T.nilable(Integer)) 186 | end 187 | 188 | it 'coreces correctly' do 189 | expect{TypeCoerce[Integer].new.from(nil)}.to raise_error(TypeError) 190 | expect(TypeCoerce[T.nilable(Integer)].new.from(nil) || 1).to eql 1 191 | expect(TypeCoerce[Integer].new.from(2)).to eql 2 192 | expect(TypeCoerce[Integer].new.from('1.0')).to eql 1 193 | 194 | expect{TypeCoerce[T.nilable(Integer)].new.from('invalid integer string')}.to raise_error(TypeCoerce::CoercionError) 195 | expect(TypeCoerce[Float].new.from('1.0')).to eql 1.0 196 | 197 | expect(TypeCoerce[T::Boolean].new.from('false')).to be false 198 | expect(TypeCoerce[T::Boolean].new.from('true')).to be true 199 | 200 | expect(TypeCoerce[T.nilable(Integer)].new.from('')).to be nil 201 | expect{TypeCoerce[T.nilable(Integer)].new.from([])}.to raise_error(TypeCoerce::CoercionError) 202 | expect(TypeCoerce[T.nilable(String)].new.from('')).to eql '' 203 | end 204 | end 205 | 206 | context 'when given custom types' do 207 | it 'coerces correctly' do 208 | obj = TypeCoerce[CustomType].new.from(1) 209 | T.assert_type!(obj, CustomType) 210 | expect(obj.a).to be 1 211 | expect(TypeCoerce[CustomType].new.from(obj)).to be obj 212 | 213 | expect{TypeCoerce[UnsupportedCustomType].new.from(1)}.to raise_error(ArgumentError) 214 | # CustomType2.new(anything) returns Integer 1; 1.is_a?(CustomType2) == false 215 | expect{TypeCoerce[CustomType2].new.from(1)}.to raise_error(TypeError) 216 | end 217 | end 218 | 219 | context 'when given union types' do 220 | context 'supported union types' do 221 | it 'coerces correctly' do 222 | coerced = TypeCoerce[WithSupportedUnion].new.from({ 223 | nilable: 2, 224 | nilable_boolean: 'true' 225 | }) 226 | expect(coerced.nilable).to eq('2') 227 | expect(coerced.nilable_boolean).to eq(true) 228 | end 229 | end 230 | 231 | context 'unsupported union types' do 232 | it 'keeps the values as-is' do 233 | coerced = TypeCoerce[WithUnsupportedUnion].new.from({union: 'a'}) 234 | expect(coerced.union).to eq('a') 235 | 236 | coerced = TypeCoerce[WithUnsupportedUnion].new.from({union: 2}) 237 | expect(coerced.union).to eq(2) 238 | 239 | expect do 240 | TypeCoerce[WithUnsupportedUnion].new.from({union: nil}) 241 | end.to raise_error(TypeError) 242 | end 243 | end 244 | end 245 | 246 | context 'when dealing with arrays' do 247 | it 'coreces correctly' do 248 | expect(TypeCoerce[T::Array[Integer]].new.from(nil)).to eql [] 249 | expect(TypeCoerce[T::Array[Integer]].new.from('')).to eql [] 250 | expect{TypeCoerce[T::Array[Integer]].new.from('not an array')}.to raise_error(TypeCoerce::ShapeError) 251 | expect{TypeCoerce[T::Array[Integer]].new.from('1')}.to raise_error(TypeCoerce::ShapeError) 252 | expect(TypeCoerce[T::Array[Integer]].new.from(['1', '2', '3'])).to eql [1, 2, 3] 253 | expect{TypeCoerce[T::Array[Integer]].new.from(['1', 'invalid', '3'])}.to raise_error(TypeCoerce::CoercionError) 254 | expect{TypeCoerce[T::Array[Integer]].new.from({a: 1})}.to raise_error(TypeCoerce::CoercionError) 255 | 256 | infos = TypeCoerce[T::Array[ParamInfo]].new.from([{name: 'a', skill_ids: []}]) 257 | T.assert_type!(infos, T::Array[ParamInfo]) 258 | expect(infos.first.name).to eql 'a' 259 | 260 | infos = TypeCoerce[T::Array[ParamInfo]].new.from([{name: 'b', skill_ids: []}]) 261 | T.assert_type!(infos, T::Array[ParamInfo]) 262 | expect(infos.first.name).to eql 'b' 263 | 264 | expect { 265 | TypeCoerce[ParamInfo2].new.from({a: nil, b: nil}) 266 | }.to raise_error(TypeError) 267 | end 268 | end 269 | 270 | context 'when dealing with hashes' do 271 | it 'coreces correctly' do 272 | expect(TypeCoerce[T::Hash[T.untyped, T.untyped]].new.from(nil)).to eql({}) 273 | 274 | expect(TypeCoerce[T::Hash[String, T::Boolean]].new.from({ 275 | a: 'true', 276 | b: 'false', 277 | })).to eql({ 278 | 'a' => true, 279 | 'b' => false, 280 | }) 281 | 282 | expect(TypeCoerce[HashParams].new.from({ 283 | myhash: {'a' => '1', 'b' => '2'}, 284 | }).myhash).to eql({'a' => 1, 'b' => 2}) 285 | 286 | expect(TypeCoerce[HashParamsWithDefault].new.from({}).myhash).to eql({'a' => 1}) 287 | 288 | expect { 289 | TypeCoerce[T::Hash[String, T::Boolean]].new.from({ 290 | a: 'invalid', 291 | b: 'false', 292 | }) 293 | }.to raise_error(TypeCoerce::CoercionError) 294 | 295 | expect { 296 | TypeCoerce[T::Hash[String, Integer]].new.from(1) 297 | }.to raise_error(TypeCoerce::ShapeError) 298 | end 299 | end 300 | 301 | context 'when dealing with sets' do 302 | it 'coreces correctly' do 303 | expect(TypeCoerce[T::Set[Integer]].new.from( 304 | Set.new(['1', '2', '3']) 305 | )).to eq Set.new([1, 2, 3]) 306 | 307 | expect { 308 | TypeCoerce[T::Set[Integer]].new.from(Set.new(['1', 'invalid', '3'])) 309 | }.to raise_error(TypeCoerce::CoercionError) 310 | 311 | expect { 312 | TypeCoerce[T::Set[Integer]].new.from(1) 313 | }.to raise_error(TypeCoerce::ShapeError) 314 | end 315 | end 316 | 317 | context 'when given a type alias' do 318 | MyType = T.type_alias(T::Boolean) 319 | 320 | it 'coerces correctly' do 321 | expect(TypeCoerce[MyType].new.from('false')).to be false 322 | end 323 | end 324 | 325 | context 'when dealing with enums' do 326 | it 'coerces a serialized enum correctly' do 327 | coerced = TypeCoerce[WithEnum].new.from({myenum: "test"}) 328 | expect(coerced.myenum).to eq(TestEnum::Test) 329 | end 330 | 331 | it 'handles a real enum correctly' do 332 | coerced = TypeCoerce[WithEnum].new.from({myenum: TestEnum::Test}) 333 | expect(coerced.myenum).to eq(TestEnum::Test) 334 | end 335 | 336 | it 'handles bad enum' do 337 | expect { 338 | TypeCoerce[WithEnum].new.from({myenum: "bad_key"}) 339 | }.to raise_error(TypeCoerce::CoercionError) 340 | end 341 | end 342 | 343 | it 'works with T.untyped' do 344 | expect(TypeCoerce[T.untyped].new.from(1)).to eql 1 345 | 346 | obj = CustomType.new(1) 347 | expect(TypeCoerce[T::Hash[String, T.untyped]].new.from({a: obj})).to eq({'a' => obj}) 348 | end 349 | 350 | it 'works with T::Types::FixedArray' do 351 | type = T.type_alias { [Integer, String, Integer] } 352 | coerced = TypeCoerce[type].new.from(['1', 2, '3']) 353 | expect(coerced).to eql([1, '2', 3]) 354 | 355 | coerced = TypeCoerce[WithFixedArray].new.from({ arr: ['1', 2, '3'] }) 356 | expect(coerced.arr).to eql([1, '2', 3]) 357 | end 358 | 359 | context 'when dealing with T.class_of' do 360 | it 'keeps the value as-is' do 361 | string_class_type = T.class_of(String) 362 | expect(TypeCoerce[string_class_type].new.from(String)).to eql(String) 363 | expect(TypeCoerce[string_class_type].new.from(CustomString)).to eql(CustomString) 364 | expect do 365 | TypeCoerce[string_class_type].new.from(Integer) 366 | end.to raise_error(TypeError) 367 | expect do 368 | TypeCoerce[string_class_type].new.from('a') 369 | end.to raise_error(TypeError) 370 | end 371 | end 372 | 373 | context 'when dealing with unknown types' do 374 | context 'raise_coercion_error is enabled' do 375 | it 'raises error' do 376 | expect do 377 | TypeCoerce['a'].new.from('a', raise_coercion_error: true) 378 | end.to raise_error(TypeCoerce::CoercionError) 379 | end 380 | end 381 | context 'raise_coercion_error is disabled' do 382 | it 'keeps the value as-is (and let Sorbet raise error)' do 383 | expect do 384 | TypeCoerce['a'].new.from('a', raise_coercion_error: false) 385 | end.to raise_error(/must be an T::Types::Base/i) 386 | end 387 | end 388 | end 389 | 390 | context 'when dealing with coercing empty strings' do 391 | context 'when flag is set' do 392 | it 'coerces empty strings to nil from a simple type' do 393 | expect(TypeCoerce[T.nilable(String)].new.from('', coerce_empty_to_nil: true)).to be_nil 394 | end 395 | 396 | it 'coerces empty strings to nil from a struct' do 397 | coerced = TypeCoerce[WithNilableString].new.from({myvalue: ''}, coerce_empty_to_nil: true) 398 | expect(coerced.myvalue).to eql(nil) 399 | end 400 | end 401 | 402 | context 'when flag is not set' do 403 | it 'coerces empty strings to nil from a simple type' do 404 | expect(TypeCoerce[T.nilable(String)].new.from('', coerce_empty_to_nil: false)).to eql('') 405 | end 406 | 407 | it 'coerces empty strings to nil from a struct' do 408 | coerced = TypeCoerce[WithNilableString].new.from({myvalue: ''}, coerce_empty_to_nil: false) 409 | expect(coerced.myvalue).to eql('') 410 | end 411 | end 412 | end 413 | end 414 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/simplecov.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi gems 3 | 4 | # typed: true 5 | # 6 | # If you would like to make changes to this file, great! Please create the gem's shim here: 7 | # 8 | # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/simplecov/all/simplecov.rbi 9 | # 10 | # simplecov-0.21.2 11 | 12 | module SimpleCov 13 | def self.adapt_coverage_result; end 14 | def self.add_not_loaded_files(result); end 15 | def self.at_exit_behavior; end 16 | def self.clear_result; end 17 | def self.collate(result_filenames, profile = nil, ignore_timeout: nil, &block); end 18 | def self.exit_and_report_previous_error(exit_status); end 19 | def self.exit_status_from_exception; end 20 | def self.external_at_exit; end 21 | def self.external_at_exit=(arg0); end 22 | def self.external_at_exit?; end 23 | def self.filtered(files); end 24 | def self.final_result_process?; end 25 | def self.grouped(files); end 26 | def self.initial_setup(profile, &block); end 27 | def self.load_adapter(name); end 28 | def self.load_profile(name); end 29 | def self.lookup_corresponding_ruby_coverage_name(criterion); end 30 | def self.make_parallel_tests_available; end 31 | def self.pid; end 32 | def self.pid=(arg0); end 33 | def self.previous_error?(error_exit_status); end 34 | def self.probably_running_parallel_tests?; end 35 | def self.process_coverage_result; end 36 | def self.process_result(result); end 37 | def self.process_results_and_report_error; end 38 | def self.ready_to_process_results?; end 39 | def self.remove_useless_results; end 40 | def self.result; end 41 | def self.result?; end 42 | def self.result_exit_status(result); end 43 | def self.result_with_not_loaded_files; end 44 | def self.round_coverage(coverage); end 45 | def self.run_exit_tasks!; end 46 | def self.running; end 47 | def self.running=(arg0); end 48 | def self.start(profile = nil, &block); end 49 | def self.start_coverage_measurement; end 50 | def self.start_coverage_with_criteria; end 51 | def self.wait_for_other_processes; end 52 | def self.write_last_run(result); end 53 | extend SimpleCov::Configuration 54 | end 55 | module SimpleCov::Formatter 56 | def self.from_env(env); end 57 | end 58 | class SimpleCov::Formatter::MultiFormatter 59 | def self.[](*args); end 60 | def self.new(formatters = nil); end 61 | end 62 | module SimpleCov::Formatter::MultiFormatter::InstanceMethods 63 | def format(result); end 64 | end 65 | module SimpleCov::Configuration 66 | def adapters; end 67 | def add_filter(filter_argument = nil, &filter_proc); end 68 | def add_group(group_name, filter_argument = nil, &filter_proc); end 69 | def at_exit(&block); end 70 | def at_fork(&block); end 71 | def branch_coverage?; end 72 | def branch_coverage_supported?; end 73 | def clear_coverage_criteria; end 74 | def command_name(name = nil); end 75 | def configure(&block); end 76 | def coverage_criteria; end 77 | def coverage_criterion(criterion = nil); end 78 | def coverage_criterion_enabled?(criterion); end 79 | def coverage_dir(dir = nil); end 80 | def coverage_path; end 81 | def coverage_start_arguments_supported?; end 82 | def enable_coverage(criterion); end 83 | def enable_for_subprocesses(value = nil); end 84 | def enabled_for_subprocesses?; end 85 | def filters; end 86 | def filters=(arg0); end 87 | def formatter(formatter = nil); end 88 | def formatter=(arg0); end 89 | def formatters; end 90 | def formatters=(formatters); end 91 | def groups; end 92 | def groups=(arg0); end 93 | def maximum_coverage_drop(coverage_drop = nil); end 94 | def merge_timeout(seconds = nil); end 95 | def minimum_coverage(coverage = nil); end 96 | def minimum_coverage_by_file(coverage = nil); end 97 | def minimum_possible_coverage_exceeded(coverage_option); end 98 | def nocov_token(nocov_token = nil); end 99 | def parse_filter(filter_argument = nil, &filter_proc); end 100 | def primary_coverage(criterion = nil); end 101 | def print_error_status; end 102 | def print_error_status=(arg0); end 103 | def profiles; end 104 | def project_name(new_name = nil); end 105 | def raise_if_criterion_disabled(criterion); end 106 | def raise_if_criterion_unsupported(criterion); end 107 | def raise_on_invalid_coverage(coverage, coverage_setting); end 108 | def refuse_coverage_drop(*criteria); end 109 | def root(root = nil); end 110 | def skip_token(nocov_token = nil); end 111 | def track_files(glob); end 112 | def tracked_files; end 113 | def use_merging(use = nil); end 114 | end 115 | class SimpleCov::CoverageStatistics 116 | def compute_percent(covered, missed, total); end 117 | def compute_strength(total_strength, total); end 118 | def covered; end 119 | def initialize(covered:, missed:, total_strength: nil); end 120 | def missed; end 121 | def percent; end 122 | def self.from(coverage_statistics); end 123 | def strength; end 124 | def total; end 125 | end 126 | module SimpleCov::ExitCodes 127 | end 128 | module SimpleCov::ExitCodes::ExitCodeHandling 129 | def call(result, coverage_limits:); end 130 | def coverage_checks(result, coverage_limits); end 131 | def self.call(result, coverage_limits:); end 132 | def self.coverage_checks(result, coverage_limits); end 133 | end 134 | class SimpleCov::ExitCodes::MaximumCoverageDropCheck 135 | def compute_coverage_drop_data; end 136 | def coverage_drop_violations; end 137 | def drop_percent(criterion); end 138 | def exit_code; end 139 | def failing?; end 140 | def initialize(result, maximum_coverage_drop); end 141 | def last_coverage(criterion); end 142 | def last_run; end 143 | def maximum_coverage_drop; end 144 | def report; end 145 | def result; end 146 | end 147 | class SimpleCov::ExitCodes::MinimumCoverageByFileCheck 148 | def compute_minimum_coverage_data; end 149 | def exit_code; end 150 | def failing?; end 151 | def initialize(result, minimum_coverage_by_file); end 152 | def minimum_coverage_by_file; end 153 | def minimum_violations; end 154 | def report; end 155 | def result; end 156 | end 157 | class SimpleCov::ExitCodes::MinimumOverallCoverageCheck 158 | def calculate_minimum_violations; end 159 | def exit_code; end 160 | def failing?; end 161 | def initialize(result, minimum_coverage); end 162 | def minimum_coverage; end 163 | def minimum_violations; end 164 | def report; end 165 | def result; end 166 | end 167 | class SimpleCov::Profiles < Hash 168 | def define(name, &blk); end 169 | def load(name); end 170 | end 171 | class SimpleCov::SourceFile 172 | def branch_coverage_statistics; end 173 | def branches; end 174 | def branches_coverage_percent; end 175 | def branches_for_line(line_number); end 176 | def branches_report; end 177 | def build_branch(branch_data, hit_count, condition_start_line); end 178 | def build_branches; end 179 | def build_branches_from(condition, branches); end 180 | def build_branches_report; end 181 | def build_lines; end 182 | def build_no_cov_chunks; end 183 | def coverage_data; end 184 | def coverage_exceeding_source_warn; end 185 | def coverage_statistics; end 186 | def covered_branches; end 187 | def covered_lines; end 188 | def covered_percent; end 189 | def covered_strength; end 190 | def ensure_remove_undefs(file_lines); end 191 | def filename; end 192 | def initialize(filename, coverage_data); end 193 | def line(number); end 194 | def line_coverage_statistics; end 195 | def line_with_missed_branch?(line_number); end 196 | def lines; end 197 | def lines_of_code; end 198 | def lines_strength; end 199 | def load_source; end 200 | def missed_branches; end 201 | def missed_lines; end 202 | def never_lines; end 203 | def no_branches?; end 204 | def no_cov_chunks; end 205 | def no_lines?; end 206 | def process_skipped_branches(branches); end 207 | def process_skipped_lines(lines); end 208 | def project_filename; end 209 | def read_lines(file, lines, current_line); end 210 | def relevant_lines; end 211 | def restore_ruby_data_structure(structure); end 212 | def set_encoding_based_on_magic_comment(file, line); end 213 | def shebang?(line); end 214 | def skipped_lines; end 215 | def source; end 216 | def source_lines; end 217 | def src; end 218 | def total_branches; end 219 | end 220 | class SimpleCov::SourceFile::Line 221 | def coverage; end 222 | def covered?; end 223 | def initialize(src, line_number, coverage); end 224 | def line; end 225 | def line_number; end 226 | def missed?; end 227 | def never?; end 228 | def number; end 229 | def skipped!; end 230 | def skipped; end 231 | def skipped?; end 232 | def source; end 233 | def src; end 234 | def status; end 235 | end 236 | class SimpleCov::SourceFile::Branch 237 | def coverage; end 238 | def covered?; end 239 | def end_line; end 240 | def initialize(start_line:, end_line:, coverage:, inline:, type:); end 241 | def inline?; end 242 | def missed?; end 243 | def overlaps_with?(line_range); end 244 | def report; end 245 | def report_line; end 246 | def skipped!; end 247 | def skipped?; end 248 | def start_line; end 249 | def type; end 250 | end 251 | class SimpleCov::FileList 252 | def branch_covered_percent; end 253 | def compute_coverage_statistics; end 254 | def compute_coverage_statistics_by_file; end 255 | def count(*args, &block); end 256 | def coverage_statistics; end 257 | def coverage_statistics_by_file; end 258 | def covered_branches; end 259 | def covered_lines; end 260 | def covered_percent; end 261 | def covered_percentages; end 262 | def covered_strength; end 263 | def each(*args, &block); end 264 | def empty?(*args, &block); end 265 | def initialize(files); end 266 | def least_covered_file; end 267 | def length(*args, &block); end 268 | def lines_of_code; end 269 | def map(*args, &block); end 270 | def missed_branches; end 271 | def missed_lines; end 272 | def never_lines; end 273 | def size(*args, &block); end 274 | def skipped_lines; end 275 | def to_a(*args, &block); end 276 | def to_ary(*args, &block); end 277 | def total_branches; end 278 | extend Forwardable 279 | include Enumerable 280 | end 281 | class SimpleCov::Result 282 | def command_name; end 283 | def command_name=(arg0); end 284 | def coverage; end 285 | def coverage_statistics(*args, &block); end 286 | def coverage_statistics_by_file(*args, &block); end 287 | def covered_branches(*args, &block); end 288 | def covered_lines(*args, &block); end 289 | def covered_percent(*args, &block); end 290 | def covered_percentages(*args, &block); end 291 | def covered_strength(*args, &block); end 292 | def created_at; end 293 | def created_at=(arg0); end 294 | def filenames; end 295 | def files; end 296 | def filter!; end 297 | def format!; end 298 | def groups; end 299 | def initialize(original_result, command_name: nil, created_at: nil); end 300 | def least_covered_file(*args, &block); end 301 | def missed_branches(*args, &block); end 302 | def missed_lines(*args, &block); end 303 | def original_result; end 304 | def self.from_hash(hash); end 305 | def source_files; end 306 | def to_hash; end 307 | def total_branches(*args, &block); end 308 | def total_lines(*args, &block); end 309 | extend Forwardable 310 | end 311 | class SimpleCov::Filter 312 | def filter_argument; end 313 | def initialize(filter_argument); end 314 | def matches?(_source_file); end 315 | def passes?(source_file); end 316 | def self.build_filter(filter_argument); end 317 | def self.class_for_argument(filter_argument); end 318 | end 319 | class SimpleCov::StringFilter < SimpleCov::Filter 320 | def matches?(source_file); end 321 | end 322 | class SimpleCov::RegexFilter < SimpleCov::Filter 323 | def matches?(source_file); end 324 | end 325 | class SimpleCov::BlockFilter < SimpleCov::Filter 326 | def matches?(source_file); end 327 | end 328 | class SimpleCov::ArrayFilter < SimpleCov::Filter 329 | def initialize(filter_argument); end 330 | def matches?(source_files_list); end 331 | end 332 | class SimpleCov::Formatter::SimpleFormatter 333 | def format(result); end 334 | end 335 | module SimpleCov::LastRun 336 | def self.last_run_path; end 337 | def self.read; end 338 | def self.write(json); end 339 | end 340 | class SimpleCov::LinesClassifier 341 | def classify(lines); end 342 | def self.no_cov_line; end 343 | def self.no_cov_line?(line); end 344 | def self.whitespace_line?(line); end 345 | end 346 | module SimpleCov::ResultMerger 347 | def self.adapt_pre_simplecov_0_18_result(result); end 348 | def self.adapt_result(result); end 349 | def self.create_result(command_names, coverage); end 350 | def self.merge_and_store(*file_paths, ignore_timeout: nil); end 351 | def self.merge_coverage(*results); end 352 | def self.merge_results(*file_paths, ignore_timeout: nil); end 353 | def self.merge_valid_results(results, ignore_timeout: nil); end 354 | def self.merged_result; end 355 | def self.parse_file(path); end 356 | def self.parse_json(content); end 357 | def self.pre_simplecov_0_18_result?(result); end 358 | def self.read_file(path); end 359 | def self.read_resultset; end 360 | def self.resultset_path; end 361 | def self.resultset_writelock; end 362 | def self.store_result(result); end 363 | def self.synchronize_resultset; end 364 | def self.time_since_result_creation(data); end 365 | def self.valid_results(file_path, ignore_timeout: nil); end 366 | def self.within_merge_timeout?(data); end 367 | end 368 | module SimpleCov::CommandGuesser 369 | def self.from_command_line_options; end 370 | def self.from_defined_constants; end 371 | def self.from_env; end 372 | def self.guess; end 373 | def self.original_run_command; end 374 | def self.original_run_command=(arg0); end 375 | end 376 | class SimpleCov::ResultAdapter 377 | def adapt; end 378 | def initialize(result); end 379 | def result; end 380 | def self.call(*args); end 381 | end 382 | module SimpleCov::Combine 383 | def combine(combiner_module, coverage_a, coverage_b); end 384 | def empty_coverage?(coverage_a, coverage_b); end 385 | def existing_coverage(coverage_a, coverage_b); end 386 | def self.combine(combiner_module, coverage_a, coverage_b); end 387 | def self.empty_coverage?(coverage_a, coverage_b); end 388 | def self.existing_coverage(coverage_a, coverage_b); end 389 | end 390 | module SimpleCov::Combine::BranchesCombiner 391 | def combine(coverage_a, coverage_b); end 392 | def self.combine(coverage_a, coverage_b); end 393 | end 394 | module SimpleCov::Combine::FilesCombiner 395 | def combine(coverage_a, coverage_b); end 396 | def self.combine(coverage_a, coverage_b); end 397 | end 398 | module SimpleCov::Combine::LinesCombiner 399 | def combine(coverage_a, coverage_b); end 400 | def merge_line_coverage(first_val, second_val); end 401 | def self.combine(coverage_a, coverage_b); end 402 | def self.merge_line_coverage(first_val, second_val); end 403 | end 404 | module SimpleCov::Combine::ResultsCombiner 405 | def combine(*results); end 406 | def combine_file_coverage(coverage_a, coverage_b); end 407 | def combine_result_sets(combined_results, result); end 408 | def self.combine(*results); end 409 | def self.combine_file_coverage(coverage_a, coverage_b); end 410 | def self.combine_result_sets(combined_results, result); end 411 | end 412 | module SimpleCov::UselessResultsRemover 413 | def self.call(coverage_result); end 414 | def self.root_regx; end 415 | end 416 | module SimpleCov::SimulateCoverage 417 | def call(absolute_path); end 418 | def self.call(absolute_path); end 419 | end 420 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/rexml.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi gems 3 | 4 | # typed: strict 5 | # 6 | # If you would like to make changes to this file, great! Please create the gem's shim here: 7 | # 8 | # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/rexml/all/rexml.rbi 9 | # 10 | # rexml-3.2.5 11 | 12 | module REXML 13 | end 14 | module REXML::Security 15 | def self.entity_expansion_limit; end 16 | def self.entity_expansion_limit=(val); end 17 | def self.entity_expansion_text_limit; end 18 | def self.entity_expansion_text_limit=(val); end 19 | end 20 | class REXML::ParseException < RuntimeError 21 | def context; end 22 | def continued_exception; end 23 | def continued_exception=(arg0); end 24 | def initialize(message, source = nil, parser = nil, exception = nil); end 25 | def line; end 26 | def parser; end 27 | def parser=(arg0); end 28 | def position; end 29 | def source; end 30 | def source=(arg0); end 31 | def to_s; end 32 | end 33 | module REXML::Formatters 34 | end 35 | class REXML::Formatters::Default 36 | def initialize(ie_hack = nil); end 37 | def write(node, output); end 38 | def write_cdata(node, output); end 39 | def write_comment(node, output); end 40 | def write_document(node, output); end 41 | def write_element(node, output); end 42 | def write_instruction(node, output); end 43 | def write_text(node, output); end 44 | end 45 | class REXML::Formatters::Pretty < REXML::Formatters::Default 46 | def compact; end 47 | def compact=(arg0); end 48 | def indent_text(string, level = nil, style = nil, indentfirstline = nil); end 49 | def initialize(indentation = nil, ie_hack = nil); end 50 | def width; end 51 | def width=(arg0); end 52 | def wrap(string, width); end 53 | def write_cdata(node, output); end 54 | def write_comment(node, output); end 55 | def write_document(node, output); end 56 | def write_element(node, output); end 57 | def write_text(node, output); end 58 | end 59 | module REXML::Node 60 | def each_recursive(&block); end 61 | def find_first_recursive(&block); end 62 | def indent(to, ind); end 63 | def index_in_parent; end 64 | def next_sibling_node; end 65 | def parent?; end 66 | def previous_sibling_node; end 67 | def to_s(indent = nil); end 68 | end 69 | class REXML::Child 70 | def bytes; end 71 | def document; end 72 | def initialize(parent = nil); end 73 | def next_sibling; end 74 | def next_sibling=(other); end 75 | def parent; end 76 | def parent=(other); end 77 | def previous_sibling; end 78 | def previous_sibling=(other); end 79 | def remove; end 80 | def replace_with(child); end 81 | include REXML::Node 82 | end 83 | class REXML::Parent < REXML::Child 84 | def <<(object); end 85 | def [](index); end 86 | def []=(*args); end 87 | def add(object); end 88 | def children; end 89 | def deep_clone; end 90 | def delete(object); end 91 | def delete_at(index); end 92 | def delete_if(&block); end 93 | def each(&block); end 94 | def each_child(&block); end 95 | def each_index(&block); end 96 | def index(child); end 97 | def initialize(parent = nil); end 98 | def insert_after(child1, child2); end 99 | def insert_before(child1, child2); end 100 | def length; end 101 | def parent?; end 102 | def push(object); end 103 | def replace_child(to_replace, replacement); end 104 | def size; end 105 | def to_a; end 106 | def unshift(object); end 107 | include Enumerable 108 | end 109 | module REXML::XMLTokens 110 | end 111 | module REXML::Namespace 112 | def expanded_name; end 113 | def fully_expanded_name; end 114 | def has_name?(other, ns = nil); end 115 | def local_name; end 116 | def name; end 117 | def name=(name); end 118 | def prefix; end 119 | def prefix=(arg0); end 120 | include REXML::XMLTokens 121 | end 122 | module REXML::Encoding 123 | def decode(string); end 124 | def encode(string); end 125 | def encoding; end 126 | def encoding=(encoding); end 127 | def find_encoding(name); end 128 | end 129 | class REXML::SourceFactory 130 | def self.create_from(arg); end 131 | end 132 | class REXML::Source 133 | def buffer; end 134 | def consume(pattern); end 135 | def current_line; end 136 | def detect_encoding; end 137 | def empty?; end 138 | def encoding; end 139 | def encoding=(enc); end 140 | def encoding_updated; end 141 | def initialize(arg, encoding = nil); end 142 | def line; end 143 | def match(pattern, cons = nil); end 144 | def match_to(char, pattern); end 145 | def match_to_consume(char, pattern); end 146 | def position; end 147 | def read; end 148 | def scan(pattern, cons = nil); end 149 | include REXML::Encoding 150 | end 151 | class REXML::IOSource < REXML::Source 152 | def consume(pattern); end 153 | def current_line; end 154 | def empty?; end 155 | def encoding_updated; end 156 | def initialize(arg, block_size = nil, encoding = nil); end 157 | def match(pattern, cons = nil); end 158 | def position; end 159 | def read; end 160 | def readline; end 161 | def scan(pattern, cons = nil); end 162 | end 163 | class REXML::Entity < REXML::Child 164 | def external; end 165 | def initialize(stream, value = nil, parent = nil, reference = nil); end 166 | def name; end 167 | def ndata; end 168 | def normalized; end 169 | def pubid; end 170 | def ref; end 171 | def self.matches?(string); end 172 | def to_s; end 173 | def unnormalized; end 174 | def value; end 175 | def write(out, indent = nil); end 176 | include REXML::XMLTokens 177 | end 178 | module REXML::EntityConst 179 | end 180 | class REXML::AttlistDecl < REXML::Child 181 | def [](key); end 182 | def each(&block); end 183 | def element_name; end 184 | def include?(key); end 185 | def initialize(source); end 186 | def node_type; end 187 | def write(out, indent = nil); end 188 | include Enumerable 189 | end 190 | class REXML::ReferenceWriter 191 | def initialize(id_type, public_id_literal, system_literal, context = nil); end 192 | def write(output); end 193 | end 194 | class REXML::DocType < REXML::Parent 195 | def add(child); end 196 | def attribute_of(element, attribute); end 197 | def attributes_of(element); end 198 | def clone; end 199 | def context; end 200 | def entities; end 201 | def entity(name); end 202 | def external_id; end 203 | def initialize(first, parent = nil); end 204 | def name; end 205 | def namespaces; end 206 | def node_type; end 207 | def notation(name); end 208 | def notations; end 209 | def public; end 210 | def system; end 211 | def write(output, indent = nil, transitive = nil, ie_hack = nil); end 212 | include REXML::XMLTokens 213 | end 214 | class REXML::Declaration < REXML::Child 215 | def initialize(src); end 216 | def to_s; end 217 | def write(output, indent); end 218 | end 219 | class REXML::ElementDecl < REXML::Declaration 220 | def initialize(src); end 221 | end 222 | class REXML::ExternalEntity < REXML::Child 223 | def initialize(src); end 224 | def to_s; end 225 | def write(output, indent); end 226 | end 227 | class REXML::NotationDecl < REXML::Child 228 | def initialize(name, middle, pub, sys); end 229 | def name; end 230 | def public; end 231 | def public=(arg0); end 232 | def system; end 233 | def system=(arg0); end 234 | def to_s; end 235 | def write(output, indent = nil); end 236 | end 237 | class REXML::Text < REXML::Child 238 | def <<(to_append); end 239 | def <=>(other); end 240 | def clear_cache; end 241 | def clone; end 242 | def doctype; end 243 | def empty?; end 244 | def indent_text(string, level = nil, style = nil, indentfirstline = nil); end 245 | def initialize(arg, respect_whitespace = nil, parent = nil, raw = nil, entity_filter = nil, illegal = nil); end 246 | def inspect; end 247 | def node_type; end 248 | def parent=(parent); end 249 | def raw; end 250 | def raw=(arg0); end 251 | def self.check(string, pattern, doctype); end 252 | def self.expand(ref, doctype, filter); end 253 | def self.normalize(input, doctype = nil, entity_filter = nil); end 254 | def self.read_with_substitution(input, illegal = nil); end 255 | def self.unnormalize(string, doctype = nil, filter = nil, illegal = nil); end 256 | def to_s; end 257 | def value; end 258 | def value=(val); end 259 | def wrap(string, width, addnewline = nil); end 260 | def write(writer, indent = nil, transitive = nil, ie_hack = nil); end 261 | def write_with_substitution(out, input); end 262 | def xpath; end 263 | include Comparable 264 | end 265 | class REXML::Attribute 266 | def ==(other); end 267 | def clone; end 268 | def doctype; end 269 | def element; end 270 | def element=(element); end 271 | def hash; end 272 | def initialize(first, second = nil, parent = nil); end 273 | def inspect; end 274 | def namespace(arg = nil); end 275 | def node_type; end 276 | def normalized=(arg0); end 277 | def prefix; end 278 | def remove; end 279 | def to_s; end 280 | def to_string; end 281 | def value; end 282 | def write(output, indent = nil); end 283 | def xpath; end 284 | include REXML::Namespace 285 | include REXML::Node 286 | end 287 | class REXML::CData < REXML::Text 288 | def clone; end 289 | def initialize(first, whitespace = nil, parent = nil); end 290 | def to_s; end 291 | def value; end 292 | def write(output = nil, indent = nil, transitive = nil, ie_hack = nil); end 293 | end 294 | module REXML::Functions 295 | end 296 | module REXML::Parsers 297 | end 298 | class REXML::Parsers::XPathParser 299 | def AdditiveExpr(path, parsed); end 300 | def AndExpr(path, parsed); end 301 | def EqualityExpr(path, parsed); end 302 | def FilterExpr(path, parsed); end 303 | def FunctionCall(rest, parsed); end 304 | def LocationPath(path, parsed); end 305 | def MultiplicativeExpr(path, parsed); end 306 | def NodeTest(path, parsed); end 307 | def OrExpr(path, parsed); end 308 | def PathExpr(path, parsed); end 309 | def Predicate(path, parsed); end 310 | def PrimaryExpr(path, parsed); end 311 | def RelationalExpr(path, parsed); end 312 | def RelativeLocationPath(path, parsed); end 313 | def UnaryExpr(path, parsed); end 314 | def UnionExpr(path, parsed); end 315 | def abbreviate(path); end 316 | def expand(path); end 317 | def get_group(string); end 318 | def namespaces=(namespaces); end 319 | def parse(path); end 320 | def parse_args(string); end 321 | def predicate(path); end 322 | def predicate_to_string(path, &block); end 323 | include REXML::XMLTokens 324 | end 325 | module REXML::DClonable 326 | end 327 | class REXML::XPathParser 328 | def []=(variable_name, value); end 329 | def child(nodeset); end 330 | def compare(a, operator, b); end 331 | def descendant(nodeset, include_self); end 332 | def descendant_recursive(raw_node, new_nodeset, new_nodes, include_self); end 333 | def each_unnode(nodeset); end 334 | def enter(tag, *args); end 335 | def equality_relational_compare(set1, op, set2); end 336 | def evaluate_predicate(expression, nodesets); end 337 | def expr(path_stack, nodeset, context = nil); end 338 | def filter_nodeset(nodeset); end 339 | def first(path_stack, node); end 340 | def following(node); end 341 | def following_node_of(node); end 342 | def get_first(path, nodeset); end 343 | def get_namespace(node, prefix); end 344 | def initialize(strict: nil); end 345 | def leave(tag, *args); end 346 | def match(path_stack, nodeset); end 347 | def namespaces=(namespaces = nil); end 348 | def next_sibling_node(node); end 349 | def node_test(path_stack, nodesets, any_type: nil); end 350 | def norm(b); end 351 | def normalize_compare_values(a, operator, b); end 352 | def parse(path, nodeset); end 353 | def preceding(node); end 354 | def preceding_node_of(node); end 355 | def predicate(path, nodeset); end 356 | def sort(array_of_nodes, order); end 357 | def step(path_stack, any_type: nil, order: nil); end 358 | def strict?; end 359 | def trace(*args); end 360 | def unnode(nodeset); end 361 | def value_type(value); end 362 | def variables=(vars = nil); end 363 | include REXML::XMLTokens 364 | end 365 | class REXML::XPathNode 366 | def context; end 367 | def initialize(node, context = nil); end 368 | def position; end 369 | def raw_node; end 370 | end 371 | class REXML::XPath 372 | def self.each(element, path = nil, namespaces = nil, variables = nil, options = nil, &block); end 373 | def self.first(element, path = nil, namespaces = nil, variables = nil, options = nil); end 374 | def self.match(element, path = nil, namespaces = nil, variables = nil, options = nil); end 375 | include REXML::Functions 376 | end 377 | class REXML::Element < REXML::Parent 378 | def [](name_or_index); end 379 | def __to_xpath_helper(node); end 380 | def add_attribute(key, value = nil); end 381 | def add_attributes(hash); end 382 | def add_element(element, attrs = nil); end 383 | def add_namespace(prefix, uri = nil); end 384 | def add_text(text); end 385 | def attribute(name, namespace = nil); end 386 | def attributes; end 387 | def cdatas; end 388 | def clone; end 389 | def comments; end 390 | def context; end 391 | def context=(arg0); end 392 | def delete_attribute(key); end 393 | def delete_element(element); end 394 | def delete_namespace(namespace = nil); end 395 | def document; end 396 | def each_element(xpath = nil, &block); end 397 | def each_element_with_attribute(key, value = nil, max = nil, name = nil, &block); end 398 | def each_element_with_text(text = nil, max = nil, name = nil, &block); end 399 | def each_with_something(test, max = nil, name = nil); end 400 | def elements; end 401 | def get_elements(xpath); end 402 | def get_text(path = nil); end 403 | def has_attributes?; end 404 | def has_elements?; end 405 | def has_text?; end 406 | def ignore_whitespace_nodes; end 407 | def initialize(arg = nil, parent = nil, context = nil); end 408 | def inspect; end 409 | def instructions; end 410 | def namespace(prefix = nil); end 411 | def namespaces; end 412 | def next_element; end 413 | def node_type; end 414 | def prefixes; end 415 | def previous_element; end 416 | def raw; end 417 | def root; end 418 | def root_node; end 419 | def text(path = nil); end 420 | def text=(text); end 421 | def texts; end 422 | def whitespace; end 423 | def write(output = nil, indent = nil, transitive = nil, ie_hack = nil); end 424 | def xpath; end 425 | include REXML::Namespace 426 | end 427 | class REXML::Elements 428 | def <<(element = nil); end 429 | def [](index, name = nil); end 430 | def []=(index, element); end 431 | def add(element = nil); end 432 | def collect(xpath = nil); end 433 | def delete(element); end 434 | def delete_all(xpath); end 435 | def each(xpath = nil); end 436 | def empty?; end 437 | def index(element); end 438 | def initialize(parent); end 439 | def inject(xpath = nil, initial = nil); end 440 | def literalize(name); end 441 | def parent; end 442 | def size; end 443 | def to_a(xpath = nil); end 444 | include Enumerable 445 | end 446 | class REXML::Attributes < Hash 447 | def <<(attribute); end 448 | def [](name); end 449 | def []=(name, value); end 450 | def add(attribute); end 451 | def delete(attribute); end 452 | def delete_all(name); end 453 | def each; end 454 | def each_attribute; end 455 | def get_attribute(name); end 456 | def get_attribute_ns(namespace, name); end 457 | def initialize(element); end 458 | def length; end 459 | def namespaces; end 460 | def prefixes; end 461 | def size; end 462 | def to_a; end 463 | end 464 | class REXML::XMLDecl < REXML::Child 465 | def ==(other); end 466 | def clone; end 467 | def content(enc); end 468 | def dowrite; end 469 | def encoding=(enc); end 470 | def initialize(version = nil, encoding = nil, standalone = nil); end 471 | def inspect; end 472 | def node_type; end 473 | def nowrite; end 474 | def old_enc=(encoding); end 475 | def self.default; end 476 | def stand_alone?; end 477 | def standalone; end 478 | def standalone=(arg0); end 479 | def version; end 480 | def version=(arg0); end 481 | def write(writer, indent = nil, transitive = nil, ie_hack = nil); end 482 | def writeencoding; end 483 | def writethis; end 484 | def xmldecl(version, encoding, standalone); end 485 | include REXML::Encoding 486 | end 487 | class REXML::Comment < REXML::Child 488 | def <=>(other); end 489 | def ==(other); end 490 | def clone; end 491 | def initialize(first, second = nil); end 492 | def node_type; end 493 | def string; end 494 | def string=(arg0); end 495 | def to_s; end 496 | def write(output, indent = nil, transitive = nil, ie_hack = nil); end 497 | include Comparable 498 | end 499 | class REXML::Instruction < REXML::Child 500 | def ==(other); end 501 | def clone; end 502 | def content; end 503 | def content=(arg0); end 504 | def initialize(target, content = nil); end 505 | def inspect; end 506 | def node_type; end 507 | def target; end 508 | def target=(arg0); end 509 | def write(writer, indent = nil, transitive = nil, ie_hack = nil); end 510 | end 511 | class REXML::Output 512 | def <<(content); end 513 | def encoding; end 514 | def initialize(real_IO, encd = nil); end 515 | def to_s; end 516 | include REXML::Encoding 517 | end 518 | class REXML::UndefinedNamespaceException < REXML::ParseException 519 | def initialize(prefix, source, parser); end 520 | end 521 | class REXML::Parsers::BaseParser 522 | def add_listener(listener); end 523 | def empty?; end 524 | def entity(reference, entities); end 525 | def has_next?; end 526 | def initialize(source); end 527 | def need_source_encoding_update?(xml_declaration_encoding); end 528 | def normalize(input, entities = nil, entity_filter = nil); end 529 | def parse_attributes(prefixes, curr_ns); end 530 | def parse_id(base_error_message, accept_external_id:, accept_public_id:); end 531 | def parse_id_invalid_details(accept_external_id:, accept_public_id:); end 532 | def parse_name(base_error_message); end 533 | def peek(depth = nil); end 534 | def position; end 535 | def process_instruction; end 536 | def pull; end 537 | def pull_event; end 538 | def source; end 539 | def stream=(source); end 540 | def unnormalize(string, entities = nil, filter = nil); end 541 | def unshift(token); end 542 | end 543 | class REXML::Parsers::StreamParser 544 | def add_listener(listener); end 545 | def initialize(source, listener); end 546 | def parse; end 547 | end 548 | module REXML::Validation 549 | end 550 | class REXML::Validation::ValidationException < RuntimeError 551 | def initialize(msg); end 552 | end 553 | class REXML::Parsers::TreeParser 554 | def add_listener(listener); end 555 | def initialize(source, build_context = nil); end 556 | def parse; end 557 | end 558 | class REXML::Document < REXML::Element 559 | def <<(child); end 560 | def add(child); end 561 | def add_element(arg = nil, arg2 = nil); end 562 | def build(source); end 563 | def clone; end 564 | def doctype; end 565 | def document; end 566 | def encoding; end 567 | def entity_expansion_count; end 568 | def expanded_name; end 569 | def initialize(source = nil, context = nil); end 570 | def name; end 571 | def node_type; end 572 | def record_entity_expansion; end 573 | def root; end 574 | def self.entity_expansion_limit; end 575 | def self.entity_expansion_limit=(val); end 576 | def self.entity_expansion_text_limit; end 577 | def self.entity_expansion_text_limit=(val); end 578 | def self.parse_stream(source, listener); end 579 | def stand_alone?; end 580 | def version; end 581 | def write(*arguments); end 582 | def xml_decl; end 583 | end 584 | module REXML::StreamListener 585 | def attlistdecl(element_name, attributes, raw_content); end 586 | def cdata(content); end 587 | def comment(comment); end 588 | def doctype(name, pub_sys, long_name, uri); end 589 | def doctype_end; end 590 | def elementdecl(content); end 591 | def entity(content); end 592 | def entitydecl(content); end 593 | def instruction(name, instruction); end 594 | def notationdecl(content); end 595 | def tag_end(name); end 596 | def tag_start(name, attrs); end 597 | def text(text); end 598 | def xmldecl(version, encoding, standalone); end 599 | end 600 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/byebug.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi gems 3 | 4 | # typed: true 5 | # 6 | # If you would like to make changes to this file, great! Please create the gem's shim here: 7 | # 8 | # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/byebug/all/byebug.rbi 9 | # 10 | # byebug-11.0.1 11 | 12 | module Byebug 13 | def add_catchpoint(arg0); end 14 | def breakpoints; end 15 | def catchpoints; end 16 | def contexts; end 17 | def current_context; end 18 | def debug_load(*arg0); end 19 | def displays; end 20 | def displays=(arg0); end 21 | def init_file; end 22 | def init_file=(arg0); end 23 | def lock; end 24 | def mode; end 25 | def mode=(arg0); end 26 | def post_mortem=(arg0); end 27 | def post_mortem?; end 28 | def raised_exception; end 29 | def rc_dirs; end 30 | def run_init_script; end 31 | def run_rc_file(rc_file); end 32 | def self.actual_control_port; end 33 | def self.actual_port; end 34 | def self.add_catchpoint(arg0); end 35 | def self.attach; end 36 | def self.breakpoints; end 37 | def self.catchpoints; end 38 | def self.client; end 39 | def self.contexts; end 40 | def self.control; end 41 | def self.current_context; end 42 | def self.debug_load(*arg0); end 43 | def self.handle_post_mortem; end 44 | def self.interrupt; end 45 | def self.load_settings; end 46 | def self.lock; end 47 | def self.parse_host_and_port(host_port_spec); end 48 | def self.post_mortem=(arg0); end 49 | def self.post_mortem?; end 50 | def self.raised_exception; end 51 | def self.server; end 52 | def self.spawn(host = nil, port = nil); end 53 | def self.start; end 54 | def self.start_client(host = nil, port = nil); end 55 | def self.start_control(host = nil, port = nil); end 56 | def self.start_server(host = nil, port = nil); end 57 | def self.started?; end 58 | def self.stop; end 59 | def self.stoppable?; end 60 | def self.thread_context(arg0); end 61 | def self.tracing=(arg0); end 62 | def self.tracing?; end 63 | def self.unlock; end 64 | def self.verbose=(arg0); end 65 | def self.verbose?; end 66 | def self.wait_connection; end 67 | def self.wait_connection=(arg0); end 68 | def start; end 69 | def started?; end 70 | def stop; end 71 | def stoppable?; end 72 | def thread_context(arg0); end 73 | def tracing=(arg0); end 74 | def tracing?; end 75 | def unlock; end 76 | def verbose=(arg0); end 77 | def verbose?; end 78 | extend Byebug 79 | include Byebug::Helpers::ReflectionHelper 80 | end 81 | module Kernel 82 | def byebug; end 83 | def debugger; end 84 | def remote_byebug(host = nil, port = nil); end 85 | end 86 | module Byebug::Helpers 87 | end 88 | module Byebug::Helpers::ReflectionHelper 89 | def commands; end 90 | end 91 | class Byebug::Context 92 | def at_breakpoint(breakpoint); end 93 | def at_catchpoint(exception); end 94 | def at_end; end 95 | def at_line; end 96 | def at_return(return_value); end 97 | def at_tracing; end 98 | def backtrace; end 99 | def dead?; end 100 | def file(*args, &block); end 101 | def frame; end 102 | def frame=(pos); end 103 | def frame_binding(*arg0); end 104 | def frame_class(*arg0); end 105 | def frame_file(*arg0); end 106 | def frame_line(*arg0); end 107 | def frame_method(*arg0); end 108 | def frame_self(*arg0); end 109 | def full_location; end 110 | def ignored?; end 111 | def ignored_file?(path); end 112 | def interrupt; end 113 | def line(*args, &block); end 114 | def location; end 115 | def processor; end 116 | def resume; end 117 | def self.ignored_files; end 118 | def self.ignored_files=(arg0); end 119 | def self.interface; end 120 | def self.interface=(arg0); end 121 | def self.processor; end 122 | def self.processor=(arg0); end 123 | def stack_size; end 124 | def step_into(*arg0); end 125 | def step_out(*arg0); end 126 | def step_over(*arg0); end 127 | def stop_reason; end 128 | def suspend; end 129 | def suspended?; end 130 | def switch; end 131 | def thnum; end 132 | def thread; end 133 | def tracing; end 134 | def tracing=(arg0); end 135 | extend Forwardable 136 | include Byebug::Helpers::FileHelper 137 | end 138 | class Byebug::DebugThread < Thread 139 | def self.inherited(arg0); end 140 | end 141 | class Byebug::Breakpoint 142 | def enabled=(arg0); end 143 | def enabled?; end 144 | def expr; end 145 | def expr=(arg0); end 146 | def hit_condition; end 147 | def hit_condition=(arg0); end 148 | def hit_count; end 149 | def hit_value; end 150 | def hit_value=(arg0); end 151 | def id; end 152 | def initialize(arg0, arg1, arg2); end 153 | def inspect; end 154 | def pos; end 155 | def self.add(file, line, expr = nil); end 156 | def self.first; end 157 | def self.last; end 158 | def self.none?; end 159 | def self.potential_line?(filename, lineno); end 160 | def self.potential_lines(filename); end 161 | def self.potential_lines_with_trace_points(iseq, lines); end 162 | def self.potential_lines_without_trace_points(iseq, lines); end 163 | def self.remove(id); end 164 | def source; end 165 | end 166 | module Byebug::Helpers::FileHelper 167 | def get_line(filename, lineno); end 168 | def get_lines(filename); end 169 | def n_lines(filename); end 170 | def normalize(filename); end 171 | def shortpath(fullpath); end 172 | def virtual_file?(name); end 173 | end 174 | class Byebug::Frame 175 | def _binding; end 176 | def _class; end 177 | def _method; end 178 | def _self; end 179 | def args; end 180 | def c_args; end 181 | def c_frame?; end 182 | def current?; end 183 | def deco_args; end 184 | def deco_block; end 185 | def deco_call; end 186 | def deco_class; end 187 | def deco_file; end 188 | def deco_method; end 189 | def deco_pos; end 190 | def file; end 191 | def initialize(context, pos); end 192 | def line; end 193 | def locals; end 194 | def mark; end 195 | def pos; end 196 | def prefix_and_default(arg_type); end 197 | def ruby_args; end 198 | def to_hash; end 199 | def use_short_style?(arg); end 200 | include Byebug::Helpers::FileHelper 201 | end 202 | module Byebug::Helpers::PathHelper 203 | def all_files; end 204 | def bin_file; end 205 | def gem_files; end 206 | def glob_for(dir); end 207 | def lib_files; end 208 | def root_path; end 209 | def test_files; end 210 | end 211 | module Byebug::Helpers::EvalHelper 212 | def allowing_other_threads; end 213 | def error_eval(str, binding = nil); end 214 | def error_msg(exception); end 215 | def in_new_thread; end 216 | def msg(exception); end 217 | def multiple_thread_eval(expression); end 218 | def safe_eval(str, binding); end 219 | def safe_inspect(var); end 220 | def safe_to_s(var); end 221 | def separate_thread_eval(expression); end 222 | def silent_eval(str, binding = nil); end 223 | def warning_eval(str, binding = nil); end 224 | def warning_msg(exception); end 225 | end 226 | class Byebug::CommandNotFound < NoMethodError 227 | def build_cmd(*args); end 228 | def help; end 229 | def initialize(input, parent = nil); end 230 | def name; end 231 | end 232 | class Byebug::CommandProcessor 233 | def after_repl; end 234 | def at_breakpoint(brkpt); end 235 | def at_catchpoint(exception); end 236 | def at_end; end 237 | def at_line; end 238 | def at_return(return_value); end 239 | def at_tracing; end 240 | def auto_cmds_for(run_level); end 241 | def before_repl; end 242 | def command_list; end 243 | def commands(*args, &block); end 244 | def confirm(*args, &block); end 245 | def context; end 246 | def errmsg(*args, &block); end 247 | def frame(*args, &block); end 248 | def initialize(context, interface = nil); end 249 | def interface; end 250 | def pr(*args, &block); end 251 | def prc(*args, &block); end 252 | def prev_line; end 253 | def prev_line=(arg0); end 254 | def printer; end 255 | def proceed!; end 256 | def process_commands; end 257 | def prompt; end 258 | def prv(*args, &block); end 259 | def puts(*args, &block); end 260 | def repl; end 261 | def run_auto_cmds(run_level); end 262 | def run_cmd(input); end 263 | def safely; end 264 | extend Forwardable 265 | include Byebug::Helpers::EvalHelper 266 | end 267 | module Byebug::Helpers::StringHelper 268 | def camelize(str); end 269 | def deindent(str, leading_spaces: nil); end 270 | def prettify(str); end 271 | end 272 | class Byebug::Setting 273 | def boolean?; end 274 | def help; end 275 | def initialize; end 276 | def integer?; end 277 | def self.[](name); end 278 | def self.[]=(name, value); end 279 | def self.find(shortcut); end 280 | def self.help_all; end 281 | def self.settings; end 282 | def to_s; end 283 | def to_sym; end 284 | def value; end 285 | def value=(arg0); end 286 | end 287 | class Byebug::History 288 | def buffer; end 289 | def clear; end 290 | def default_max_size; end 291 | def ignore?(buf); end 292 | def initialize; end 293 | def last_ids(number); end 294 | def pop; end 295 | def push(cmd); end 296 | def restore; end 297 | def save; end 298 | def size; end 299 | def size=(arg0); end 300 | def specific_max_size(number); end 301 | def to_s(n_cmds); end 302 | end 303 | class Byebug::LocalInterface < Byebug::Interface 304 | def initialize; end 305 | def readline(prompt); end 306 | def with_repl_like_sigint; end 307 | end 308 | class Byebug::ScriptInterface < Byebug::Interface 309 | def close; end 310 | def initialize(file, verbose = nil); end 311 | def read_command(prompt); end 312 | def readline(*arg0); end 313 | end 314 | class Byebug::RemoteInterface < Byebug::Interface 315 | def close; end 316 | def confirm(prompt); end 317 | def initialize(socket); end 318 | def print(message); end 319 | def puts(message); end 320 | def read_command(prompt); end 321 | def readline(prompt); end 322 | end 323 | class Byebug::Interface 324 | def autorestore; end 325 | def autosave; end 326 | def close; end 327 | def command_queue; end 328 | def command_queue=(arg0); end 329 | def confirm(prompt); end 330 | def errmsg(message); end 331 | def error; end 332 | def history; end 333 | def history=(arg0); end 334 | def initialize; end 335 | def input; end 336 | def last_if_empty(input); end 337 | def output; end 338 | def prepare_input(prompt); end 339 | def print(message); end 340 | def puts(message); end 341 | def read_command(prompt); end 342 | def read_file(filename); end 343 | def read_input(prompt, save_hist = nil); end 344 | def split_commands(cmd_line); end 345 | include Byebug::Helpers::FileHelper 346 | end 347 | class Byebug::ScriptProcessor < Byebug::CommandProcessor 348 | def after_repl; end 349 | def commands; end 350 | def prompt; end 351 | def repl; end 352 | def without_exceptions; end 353 | end 354 | class Byebug::PostMortemProcessor < Byebug::CommandProcessor 355 | def commands; end 356 | def prompt; end 357 | end 358 | class Byebug::Command 359 | def arguments; end 360 | def confirm(*args, &block); end 361 | def context; end 362 | def errmsg(*args, &block); end 363 | def frame; end 364 | def help(*args, &block); end 365 | def initialize(processor, input = nil); end 366 | def match(*args, &block); end 367 | def pr(*args, &block); end 368 | def prc(*args, &block); end 369 | def print(*args, &block); end 370 | def processor; end 371 | def prv(*args, &block); end 372 | def puts(*args, &block); end 373 | def self.allow_in_control; end 374 | def self.allow_in_control=(arg0); end 375 | def self.allow_in_post_mortem; end 376 | def self.allow_in_post_mortem=(arg0); end 377 | def self.always_run; end 378 | def self.always_run=(arg0); end 379 | def self.columnize(width); end 380 | def self.help; end 381 | def self.match(input); end 382 | def self.to_s; end 383 | extend Forwardable 384 | end 385 | module Byebug::Helpers::ParseHelper 386 | def get_int(str, cmd, min = nil, max = nil); end 387 | def parse_steps(str, cmd); end 388 | def syntax_valid?(code); end 389 | def without_stderr; end 390 | end 391 | class Byebug::SourceFileFormatter 392 | def amend(line, ceiling); end 393 | def amend_final(line); end 394 | def amend_initial(line); end 395 | def annotator; end 396 | def file; end 397 | def initialize(file, annotator); end 398 | def lines(min, max); end 399 | def lines_around(center); end 400 | def max_initial_line; end 401 | def max_line; end 402 | def range_around(center); end 403 | def range_from(min); end 404 | def size; end 405 | include Byebug::Helpers::FileHelper 406 | end 407 | class Byebug::BreakCommand < Byebug::Command 408 | def add_line_breakpoint(file, line); end 409 | def execute; end 410 | def line_breakpoint(location); end 411 | def method_breakpoint(location); end 412 | def self.description; end 413 | def self.regexp; end 414 | def self.short_description; end 415 | def target_object(str); end 416 | def valid_breakpoints_for(path, line); end 417 | include Byebug::Helpers::EvalHelper 418 | include Byebug::Helpers::FileHelper 419 | include Byebug::Helpers::ParseHelper 420 | end 421 | class Byebug::CatchCommand < Byebug::Command 422 | def add(exception); end 423 | def clear; end 424 | def execute; end 425 | def info; end 426 | def remove(exception); end 427 | def self.description; end 428 | def self.regexp; end 429 | def self.short_description; end 430 | include Byebug::Helpers::EvalHelper 431 | end 432 | class Byebug::ConditionCommand < Byebug::Command 433 | def execute; end 434 | def self.description; end 435 | def self.regexp; end 436 | def self.short_description; end 437 | include Byebug::Helpers::ParseHelper 438 | end 439 | class Byebug::ContinueCommand < Byebug::Command 440 | def execute; end 441 | def modifier; end 442 | def self.description; end 443 | def self.regexp; end 444 | def self.short_description; end 445 | def unconditionally?; end 446 | def until_line?; end 447 | include Byebug::Helpers::ParseHelper 448 | end 449 | class Byebug::DebugCommand < Byebug::Command 450 | def execute; end 451 | def self.description; end 452 | def self.regexp; end 453 | def self.short_description; end 454 | include Byebug::Helpers::EvalHelper 455 | end 456 | class Byebug::DeleteCommand < Byebug::Command 457 | def execute; end 458 | def self.description; end 459 | def self.regexp; end 460 | def self.short_description; end 461 | include Byebug::Helpers::ParseHelper 462 | end 463 | class Byebug::CommandList 464 | def each; end 465 | def initialize(commands); end 466 | def match(input); end 467 | def to_s; end 468 | def width; end 469 | include Enumerable 470 | end 471 | module Byebug::Subcommands 472 | def execute; end 473 | def self.included(command); end 474 | def subcommand_list(*args, &block); end 475 | extend Forwardable 476 | end 477 | module Byebug::Subcommands::ClassMethods 478 | def help; end 479 | def subcommand_list; end 480 | include Byebug::Helpers::ReflectionHelper 481 | end 482 | module Byebug::Helpers::ToggleHelper 483 | def enable_disable_breakpoints(is_enable, args); end 484 | def enable_disable_display(is_enable, args); end 485 | def n_displays; end 486 | def select_breakpoints(is_enable, args); end 487 | include Byebug::Helpers::ParseHelper 488 | end 489 | class Byebug::DisableCommand < Byebug::Command 490 | def self.description; end 491 | def self.regexp; end 492 | def self.short_description; end 493 | extend Byebug::Subcommands::ClassMethods 494 | include Byebug::Subcommands 495 | end 496 | class Byebug::DisableCommand::BreakpointsCommand < Byebug::Command 497 | def execute; end 498 | def self.description; end 499 | def self.regexp; end 500 | def self.short_description; end 501 | include Byebug::Helpers::ToggleHelper 502 | end 503 | class Byebug::DisableCommand::DisplayCommand < Byebug::Command 504 | def execute; end 505 | def self.description; end 506 | def self.regexp; end 507 | def self.short_description; end 508 | include Byebug::Helpers::ToggleHelper 509 | end 510 | class Byebug::DisplayCommand < Byebug::Command 511 | def display_expression(exp); end 512 | def eval_expr(expression); end 513 | def execute; end 514 | def print_display_expressions; end 515 | def self.description; end 516 | def self.regexp; end 517 | def self.short_description; end 518 | include Byebug::Helpers::EvalHelper 519 | end 520 | module Byebug::Helpers::FrameHelper 521 | def adjust_frame(new_frame); end 522 | def direction(step); end 523 | def frame_err(msg); end 524 | def index_from_start(index); end 525 | def jump_frames(steps); end 526 | def navigate_to_frame(jump_no); end 527 | def out_of_bounds?(pos); end 528 | def switch_to_frame(frame); end 529 | end 530 | class Byebug::DownCommand < Byebug::Command 531 | def execute; end 532 | def self.description; end 533 | def self.regexp; end 534 | def self.short_description; end 535 | include Byebug::Helpers::FrameHelper 536 | include Byebug::Helpers::ParseHelper 537 | end 538 | class Byebug::EditCommand < Byebug::Command 539 | def edit_error(type, file); end 540 | def editor; end 541 | def execute; end 542 | def location(matched); end 543 | def self.description; end 544 | def self.regexp; end 545 | def self.short_description; end 546 | end 547 | class Byebug::EnableCommand < Byebug::Command 548 | def self.description; end 549 | def self.regexp; end 550 | def self.short_description; end 551 | extend Byebug::Subcommands::ClassMethods 552 | include Byebug::Subcommands 553 | end 554 | class Byebug::EnableCommand::BreakpointsCommand < Byebug::Command 555 | def execute; end 556 | def self.description; end 557 | def self.regexp; end 558 | def self.short_description; end 559 | include Byebug::Helpers::ToggleHelper 560 | end 561 | class Byebug::EnableCommand::DisplayCommand < Byebug::Command 562 | def execute; end 563 | def self.description; end 564 | def self.regexp; end 565 | def self.short_description; end 566 | include Byebug::Helpers::ToggleHelper 567 | end 568 | class Byebug::FinishCommand < Byebug::Command 569 | def execute; end 570 | def max_frames; end 571 | def self.description; end 572 | def self.regexp; end 573 | def self.short_description; end 574 | include Byebug::Helpers::ParseHelper 575 | end 576 | class Byebug::FrameCommand < Byebug::Command 577 | def execute; end 578 | def self.description; end 579 | def self.regexp; end 580 | def self.short_description; end 581 | include Byebug::Helpers::FrameHelper 582 | include Byebug::Helpers::ParseHelper 583 | end 584 | class Byebug::HelpCommand < Byebug::Command 585 | def command; end 586 | def execute; end 587 | def help_for(input, cmd); end 588 | def help_for_all; end 589 | def self.description; end 590 | def self.regexp; end 591 | def self.short_description; end 592 | def subcommand; end 593 | end 594 | class Byebug::HistoryCommand < Byebug::Command 595 | def execute; end 596 | def self.description; end 597 | def self.regexp; end 598 | def self.short_description; end 599 | include Byebug::Helpers::ParseHelper 600 | end 601 | class Byebug::InfoCommand < Byebug::Command 602 | def self.description; end 603 | def self.regexp; end 604 | def self.short_description; end 605 | extend Byebug::Subcommands::ClassMethods 606 | include Byebug::Subcommands 607 | end 608 | class Byebug::InfoCommand::BreakpointsCommand < Byebug::Command 609 | def execute; end 610 | def info_breakpoint(brkpt); end 611 | def self.description; end 612 | def self.regexp; end 613 | def self.short_description; end 614 | end 615 | class Byebug::InfoCommand::DisplayCommand < Byebug::Command 616 | def execute; end 617 | def self.description; end 618 | def self.regexp; end 619 | def self.short_description; end 620 | end 621 | class Byebug::InfoCommand::FileCommand < Byebug::Command 622 | def execute; end 623 | def info_file_basic(file); end 624 | def info_file_breakpoints(file); end 625 | def info_file_mtime(file); end 626 | def info_file_sha1(file); end 627 | def self.description; end 628 | def self.regexp; end 629 | def self.short_description; end 630 | include Byebug::Helpers::FileHelper 631 | include Byebug::Helpers::StringHelper 632 | end 633 | class Byebug::InfoCommand::LineCommand < Byebug::Command 634 | def execute; end 635 | def self.description; end 636 | def self.regexp; end 637 | def self.short_description; end 638 | end 639 | class Byebug::InfoCommand::ProgramCommand < Byebug::Command 640 | def execute; end 641 | def format_stop_reason(stop_reason); end 642 | def self.description; end 643 | def self.regexp; end 644 | def self.short_description; end 645 | end 646 | class Byebug::InterruptCommand < Byebug::Command 647 | def execute; end 648 | def self.description; end 649 | def self.regexp; end 650 | def self.short_description; end 651 | end 652 | class Byebug::IrbCommand < Byebug::Command 653 | def execute; end 654 | def self.description; end 655 | def self.regexp; end 656 | def self.short_description; end 657 | def with_clean_argv; end 658 | end 659 | class Byebug::KillCommand < Byebug::Command 660 | def execute; end 661 | def self.description; end 662 | def self.regexp; end 663 | def self.short_description; end 664 | end 665 | class Byebug::ListCommand < Byebug::Command 666 | def amend_final(*args, &block); end 667 | def auto_range(direction); end 668 | def display_lines(min, max); end 669 | def execute; end 670 | def lower_bound(range); end 671 | def max_line(*args, &block); end 672 | def move(line, size, direction = nil); end 673 | def parse_range(input); end 674 | def range(input); end 675 | def self.description; end 676 | def self.regexp; end 677 | def self.short_description; end 678 | def size(*args, &block); end 679 | def source_file_formatter; end 680 | def split_range(str); end 681 | def upper_bound(range); end 682 | def valid_range?(first, last); end 683 | extend Forwardable 684 | include Byebug::Helpers::FileHelper 685 | include Byebug::Helpers::ParseHelper 686 | end 687 | class Byebug::MethodCommand < Byebug::Command 688 | def execute; end 689 | def self.description; end 690 | def self.regexp; end 691 | def self.short_description; end 692 | include Byebug::Helpers::EvalHelper 693 | end 694 | class Byebug::NextCommand < Byebug::Command 695 | def execute; end 696 | def self.description; end 697 | def self.regexp; end 698 | def self.short_description; end 699 | include Byebug::Helpers::ParseHelper 700 | end 701 | class Byebug::PryCommand < Byebug::Command 702 | def execute; end 703 | def self.description; end 704 | def self.regexp; end 705 | def self.short_description; end 706 | end 707 | class Byebug::QuitCommand < Byebug::Command 708 | def execute; end 709 | def self.description; end 710 | def self.regexp; end 711 | def self.short_description; end 712 | end 713 | module Byebug::Helpers::BinHelper 714 | def executable_file_extensions; end 715 | def find_executable(path, cmd); end 716 | def real_executable?(file); end 717 | def search_paths; end 718 | def which(cmd); end 719 | end 720 | class Byebug::RestartCommand < Byebug::Command 721 | def execute; end 722 | def prepend_byebug_bin(cmd); end 723 | def prepend_ruby_bin(cmd); end 724 | def self.description; end 725 | def self.regexp; end 726 | def self.short_description; end 727 | include Byebug::Helpers::BinHelper 728 | include Byebug::Helpers::PathHelper 729 | end 730 | class Byebug::SaveCommand < Byebug::Command 731 | def execute; end 732 | def save_breakpoints(file); end 733 | def save_catchpoints(file); end 734 | def save_displays(file); end 735 | def save_settings(file); end 736 | def self.description; end 737 | def self.regexp; end 738 | def self.short_description; end 739 | end 740 | class Byebug::SetCommand < Byebug::Command 741 | def execute; end 742 | def get_onoff(arg, default); end 743 | def self.description; end 744 | def self.help; end 745 | def self.regexp; end 746 | def self.short_description; end 747 | include Byebug::Helpers::ParseHelper 748 | end 749 | class Byebug::ShowCommand < Byebug::Command 750 | def execute; end 751 | def self.description; end 752 | def self.help; end 753 | def self.regexp; end 754 | def self.short_description; end 755 | end 756 | class Byebug::SkipCommand < Byebug::Command 757 | def auto_run; end 758 | def execute; end 759 | def initialize_attributes; end 760 | def keep_execution; end 761 | def reset_attributes; end 762 | def self.description; end 763 | def self.file_line; end 764 | def self.file_line=(arg0); end 765 | def self.file_path; end 766 | def self.file_path=(arg0); end 767 | def self.previous_autolist; end 768 | def self.regexp; end 769 | def self.restore_autolist; end 770 | def self.setup_autolist(value); end 771 | def self.short_description; end 772 | include Byebug::Helpers::ParseHelper 773 | end 774 | class Byebug::SourceCommand < Byebug::Command 775 | def execute; end 776 | def self.description; end 777 | def self.regexp; end 778 | def self.short_description; end 779 | end 780 | class Byebug::StepCommand < Byebug::Command 781 | def execute; end 782 | def self.description; end 783 | def self.regexp; end 784 | def self.short_description; end 785 | include Byebug::Helpers::ParseHelper 786 | end 787 | module Byebug::Helpers::ThreadHelper 788 | def context_from_thread(thnum); end 789 | def current_thread?(ctx); end 790 | def debug_flag(ctx); end 791 | def display_context(ctx); end 792 | def location(ctx); end 793 | def status_flag(ctx); end 794 | def thread_arguments(ctx); end 795 | end 796 | class Byebug::ThreadCommand < Byebug::Command 797 | def self.description; end 798 | def self.regexp; end 799 | def self.short_description; end 800 | extend Byebug::Subcommands::ClassMethods 801 | include Byebug::Subcommands 802 | end 803 | class Byebug::ThreadCommand::CurrentCommand < Byebug::Command 804 | def execute; end 805 | def self.description; end 806 | def self.regexp; end 807 | def self.short_description; end 808 | include Byebug::Helpers::ThreadHelper 809 | end 810 | class Byebug::ThreadCommand::ListCommand < Byebug::Command 811 | def execute; end 812 | def self.description; end 813 | def self.regexp; end 814 | def self.short_description; end 815 | include Byebug::Helpers::ThreadHelper 816 | end 817 | class Byebug::ThreadCommand::ResumeCommand < Byebug::Command 818 | def execute; end 819 | def self.description; end 820 | def self.regexp; end 821 | def self.short_description; end 822 | include Byebug::Helpers::ThreadHelper 823 | end 824 | class Byebug::ThreadCommand::StopCommand < Byebug::Command 825 | def execute; end 826 | def self.description; end 827 | def self.regexp; end 828 | def self.short_description; end 829 | include Byebug::Helpers::ThreadHelper 830 | end 831 | class Byebug::ThreadCommand::SwitchCommand < Byebug::Command 832 | def execute; end 833 | def self.description; end 834 | def self.regexp; end 835 | def self.short_description; end 836 | include Byebug::Helpers::ThreadHelper 837 | end 838 | class Byebug::TracevarCommand < Byebug::Command 839 | def execute; end 840 | def on_change(name, value, stop); end 841 | def self.description; end 842 | def self.regexp; end 843 | def self.short_description; end 844 | end 845 | class Byebug::UndisplayCommand < Byebug::Command 846 | def execute; end 847 | def self.description; end 848 | def self.regexp; end 849 | def self.short_description; end 850 | include Byebug::Helpers::ParseHelper 851 | end 852 | class Byebug::UntracevarCommand < Byebug::Command 853 | def execute; end 854 | def self.description; end 855 | def self.regexp; end 856 | def self.short_description; end 857 | end 858 | class Byebug::UpCommand < Byebug::Command 859 | def execute; end 860 | def self.description; end 861 | def self.regexp; end 862 | def self.short_description; end 863 | include Byebug::Helpers::FrameHelper 864 | include Byebug::Helpers::ParseHelper 865 | end 866 | module Byebug::Helpers::VarHelper 867 | def var_args; end 868 | def var_global; end 869 | def var_instance(str); end 870 | def var_list(ary, binding = nil); end 871 | def var_local; end 872 | include Byebug::Helpers::EvalHelper 873 | end 874 | class Byebug::VarCommand < Byebug::Command 875 | def self.description; end 876 | def self.regexp; end 877 | def self.short_description; end 878 | extend Byebug::Subcommands::ClassMethods 879 | include Byebug::Subcommands 880 | end 881 | class Byebug::VarCommand::AllCommand < Byebug::Command 882 | def execute; end 883 | def self.description; end 884 | def self.regexp; end 885 | def self.short_description; end 886 | include Byebug::Helpers::VarHelper 887 | end 888 | class Byebug::VarCommand::ArgsCommand < Byebug::Command 889 | def execute; end 890 | def self.description; end 891 | def self.regexp; end 892 | def self.short_description; end 893 | include Byebug::Helpers::VarHelper 894 | end 895 | class Byebug::VarCommand::ConstCommand < Byebug::Command 896 | def execute; end 897 | def self.description; end 898 | def self.regexp; end 899 | def self.short_description; end 900 | def str_obj; end 901 | include Byebug::Helpers::EvalHelper 902 | end 903 | class Byebug::VarCommand::InstanceCommand < Byebug::Command 904 | def execute; end 905 | def self.description; end 906 | def self.regexp; end 907 | def self.short_description; end 908 | include Byebug::Helpers::VarHelper 909 | end 910 | class Byebug::VarCommand::LocalCommand < Byebug::Command 911 | def execute; end 912 | def self.description; end 913 | def self.regexp; end 914 | def self.short_description; end 915 | include Byebug::Helpers::VarHelper 916 | end 917 | class Byebug::VarCommand::GlobalCommand < Byebug::Command 918 | def execute; end 919 | def self.description; end 920 | def self.regexp; end 921 | def self.short_description; end 922 | include Byebug::Helpers::VarHelper 923 | end 924 | class Byebug::WhereCommand < Byebug::Command 925 | def execute; end 926 | def print_backtrace; end 927 | def self.description; end 928 | def self.regexp; end 929 | def self.short_description; end 930 | include Byebug::Helpers::FrameHelper 931 | end 932 | class Byebug::ControlProcessor < Byebug::CommandProcessor 933 | def commands; end 934 | def prompt; end 935 | end 936 | module Byebug::Remote 937 | end 938 | class Byebug::Remote::Server 939 | def actual_port; end 940 | def initialize(wait_connection:, &block); end 941 | def start(host, port); end 942 | def wait_connection; end 943 | end 944 | class Byebug::Remote::Client 945 | def connect_at(host, port); end 946 | def initialize(interface); end 947 | def interface; end 948 | def socket; end 949 | def start(host = nil, port = nil); end 950 | def started?; end 951 | end 952 | module Byebug::Printers 953 | end 954 | class Byebug::Printers::Base 955 | def array_of_args(collection, &_block); end 956 | def contents; end 957 | def contents_files; end 958 | def locate(path); end 959 | def parts(path); end 960 | def translate(string, args = nil); end 961 | def type; end 962 | end 963 | class Byebug::Printers::Base::MissedPath < StandardError 964 | end 965 | class Byebug::Printers::Base::MissedArgument < StandardError 966 | end 967 | class Byebug::Printers::Plain < Byebug::Printers::Base 968 | def contents_files; end 969 | def print(path, args = nil); end 970 | def print_collection(path, collection, &block); end 971 | def print_variables(variables, *_unused); end 972 | end 973 | class Byebug::AutosaveSetting < Byebug::Setting 974 | def banner; end 975 | end 976 | class Byebug::AutolistSetting < Byebug::Setting 977 | def banner; end 978 | def initialize; end 979 | def value; end 980 | def value=(val); end 981 | end 982 | class Byebug::WidthSetting < Byebug::Setting 983 | def banner; end 984 | def to_s; end 985 | end 986 | class Byebug::HistsizeSetting < Byebug::Setting 987 | def banner; end 988 | def to_s; end 989 | end 990 | class Byebug::LinetraceSetting < Byebug::Setting 991 | def banner; end 992 | def value; end 993 | def value=(val); end 994 | end 995 | class Byebug::StackOnErrorSetting < Byebug::Setting 996 | def banner; end 997 | end 998 | class Byebug::BasenameSetting < Byebug::Setting 999 | def banner; end 1000 | end 1001 | class Byebug::PostMortemSetting < Byebug::Setting 1002 | def banner; end 1003 | def initialize; end 1004 | def value; end 1005 | def value=(val); end 1006 | end 1007 | class Byebug::AutoirbSetting < Byebug::Setting 1008 | def banner; end 1009 | def initialize; end 1010 | def value; end 1011 | def value=(val); end 1012 | end 1013 | class Byebug::CallstyleSetting < Byebug::Setting 1014 | def banner; end 1015 | def to_s; end 1016 | end 1017 | class Byebug::FullpathSetting < Byebug::Setting 1018 | def banner; end 1019 | end 1020 | class Byebug::AutoprySetting < Byebug::Setting 1021 | def banner; end 1022 | def initialize; end 1023 | def value; end 1024 | def value=(val); end 1025 | end 1026 | class Byebug::SavefileSetting < Byebug::Setting 1027 | def banner; end 1028 | def to_s; end 1029 | end 1030 | class Byebug::HistfileSetting < Byebug::Setting 1031 | def banner; end 1032 | def to_s; end 1033 | end 1034 | class Byebug::ListsizeSetting < Byebug::Setting 1035 | def banner; end 1036 | def to_s; end 1037 | end 1038 | class Exception 1039 | def __bb_context; end 1040 | end 1041 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/rspec-mocks.rbi: -------------------------------------------------------------------------------- 1 | # This file is autogenerated. Do not edit it by hand. Regenerate it with: 2 | # srb rbi gems 3 | 4 | # typed: true 5 | # 6 | # If you would like to make changes to this file, great! Please create the gem's shim here: 7 | # 8 | # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/rspec-mocks/all/rspec-mocks.rbi 9 | # 10 | # rspec-mocks-3.11.1 11 | 12 | module RSpec 13 | end 14 | module RSpec::Mocks 15 | def self.allow_message(subject, message, opts = nil, &block); end 16 | def self.configuration; end 17 | def self.error_generator; end 18 | def self.expect_message(subject, message, opts = nil, &block); end 19 | def self.setup; end 20 | def self.space; end 21 | def self.teardown; end 22 | def self.verify; end 23 | def self.with_temporary_scope; end 24 | end 25 | class RSpec::Mocks::InstanceMethodStasher 26 | def handle_restoration_failures; end 27 | def initialize(object, method); end 28 | def method_defined_directly_on_klass?; end 29 | def method_defined_on_klass?(klass = nil); end 30 | def method_is_stashed?; end 31 | def method_owned_by_klass?; end 32 | def original_method; end 33 | def restore; end 34 | def stash; end 35 | end 36 | class RSpec::Mocks::MethodDouble 37 | def add_default_stub(*args, &implementation); end 38 | def add_expectation(error_generator, expectation_ordering, expected_from, opts, &implementation); end 39 | def add_simple_expectation(method_name, response, error_generator, backtrace_line); end 40 | def add_simple_stub(method_name, response); end 41 | def add_stub(error_generator, expectation_ordering, expected_from, opts = nil, &implementation); end 42 | def build_expectation(error_generator, expectation_ordering); end 43 | def clear; end 44 | def configure_method; end 45 | def define_proxy_method; end 46 | def definition_target; end 47 | def expectations; end 48 | def initialize(object, method_name, proxy); end 49 | def message_expectation_class; end 50 | def method_name; end 51 | def method_stasher; end 52 | def new_rspec_prepended_module; end 53 | def object; end 54 | def object_singleton_class; end 55 | def original_implementation_callable; end 56 | def original_method; end 57 | def proxy_method_invoked(_obj, *args, &block); end 58 | def raise_method_not_stubbed_error; end 59 | def remove_method_from_definition_target; end 60 | def remove_stub; end 61 | def remove_stub_if_present; end 62 | def reset; end 63 | def restore_original_method; end 64 | def restore_original_visibility; end 65 | def save_original_implementation_callable!; end 66 | def setup_simple_method_double(method_name, response, collection, error_generator = nil, backtrace_line = nil); end 67 | def show_frozen_warning; end 68 | def stubs; end 69 | def usable_rspec_prepended_module; end 70 | def verify; end 71 | def visibility; end 72 | end 73 | class RSpec::Mocks::MethodDouble::RSpecPrependedModule < Module 74 | end 75 | module RSpec::Mocks::ArgumentMatchers 76 | def a_kind_of(klass); end 77 | def an_instance_of(klass); end 78 | def any_args; end 79 | def anything; end 80 | def array_including(*args); end 81 | def boolean; end 82 | def duck_type(*args); end 83 | def hash_excluding(*args); end 84 | def hash_including(*args); end 85 | def hash_not_including(*args); end 86 | def instance_of(klass); end 87 | def kind_of(klass); end 88 | def no_args; end 89 | def self.anythingize_lonely_keys(*args); end 90 | end 91 | class RSpec::Mocks::ArgumentMatchers::SingletonMatcher 92 | def self.inherited(subklass); end 93 | def self.new(*arg0); end 94 | end 95 | class RSpec::Mocks::ArgumentMatchers::AnyArgsMatcher < RSpec::Mocks::ArgumentMatchers::SingletonMatcher 96 | def description; end 97 | end 98 | class RSpec::Mocks::ArgumentMatchers::AnyArgMatcher < RSpec::Mocks::ArgumentMatchers::SingletonMatcher 99 | def ===(_other); end 100 | def description; end 101 | end 102 | class RSpec::Mocks::ArgumentMatchers::NoArgsMatcher < RSpec::Mocks::ArgumentMatchers::SingletonMatcher 103 | def description; end 104 | end 105 | class RSpec::Mocks::ArgumentMatchers::BooleanMatcher < RSpec::Mocks::ArgumentMatchers::SingletonMatcher 106 | def ===(value); end 107 | def description; end 108 | end 109 | class RSpec::Mocks::ArgumentMatchers::BaseHashMatcher 110 | def ===(predicate, actual); end 111 | def description(name); end 112 | def formatted_expected_hash; end 113 | def initialize(expected); end 114 | end 115 | class RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher < RSpec::Mocks::ArgumentMatchers::BaseHashMatcher 116 | def ===(actual); end 117 | def description; end 118 | end 119 | class RSpec::Mocks::ArgumentMatchers::HashExcludingMatcher < RSpec::Mocks::ArgumentMatchers::BaseHashMatcher 120 | def ===(actual); end 121 | def description; end 122 | end 123 | class RSpec::Mocks::ArgumentMatchers::ArrayIncludingMatcher 124 | def ===(actual); end 125 | def description; end 126 | def formatted_expected_values; end 127 | def initialize(expected); end 128 | end 129 | class RSpec::Mocks::ArgumentMatchers::DuckTypeMatcher 130 | def ===(value); end 131 | def description; end 132 | def initialize(*methods_to_respond_to); end 133 | end 134 | class RSpec::Mocks::ArgumentMatchers::InstanceOf 135 | def ===(actual); end 136 | def description; end 137 | def initialize(klass); end 138 | end 139 | class RSpec::Mocks::ArgumentMatchers::KindOf 140 | def ===(actual); end 141 | def description; end 142 | def initialize(klass); end 143 | end 144 | class RSpec::Mocks::ObjectReference 145 | def self.anonymous_module?(mod); end 146 | def self.for(object_module_or_name, allow_direct_object_refs = nil); end 147 | def self.name_of(mod); end 148 | end 149 | class RSpec::Mocks::DirectObjectReference 150 | def const_to_replace; end 151 | def defined?; end 152 | def description; end 153 | def initialize(object); end 154 | def target; end 155 | def when_loaded; end 156 | end 157 | class RSpec::Mocks::NamedObjectReference 158 | def const_to_replace; end 159 | def defined?; end 160 | def description; end 161 | def initialize(const_name); end 162 | def object; end 163 | def target; end 164 | def when_loaded; end 165 | end 166 | module RSpec::Mocks::ExampleMethods 167 | def allow(target); end 168 | def allow_any_instance_of(klass); end 169 | def allow_message_expectations_on_nil; end 170 | def class_double(doubled_class, *args); end 171 | def class_spy(*args); end 172 | def double(*args); end 173 | def expect_any_instance_of(klass); end 174 | def have_received(method_name, &block); end 175 | def hide_const(constant_name); end 176 | def instance_double(doubled_class, *args); end 177 | def instance_spy(*args); end 178 | def object_double(object_or_name, *args); end 179 | def object_spy(*args); end 180 | def receive(method_name, &block); end 181 | def receive_message_chain(*messages, &block); end 182 | def receive_messages(message_return_value_hash); end 183 | def self.declare_double(type, *args); end 184 | def self.declare_verifying_double(type, ref, *args); end 185 | def self.extended(object); end 186 | def self.included(klass); end 187 | def spy(*args); end 188 | def stub_const(constant_name, value, options = nil); end 189 | def without_partial_double_verification; end 190 | include RSpec::Mocks::ArgumentMatchers 191 | end 192 | module RSpec::Mocks::ExampleMethods::ExpectHost 193 | def expect(target); end 194 | end 195 | class RSpec::Mocks::Proxy 196 | def add_message_expectation(method_name, opts = nil, &block); end 197 | def add_simple_expectation(method_name, response, location); end 198 | def add_simple_stub(method_name, response); end 199 | def add_stub(method_name, opts = nil, &implementation); end 200 | def as_null_object; end 201 | def build_expectation(method_name); end 202 | def check_for_unexpected_arguments(expectation); end 203 | def ensure_can_be_proxied!(object); end 204 | def ensure_implemented(*_args); end 205 | def find_almost_matching_expectation(method_name, *args); end 206 | def find_almost_matching_stub(method_name, *args); end 207 | def find_best_matching_expectation_for(method_name); end 208 | def find_matching_expectation(method_name, *args); end 209 | def find_matching_method_stub(method_name, *args); end 210 | def has_negative_expectation?(message); end 211 | def initialize(object, order_group, options = nil); end 212 | def message_received(message, *args, &block); end 213 | def messages_arg_list; end 214 | def method_double_for(message); end 215 | def method_double_if_exists_for_message(message); end 216 | def null_object?; end 217 | def object; end 218 | def original_method_handle_for(_message); end 219 | def prepended_modules_of_singleton_class; end 220 | def raise_missing_default_stub_error(expectation, args_for_multiple_calls); end 221 | def raise_unexpected_message_error(method_name, args); end 222 | def received_message?(method_name, *args, &block); end 223 | def record_message_received(message, *args, &block); end 224 | def remove_stub(method_name); end 225 | def remove_stub_if_present(method_name); end 226 | def replay_received_message_on(expectation, &block); end 227 | def reset; end 228 | def self.prepended_modules_of(klass); end 229 | def verify; end 230 | def visibility_for(_method_name); end 231 | end 232 | class RSpec::Mocks::Proxy::SpecificMessage < Struct 233 | def ==(expectation); end 234 | def args; end 235 | def args=(_); end 236 | def message; end 237 | def message=(_); end 238 | def object; end 239 | def object=(_); end 240 | def self.[](*arg0); end 241 | def self.inspect; end 242 | def self.members; end 243 | def self.new(*arg0); end 244 | end 245 | class RSpec::Mocks::TestDoubleProxy < RSpec::Mocks::Proxy 246 | def reset; end 247 | end 248 | class RSpec::Mocks::PartialDoubleProxy < RSpec::Mocks::Proxy 249 | def add_simple_expectation(method_name, response, location); end 250 | def add_simple_stub(method_name, response); end 251 | def any_instance_class_recorder_observing_method?(klass, method_name); end 252 | def message_received(message, *args, &block); end 253 | def original_method_handle_for(message); end 254 | def reset; end 255 | def visibility_for(method_name); end 256 | end 257 | module RSpec::Mocks::PartialClassDoubleProxyMethods 258 | def initialize(source_space, *args); end 259 | def method_double_from_ancestor_for(message); end 260 | def original_method_handle_for(message); end 261 | def original_unbound_method_handle_from_ancestor_for(message); end 262 | def superclass_proxy; end 263 | end 264 | class RSpec::Mocks::PartialClassDoubleProxy < RSpec::Mocks::PartialDoubleProxy 265 | include RSpec::Mocks::PartialClassDoubleProxyMethods 266 | end 267 | class RSpec::Mocks::ProxyForNil < RSpec::Mocks::PartialDoubleProxy 268 | def add_message_expectation(method_name, opts = nil, &block); end 269 | def add_stub(method_name, opts = nil, &implementation); end 270 | def disallow_expectations; end 271 | def disallow_expectations=(arg0); end 272 | def initialize(order_group); end 273 | def raise_error(method_name); end 274 | def set_expectation_behavior; end 275 | def warn(method_name); end 276 | def warn_about_expectations; end 277 | def warn_about_expectations=(arg0); end 278 | def warn_or_raise!(method_name); end 279 | end 280 | module RSpec::Mocks::TestDouble 281 | def ==(other); end 282 | def __build_mock_proxy(order_group); end 283 | def __build_mock_proxy_unless_expired(order_group); end 284 | def __disallow_further_usage!; end 285 | def __mock_proxy; end 286 | def __raise_expired_error; end 287 | def as_null_object; end 288 | def assign_stubs(stubs); end 289 | def freeze; end 290 | def initialize(name = nil, stubs = nil); end 291 | def initialize_copy(other); end 292 | def inspect; end 293 | def method_missing(message, *args, &block); end 294 | def null_object?; end 295 | def respond_to?(message, incl_private = nil); end 296 | def to_s; end 297 | end 298 | class RSpec::Mocks::Double 299 | include RSpec::Mocks::TestDouble 300 | end 301 | module RSpec::Mocks::TestDoubleFormatter 302 | def self.format(dbl, unwrap = nil); end 303 | def self.name_desc(dbl); end 304 | def self.type_desc(dbl); end 305 | def self.verified_module_desc(dbl); end 306 | end 307 | class RSpec::Mocks::ArgumentListMatcher 308 | def args_match?(*actual_args); end 309 | def ensure_expected_args_valid!; end 310 | def expected_args; end 311 | def initialize(*expected_args); end 312 | def replace_any_args_with_splat_of_anything(before_count, actual_args_count); end 313 | def resolve_expected_args_based_on(actual_args); end 314 | end 315 | class RSpec::Mocks::SimpleMessageExpectation 316 | def called_max_times?; end 317 | def initialize(message, response, error_generator, backtrace_line = nil); end 318 | def invoke(*_); end 319 | def matches?(message, *_); end 320 | def unadvise(_); end 321 | def verify_messages_received; end 322 | end 323 | class RSpec::Mocks::MessageExpectation 324 | def and_call_original; end 325 | def and_invoke(first_proc, *procs); end 326 | def and_raise(*args); end 327 | def and_return(first_value, *values); end 328 | def and_throw(*args); end 329 | def and_wrap_original(&block); end 330 | def and_yield(*args, &block); end 331 | def at_least(n, &block); end 332 | def at_most(n, &block); end 333 | def exactly(n, &block); end 334 | def inspect; end 335 | def never; end 336 | def once(&block); end 337 | def ordered(&block); end 338 | def thrice(&block); end 339 | def time(&block); end 340 | def times(&block); end 341 | def to_s; end 342 | def twice(&block); end 343 | def with(*args, &block); end 344 | include RSpec::Mocks::MessageExpectation::ImplementationDetails 345 | end 346 | module RSpec::Mocks::MessageExpectation::ImplementationDetails 347 | def actual_received_count_matters?; end 348 | def additional_expected_calls; end 349 | def advise(*args); end 350 | def and_yield_receiver_to_implementation; end 351 | def argument_list_matcher=(arg0); end 352 | def called_max_times?; end 353 | def description_for(verb); end 354 | def ensure_expected_ordering_received!; end 355 | def error_generator; end 356 | def error_generator=(arg0); end 357 | def exception_source_id; end 358 | def expectation_count_type; end 359 | def expected_args; end 360 | def expected_from=(arg0); end 361 | def expected_messages_received?; end 362 | def expected_received_count=(arg0); end 363 | def generate_error; end 364 | def has_been_invoked?; end 365 | def ignoring_args?; end 366 | def implementation; end 367 | def implementation=(arg0); end 368 | def increase_actual_received_count!; end 369 | def initial_implementation_action=(action); end 370 | def initialize(error_generator, expectation_ordering, expected_from, method_double, type = nil, opts = nil, &implementation_block); end 371 | def inner_implementation_action=(action); end 372 | def invoke(parent_stub, *args, &block); end 373 | def invoke_incrementing_actual_calls_by(increment, allowed_to_fail, parent_stub, *args, &block); end 374 | def invoke_without_incrementing_received_count(parent_stub, *args, &block); end 375 | def matches?(message, *args); end 376 | def matches_at_least_count?; end 377 | def matches_at_most_count?; end 378 | def matches_exact_count?; end 379 | def matches_name_but_not_args(message, *args); end 380 | def message; end 381 | def negative?; end 382 | def negative_expectation_for?(message); end 383 | def ordered?; end 384 | def orig_object; end 385 | def raise_already_invoked_error_if_necessary(calling_customization); end 386 | def raise_out_of_order_error; end 387 | def raise_unexpected_message_args_error(args_for_multiple_calls); end 388 | def safe_invoke(parent_stub, *args, &block); end 389 | def set_expected_received_count(relativity, n); end 390 | def similar_messages; end 391 | def terminal_implementation_action=(action); end 392 | def type; end 393 | def unadvise(args); end 394 | def verify_messages_received; end 395 | def warn_about_stub_override; end 396 | def wrap_original(method_name, &block); end 397 | def yield_receiver_to_implementation_block?; end 398 | end 399 | class RSpec::Mocks::AndYieldImplementation 400 | def call(*_args_to_ignore, &block); end 401 | def initialize(args_to_yield, eval_context, error_generator); end 402 | end 403 | class RSpec::Mocks::AndReturnImplementation 404 | def call(*_args_to_ignore, &_block); end 405 | def initialize(values_to_return); end 406 | end 407 | class RSpec::Mocks::AndInvokeImplementation 408 | def call(*args, &block); end 409 | def initialize(procs_to_invoke); end 410 | end 411 | class RSpec::Mocks::Implementation 412 | def actions; end 413 | def call(*args, &block); end 414 | def initial_action; end 415 | def initial_action=(arg0); end 416 | def inner_action; end 417 | def inner_action=(arg0); end 418 | def present?; end 419 | def terminal_action; end 420 | def terminal_action=(arg0); end 421 | end 422 | class RSpec::Mocks::AndWrapOriginalImplementation 423 | def call(*args, &block); end 424 | def cannot_modify_further_error; end 425 | def initial_action=(_value); end 426 | def initialize(method, block); end 427 | def inner_action; end 428 | def inner_action=(_value); end 429 | def present?; end 430 | def terminal_action=(_value); end 431 | end 432 | class RSpec::Mocks::AndWrapOriginalImplementation::CannotModifyFurtherError < StandardError 433 | end 434 | class RSpec::Mocks::OrderGroup 435 | def clear; end 436 | def consume; end 437 | def empty?; end 438 | def expectation_for(message); end 439 | def expectations_invoked_in_order?; end 440 | def expected_invocations; end 441 | def handle_order_constraint(expectation); end 442 | def initialize; end 443 | def invoked(message); end 444 | def invoked_expectations; end 445 | def ready_for?(expectation); end 446 | def register(expectation); end 447 | def remaining_expectations; end 448 | def verify_invocation_order(expectation); end 449 | end 450 | class RSpec::Mocks::MockExpectationError < Exception 451 | end 452 | class RSpec::Mocks::ExpiredTestDoubleError < RSpec::Mocks::MockExpectationError 453 | end 454 | class RSpec::Mocks::OutsideOfExampleError < StandardError 455 | end 456 | class RSpec::Mocks::MockExpectationAlreadyInvokedError < Exception 457 | end 458 | class RSpec::Mocks::CannotSupportArgMutationsError < StandardError 459 | end 460 | class RSpec::Mocks::UnsupportedMatcherError < StandardError 461 | end 462 | class RSpec::Mocks::NegationUnsupportedError < StandardError 463 | end 464 | class RSpec::Mocks::VerifyingDoubleNotDefinedError < StandardError 465 | end 466 | class RSpec::Mocks::ErrorGenerator 467 | def __raise(message, backtrace_line = nil, source_id = nil); end 468 | def arg_list(args); end 469 | def count_message(count, expectation_count_type = nil); end 470 | def default_error_message(expectation, expected_args, actual_args); end 471 | def describe_expectation(verb, message, expected_received_count, _actual_received_count, args); end 472 | def diff_message(expected_args, actual_args); end 473 | def differ; end 474 | def error_message(expectation, args_for_multiple_calls); end 475 | def expectation_on_nil_message(method_name); end 476 | def expected_part_of_expectation_error(expected_received_count, expectation_count_type, argument_list_matcher); end 477 | def format_args(args); end 478 | def format_received_args(args_for_multiple_calls); end 479 | def group_count(index, args); end 480 | def grouped_args(args); end 481 | def initialize(target = nil); end 482 | def intro(unwrapped = nil); end 483 | def list_of_exactly_one_string?(args); end 484 | def method_call_args_description(args, generic_prefix = nil, matcher_prefix = nil); end 485 | def notify(*args); end 486 | def opts; end 487 | def opts=(arg0); end 488 | def prepend_to_backtrace(exception, line); end 489 | def raise_already_invoked_error(message, calling_customization); end 490 | def raise_cant_constrain_count_for_negated_have_received_error(count_constraint); end 491 | def raise_double_negation_error(wrapped_expression); end 492 | def raise_expectation_error(message, expected_received_count, argument_list_matcher, actual_received_count, expectation_count_type, args, backtrace_line = nil, source_id = nil); end 493 | def raise_expectation_on_mocked_method(method); end 494 | def raise_expectation_on_nil_error(method_name); end 495 | def raise_expectation_on_unstubbed_method(method); end 496 | def raise_expired_test_double_error; end 497 | def raise_have_received_disallowed(type, reason); end 498 | def raise_invalid_arguments_error(verifier); end 499 | def raise_method_not_stubbed_error(method_name); end 500 | def raise_missing_block_error(args_to_yield); end 501 | def raise_missing_default_stub_error(expectation, args_for_multiple_calls); end 502 | def raise_non_public_error(method_name, visibility); end 503 | def raise_only_valid_on_a_partial_double(method); end 504 | def raise_out_of_order_error(message); end 505 | def raise_similar_message_args_error(expectation, args_for_multiple_calls, backtrace_line = nil); end 506 | def raise_unexpected_message_args_error(expectation, args_for_multiple_calls, source_id = nil); end 507 | def raise_unexpected_message_error(message, args); end 508 | def raise_unimplemented_error(doubled_module, method_name, object); end 509 | def raise_verifying_double_not_defined_error(ref); end 510 | def raise_wrong_arity_error(args_to_yield, signature); end 511 | def received_part_of_expectation_error(actual_received_count, args); end 512 | def times(count); end 513 | def unexpected_arguments_message(expected_args_string, actual_args_string); end 514 | def unpack_string_args(formatted_expected_args, actual_args); end 515 | end 516 | class RSpec::Mocks::RootSpace 517 | def any_instance_proxy_for(*_args); end 518 | def any_instance_recorder_for(*_args); end 519 | def any_instance_recorders_from_ancestry_of(_object); end 520 | def new_scope; end 521 | def proxy_for(*_args); end 522 | def raise_lifecycle_message; end 523 | def register_constant_mutator(_mutator); end 524 | def registered?(_object); end 525 | def reset_all; end 526 | def superclass_proxy_for(*_args); end 527 | def verify_all; end 528 | end 529 | class RSpec::Mocks::Space 530 | def any_instance_mutex; end 531 | def any_instance_proxy_for(klass); end 532 | def any_instance_recorder_for(klass, only_return_existing = nil); end 533 | def any_instance_recorder_not_found_for(id, klass); end 534 | def any_instance_recorders; end 535 | def any_instance_recorders_from_ancestry_of(object); end 536 | def class_proxy_with_callback_verification_strategy(object, strategy); end 537 | def constant_mutator_for(name); end 538 | def ensure_registered(object); end 539 | def id_for(object); end 540 | def initialize; end 541 | def new_mutex; end 542 | def new_scope; end 543 | def proxies; end 544 | def proxies_of(klass); end 545 | def proxy_for(object); end 546 | def proxy_mutex; end 547 | def proxy_not_found_for(id, object); end 548 | def register_constant_mutator(mutator); end 549 | def registered?(object); end 550 | def reset_all; end 551 | def superclass_proxy_for(klass); end 552 | def superclass_proxy_not_found_for(id, object); end 553 | def verify_all; end 554 | end 555 | class RSpec::Mocks::NestedSpace < RSpec::Mocks::Space 556 | def any_instance_recorder_not_found_for(id, klass); end 557 | def constant_mutator_for(name); end 558 | def initialize(parent); end 559 | def proxies_of(klass); end 560 | def proxy_not_found_for(id, object); end 561 | def registered?(object); end 562 | end 563 | class RSpec::Mocks::Constant 564 | def hidden=(arg0); end 565 | def hidden?; end 566 | def initialize(name); end 567 | def inspect; end 568 | def mutated?; end 569 | def name; end 570 | def original_value; end 571 | def original_value=(arg0); end 572 | def previously_defined=(arg0); end 573 | def previously_defined?; end 574 | def self.original(name); end 575 | def self.unmutated(name); end 576 | def stubbed=(arg0); end 577 | def stubbed?; end 578 | def to_s; end 579 | def valid_name=(arg0); end 580 | def valid_name?; end 581 | extend RSpec::Support::RecursiveConstMethods 582 | end 583 | class RSpec::Mocks::ConstantMutator 584 | def self.hide(constant_name); end 585 | def self.mutate(mutator); end 586 | def self.raise_on_invalid_const; end 587 | def self.stub(constant_name, value, options = nil); end 588 | extend RSpec::Support::RecursiveConstMethods 589 | end 590 | class RSpec::Mocks::ConstantMutator::BaseMutator 591 | def full_constant_name; end 592 | def idempotently_reset; end 593 | def initialize(full_constant_name, mutated_value, transfer_nested_constants); end 594 | def original_value; end 595 | def to_constant; end 596 | include RSpec::Support::RecursiveConstMethods 597 | end 598 | class RSpec::Mocks::ConstantMutator::ConstantHider < RSpec::Mocks::ConstantMutator::BaseMutator 599 | def mutate; end 600 | def reset; end 601 | def to_constant; end 602 | end 603 | class RSpec::Mocks::ConstantMutator::DefinedConstantReplacer < RSpec::Mocks::ConstantMutator::BaseMutator 604 | def initialize(*args); end 605 | def mutate; end 606 | def reset; end 607 | def should_transfer_nested_constants?; end 608 | def to_constant; end 609 | def transfer_nested_constants; end 610 | def verify_constants_to_transfer!; end 611 | end 612 | class RSpec::Mocks::ConstantMutator::UndefinedConstantSetter < RSpec::Mocks::ConstantMutator::BaseMutator 613 | def mutate; end 614 | def name_for(parent, name); end 615 | def reset; end 616 | def to_constant; end 617 | end 618 | module RSpec::Mocks::TargetDelegationClassMethods 619 | def delegate_not_to(matcher_method, options = nil); end 620 | def delegate_to(matcher_method); end 621 | def disallow_negation(method_name); end 622 | end 623 | module RSpec::Mocks::TargetDelegationInstanceMethods 624 | def define_matcher(matcher, name, &block); end 625 | def matcher_allowed?(matcher); end 626 | def raise_negation_unsupported(method_name, matcher); end 627 | def raise_unsupported_matcher(method_name, matcher); end 628 | def target; end 629 | end 630 | class RSpec::Mocks::TargetBase 631 | def initialize(target); end 632 | extend RSpec::Mocks::TargetDelegationClassMethods 633 | include RSpec::Mocks::TargetDelegationInstanceMethods 634 | end 635 | module RSpec::Mocks::ExpectationTargetMethods 636 | def expression; end 637 | def not_to(matcher, &block); end 638 | def to(matcher, &block); end 639 | def to_not(matcher, &block); end 640 | extend RSpec::Mocks::TargetDelegationClassMethods 641 | include RSpec::Mocks::TargetDelegationInstanceMethods 642 | end 643 | class RSpec::Mocks::ExpectationTarget < RSpec::Mocks::TargetBase 644 | include RSpec::Mocks::ExpectationTargetMethods 645 | end 646 | class RSpec::Mocks::AllowanceTarget < RSpec::Mocks::TargetBase 647 | def expression; end 648 | def not_to(matcher, *_args); end 649 | def to(matcher, &block); end 650 | def to_not(matcher, *_args); end 651 | end 652 | class RSpec::Mocks::AnyInstanceAllowanceTarget < RSpec::Mocks::TargetBase 653 | def expression; end 654 | def not_to(matcher, *_args); end 655 | def to(matcher, &block); end 656 | def to_not(matcher, *_args); end 657 | end 658 | class RSpec::Mocks::AnyInstanceExpectationTarget < RSpec::Mocks::TargetBase 659 | def expression; end 660 | def not_to(matcher, &block); end 661 | def to(matcher, &block); end 662 | def to_not(matcher, &block); end 663 | end 664 | module RSpec::Mocks::Syntax 665 | def self.default_should_syntax_host; end 666 | def self.disable_expect(syntax_host = nil); end 667 | def self.disable_should(syntax_host = nil); end 668 | def self.enable_expect(syntax_host = nil); end 669 | def self.enable_should(syntax_host = nil); end 670 | def self.expect_enabled?(syntax_host = nil); end 671 | def self.should_enabled?(syntax_host = nil); end 672 | def self.warn_about_should!; end 673 | def self.warn_unless_should_configured(method_name, replacement = nil); end 674 | end 675 | class BasicObject 676 | def as_null_object; end 677 | def null_object?; end 678 | def received_message?(message, *args, &block); end 679 | def should_not_receive(message, &block); end 680 | def should_receive(message, opts = nil, &block); end 681 | def stub(message_or_hash, opts = nil, &block); end 682 | def stub_chain(*chain, &blk); end 683 | def unstub(message); end 684 | end 685 | class Class < Module 686 | def any_instance; end 687 | end 688 | class RSpec::Mocks::Configuration 689 | def add_stub_and_should_receive_to(*modules); end 690 | def allow_message_expectations_on_nil; end 691 | def allow_message_expectations_on_nil=(arg0); end 692 | def before_verifying_doubles(&block); end 693 | def color?; end 694 | def initialize; end 695 | def patch_marshal_to_support_partial_doubles=(val); end 696 | def reset_syntaxes_to_default; end 697 | def syntax; end 698 | def syntax=(*values); end 699 | def temporarily_suppress_partial_double_verification; end 700 | def temporarily_suppress_partial_double_verification=(arg0); end 701 | def transfer_nested_constants=(arg0); end 702 | def transfer_nested_constants?; end 703 | def verify_doubled_constant_names=(arg0); end 704 | def verify_doubled_constant_names?; end 705 | def verify_partial_doubles=(val); end 706 | def verify_partial_doubles?; end 707 | def verifying_double_callbacks; end 708 | def when_declaring_verifying_double(&block); end 709 | def yield_receiver_to_any_instance_implementation_blocks=(arg0); end 710 | def yield_receiver_to_any_instance_implementation_blocks?; end 711 | end 712 | class RSpec::Mocks::VerifyingMessageExpectation < RSpec::Mocks::MessageExpectation 713 | def initialize(*args); end 714 | def method_reference; end 715 | def method_reference=(arg0); end 716 | def validate_expected_arguments!; end 717 | def with(*args, &block); end 718 | end 719 | class RSpec::Mocks::MethodReference 720 | def defined?; end 721 | def implemented?; end 722 | def initialize(object_reference, method_name); end 723 | def original_method; end 724 | def self.for(object_reference, method_name); end 725 | def self.instance_method_visibility_for(klass, method_name); end 726 | def self.method_defined_at_any_visibility?(klass, method_name); end 727 | def self.method_visibility_for(object, method_name); end 728 | def unimplemented?; end 729 | def visibility; end 730 | def with_signature; end 731 | end 732 | class RSpec::Mocks::InstanceMethodReference < RSpec::Mocks::MethodReference 733 | def find_method(mod); end 734 | def method_defined?(mod); end 735 | def method_implemented?(mod); end 736 | def visibility_from(mod); end 737 | end 738 | class RSpec::Mocks::ObjectMethodReference < RSpec::Mocks::MethodReference 739 | def find_method(object); end 740 | def method_defined?(object); end 741 | def method_implemented?(object); end 742 | def self.for(object_reference, method_name); end 743 | def visibility_from(object); end 744 | end 745 | class RSpec::Mocks::ClassNewMethodReference < RSpec::Mocks::ObjectMethodReference 746 | def self.applies_to?(method_name); end 747 | def with_signature; end 748 | end 749 | class RSpec::Mocks::CallbackInvocationStrategy 750 | def call(doubled_module); end 751 | end 752 | class RSpec::Mocks::NoCallbackInvocationStrategy 753 | def call(_doubled_module); end 754 | end 755 | module RSpec::Mocks::VerifyingProxyMethods 756 | def add_message_expectation(method_name, opts = nil, &block); end 757 | def add_simple_stub(method_name, *args); end 758 | def add_stub(method_name, opts = nil, &implementation); end 759 | def ensure_implemented(method_name); end 760 | def ensure_publicly_implemented(method_name, _object); end 761 | end 762 | class RSpec::Mocks::VerifyingProxy < RSpec::Mocks::TestDoubleProxy 763 | def initialize(object, order_group, doubled_module, method_reference_class); end 764 | def method_reference; end 765 | def validate_arguments!(method_name, args); end 766 | def visibility_for(method_name); end 767 | include RSpec::Mocks::VerifyingProxyMethods 768 | end 769 | class RSpec::Mocks::VerifyingPartialDoubleProxy < RSpec::Mocks::PartialDoubleProxy 770 | def ensure_implemented(_method_name); end 771 | def initialize(object, expectation_ordering, optional_callback_invocation_strategy = nil); end 772 | def method_reference; end 773 | include RSpec::Mocks::VerifyingProxyMethods 774 | end 775 | class RSpec::Mocks::VerifyingPartialClassDoubleProxy < RSpec::Mocks::VerifyingPartialDoubleProxy 776 | include RSpec::Mocks::PartialClassDoubleProxyMethods 777 | end 778 | class RSpec::Mocks::VerifyingMethodDouble < RSpec::Mocks::MethodDouble 779 | def add_expectation(*args, &block); end 780 | def add_stub(*args, &block); end 781 | def initialize(object, method_name, proxy, method_reference); end 782 | def message_expectation_class; end 783 | def proxy_method_invoked(obj, *args, &block); end 784 | def validate_arguments!(actual_args); end 785 | end 786 | class RSpec::Mocks::VerifyingExistingMethodDouble < RSpec::Mocks::VerifyingMethodDouble 787 | def initialize(object, method_name, proxy); end 788 | def self.for(object, method_name, proxy); end 789 | def unimplemented?; end 790 | def with_signature; end 791 | end 792 | class RSpec::Mocks::VerifyingExistingClassNewMethodDouble < RSpec::Mocks::VerifyingExistingMethodDouble 793 | def with_signature; end 794 | end 795 | module RSpec::Mocks::VerifyingDouble 796 | def __send__(name, *args, &block); end 797 | def initialize(doubled_module, *args); end 798 | def method_missing(message, *args, &block); end 799 | def respond_to?(message, include_private = nil); end 800 | def send(name, *args, &block); end 801 | end 802 | class RSpec::Mocks::InstanceVerifyingDouble 803 | def __build_mock_proxy(order_group); end 804 | include RSpec::Mocks::TestDouble 805 | include RSpec::Mocks::VerifyingDouble 806 | end 807 | module RSpec::Mocks::ObjectVerifyingDoubleMethods 808 | def __build_mock_proxy(order_group); end 809 | def as_stubbed_const(options = nil); end 810 | include RSpec::Mocks::TestDouble 811 | include RSpec::Mocks::VerifyingDouble 812 | end 813 | class RSpec::Mocks::ObjectVerifyingDouble 814 | include RSpec::Mocks::ObjectVerifyingDoubleMethods 815 | end 816 | class RSpec::Mocks::ClassVerifyingDouble < Module 817 | include RSpec::Mocks::ObjectVerifyingDoubleMethods 818 | end 819 | module RSpec::Mocks::Version 820 | end 821 | module RSpec::Support 822 | def self.require_rspec_mocks(f); end 823 | end 824 | module RSpec::Mocks::Matchers 825 | end 826 | module RSpec::Mocks::Matchers::Matcher 827 | end 828 | module RSpec::Mocks::AnyInstance 829 | def self.error_generator; end 830 | end 831 | class RSpec::Mocks::AnyInstance::Chain 832 | def constrained_to_any_of?(*constraints); end 833 | def expectation_fulfilled!; end 834 | def initialize(recorder, *args, &block); end 835 | def last_message; end 836 | def matches_args?(*args); end 837 | def messages; end 838 | def negated?; end 839 | def never; end 840 | def playback!(instance); end 841 | def record(rspec_method_name, *args, &block); end 842 | def with(*args, &block); end 843 | include RSpec::Mocks::AnyInstance::Chain::Customizations 844 | end 845 | module RSpec::Mocks::AnyInstance::Chain::Customizations 846 | def and_call_original(*args, &block); end 847 | def and_raise(*args, &block); end 848 | def and_return(*args, &block); end 849 | def and_throw(*args, &block); end 850 | def and_wrap_original(*args, &block); end 851 | def and_yield(*args, &block); end 852 | def at_least(*args, &block); end 853 | def at_most(*args, &block); end 854 | def exactly(*args, &block); end 855 | def never(*args, &block); end 856 | def once(*args, &block); end 857 | def self.record(method_name); end 858 | def thrice(*args, &block); end 859 | def time(*args, &block); end 860 | def times(*args, &block); end 861 | def twice(*args, &block); end 862 | def with(*args, &block); end 863 | end 864 | class RSpec::Mocks::AnyInstance::ErrorGenerator < RSpec::Mocks::ErrorGenerator 865 | def raise_does_not_implement_error(klass, method_name); end 866 | def raise_message_already_received_by_other_instance_error(method_name, object_inspect, invoked_instance); end 867 | def raise_not_supported_with_prepend_error(method_name, problem_mod); end 868 | def raise_second_instance_received_message_error(unfulfilled_expectations); end 869 | end 870 | class RSpec::Mocks::AnyInstance::StubChain < RSpec::Mocks::AnyInstance::Chain 871 | def create_message_expectation_on(instance); end 872 | def expectation_fulfilled?; end 873 | def invocation_order; end 874 | def verify_invocation_order(rspec_method_name, *_args, &_block); end 875 | end 876 | class RSpec::Mocks::AnyInstance::StubChainChain < RSpec::Mocks::AnyInstance::StubChain 877 | def create_message_expectation_on(instance); end 878 | def initialize(*args); end 879 | def invocation_order; end 880 | end 881 | class RSpec::Mocks::AnyInstance::ExpectChainChain < RSpec::Mocks::AnyInstance::StubChain 882 | def create_message_expectation_on(instance); end 883 | def expectation_fulfilled?; end 884 | def initialize(*args); end 885 | def invocation_order; end 886 | def playback!(instance); end 887 | end 888 | class RSpec::Mocks::AnyInstance::ExpectationChain < RSpec::Mocks::AnyInstance::Chain 889 | def expectation_fulfilled?; end 890 | def initialize(*args, &block); end 891 | def verify_invocation_order(_rspec_method_name, *_args, &_block); end 892 | end 893 | class RSpec::Mocks::AnyInstance::PositiveExpectationChain < RSpec::Mocks::AnyInstance::ExpectationChain 894 | def create_message_expectation_on(instance); end 895 | def invocation_order; end 896 | end 897 | class RSpec::Mocks::AnyInstance::MessageChains 898 | def [](method_name); end 899 | def add(method_name, chain); end 900 | def all_expectations_fulfilled?; end 901 | def each_unfulfilled_expectation_matching(method_name, *args); end 902 | def has_expectation?(method_name); end 903 | def initialize; end 904 | def playback!(instance, method_name); end 905 | def raise_if_second_instance_to_receive_message(instance); end 906 | def received_expected_message!(method_name); end 907 | def remove_stub_chains_for!(method_name); end 908 | def unfulfilled_expectations; end 909 | end 910 | class RSpec::Mocks::AnyInstance::Recorder 911 | def allow_no_prepended_module_definition_of(method_name); end 912 | def already_observing?(method_name); end 913 | def ancestor_is_an_observer?(method_name); end 914 | def backup_method!(method_name); end 915 | def build_alias_method_name(method_name); end 916 | def expect_chain(*method_names_and_optional_return_values, &block); end 917 | def initialize(klass); end 918 | def instance_that_received(method_name); end 919 | def klass; end 920 | def mark_invoked!(method_name); end 921 | def message_chains; end 922 | def normalize_chain(*args); end 923 | def notify_received_message(_object, message, args, _blk); end 924 | def observe!(method_name); end 925 | def playback!(instance, method_name); end 926 | def public_protected_or_private_method_defined?(method_name); end 927 | def received_expected_message!(method_name); end 928 | def remove_dummy_method!(method_name); end 929 | def restore_method!(method_name); end 930 | def restore_original_method!(method_name); end 931 | def should_not_receive(method_name, &block); end 932 | def should_receive(method_name, &block); end 933 | def stop_all_observation!; end 934 | def stop_observing!(method_name); end 935 | def stub(method_name, &block); end 936 | def stub_chain(*method_names_and_optional_return_values, &block); end 937 | def stubs; end 938 | def super_class_observers_for(method_name); end 939 | def super_class_observing?(method_name); end 940 | def unstub(method_name); end 941 | def verify; end 942 | end 943 | class RSpec::Mocks::AnyInstance::Proxy 944 | def expect_chain(*chain, &block); end 945 | def initialize(recorder, target_proxies); end 946 | def klass; end 947 | def perform_proxying(method_name, args, block, &target_proxy_block); end 948 | def should_not_receive(method_name, &block); end 949 | def should_receive(method_name, &block); end 950 | def stub(method_name_or_method_map, &block); end 951 | def stub_chain(*chain, &block); end 952 | def unstub(method_name); end 953 | end 954 | class RSpec::Mocks::AnyInstance::FluentInterfaceProxy 955 | def initialize(targets); end 956 | def method_missing(*args, &block); end 957 | def respond_to_missing?(method_name, include_private = nil); end 958 | end 959 | class RSpec::Mocks::MessageChain 960 | def block; end 961 | def chain; end 962 | def chain_on(object, *chain, &block); end 963 | def find_matching_expectation; end 964 | def find_matching_stub; end 965 | def format_chain(*chain, &blk); end 966 | def initialize(object, *chain, &blk); end 967 | def object; end 968 | def setup_chain; end 969 | end 970 | class RSpec::Mocks::ExpectChain < RSpec::Mocks::MessageChain 971 | def expectation(object, message, &return_block); end 972 | def self.expect_chain_on(object, *chain, &blk); end 973 | end 974 | class RSpec::Mocks::StubChain < RSpec::Mocks::MessageChain 975 | def expectation(object, message, &return_block); end 976 | def self.stub_chain_on(object, *chain, &blk); end 977 | end 978 | class RSpec::Mocks::MarshalExtension 979 | def self.patch!; end 980 | def self.unpatch!; end 981 | end 982 | class RSpec::Mocks::Matchers::HaveReceived 983 | def apply_constraints_to(expectation); end 984 | def at_least(*args); end 985 | def at_most(*args); end 986 | def capture_failure_message; end 987 | def count_constraint; end 988 | def description; end 989 | def disallow(type, reason = nil); end 990 | def does_not_match?(subject); end 991 | def ensure_count_unconstrained; end 992 | def exactly(*args); end 993 | def expect; end 994 | def expected_messages_received_in_order?; end 995 | def failure_message; end 996 | def failure_message_when_negated; end 997 | def initialize(method_name, &block); end 998 | def matches?(subject, &block); end 999 | def mock_proxy; end 1000 | def name; end 1001 | def notify_failure_message; end 1002 | def once(*args); end 1003 | def ordered(*args); end 1004 | def setup_allowance(_subject, &_block); end 1005 | def setup_any_instance_allowance(_subject, &_block); end 1006 | def setup_any_instance_expectation(_subject, &_block); end 1007 | def setup_any_instance_negative_expectation(_subject, &_block); end 1008 | def setup_expectation(subject, &block); end 1009 | def setup_negative_expectation(subject, &block); end 1010 | def thrice(*args); end 1011 | def time(*args); end 1012 | def times(*args); end 1013 | def twice(*args); end 1014 | def with(*args); end 1015 | include RSpec::Mocks::Matchers::Matcher 1016 | end 1017 | class RSpec::Mocks::Matchers::ExpectationCustomization 1018 | def block; end 1019 | def block=(arg0); end 1020 | def initialize(method_name, args, block); end 1021 | def playback_onto(expectation); end 1022 | end 1023 | class RSpec::Mocks::Matchers::Receive 1024 | def and_call_original(*args, &block); end 1025 | def and_invoke(*args, &block); end 1026 | def and_raise(*args, &block); end 1027 | def and_return(*args, &block); end 1028 | def and_throw(*args, &block); end 1029 | def and_wrap_original(*args, &block); end 1030 | def and_yield(*args, &block); end 1031 | def at_least(*args, &block); end 1032 | def at_most(*args, &block); end 1033 | def describable; end 1034 | def description; end 1035 | def does_not_match?(subject, &block); end 1036 | def exactly(*args, &block); end 1037 | def initialize(message, block); end 1038 | def matches?(subject, &block); end 1039 | def move_block_to_last_customization(block); end 1040 | def name; end 1041 | def never(*args, &block); end 1042 | def once(*args, &block); end 1043 | def ordered(*args, &block); end 1044 | def setup_allowance(subject, &block); end 1045 | def setup_any_instance_allowance(subject, &block); end 1046 | def setup_any_instance_expectation(subject, &block); end 1047 | def setup_any_instance_method_substitute(subject, method, block); end 1048 | def setup_any_instance_negative_expectation(subject, &block); end 1049 | def setup_expectation(subject, &block); end 1050 | def setup_method_substitute(host, method, block, *args); end 1051 | def setup_mock_proxy_method_substitute(subject, method, block); end 1052 | def setup_negative_expectation(subject, &block); end 1053 | def thrice(*args, &block); end 1054 | def time(*args, &block); end 1055 | def times(*args, &block); end 1056 | def twice(*args, &block); end 1057 | def warn_if_any_instance(expression, subject); end 1058 | def with(*args, &block); end 1059 | include RSpec::Mocks::Matchers::Matcher 1060 | end 1061 | class RSpec::Mocks::Matchers::Receive::DefaultDescribable 1062 | def description_for(verb); end 1063 | def initialize(message); end 1064 | end 1065 | class RSpec::Mocks::Matchers::ReceiveMessageChain 1066 | def and_call_original(*args, &block); end 1067 | def and_invoke(*args, &block); end 1068 | def and_raise(*args, &block); end 1069 | def and_return(*args, &block); end 1070 | def and_throw(*args, &block); end 1071 | def and_yield(*args, &block); end 1072 | def description; end 1073 | def does_not_match?(*_args); end 1074 | def formatted_chain; end 1075 | def initialize(chain, &block); end 1076 | def matches?(subject, &block); end 1077 | def name; end 1078 | def replay_customizations(chain); end 1079 | def setup_allowance(subject, &block); end 1080 | def setup_any_instance_allowance(subject, &block); end 1081 | def setup_any_instance_expectation(subject, &block); end 1082 | def setup_expectation(subject, &block); end 1083 | def setup_negative_expectation(*_args); end 1084 | def with(*args, &block); end 1085 | include RSpec::Mocks::Matchers::Matcher 1086 | end 1087 | class RSpec::Mocks::Matchers::ReceiveMessages 1088 | def any_instance_of(subject); end 1089 | def description; end 1090 | def does_not_match?(_subject); end 1091 | def each_message_on(host); end 1092 | def initialize(message_return_value_hash); end 1093 | def matches?(subject); end 1094 | def name; end 1095 | def proxy_on(subject); end 1096 | def setup_allowance(subject); end 1097 | def setup_any_instance_allowance(subject); end 1098 | def setup_any_instance_expectation(subject); end 1099 | def setup_expectation(subject); end 1100 | def setup_negative_expectation(_subject); end 1101 | def warn_about_block; end 1102 | include RSpec::Mocks::Matchers::Matcher 1103 | end 1104 | --------------------------------------------------------------------------------