How to use initialize method of WebMock.Util Package

Best Webmock_ruby code snippet using WebMock.Util.initialize

webmock@3.14.0.rbi

Source:webmock@3.14.0.rbi Github

copy

Full Screen

...6 def read_body(dest = T.unsafe(nil), &block); end7end8class Net::WebMockNetBufferedIO < ::Net::BufferedIO9 # @return [WebMockNetBufferedIO] a new instance of WebMockNetBufferedIO10 def initialize(io, *args, **kwargs); end11 # https://github.com/ruby/ruby/blob/7d02441f0d6e5c9d0a73a024519eba4f69e36dce/lib/net/protocol.rb#L20812 # Modified version of method from ruby, so that nil is always passed into orig_read_nonblock to avoid timeout13 def rbuf_fill; end14end15# patch for StringIO behavior in Ruby 2.2.316# https://github.com/bblimke/webmock/issues/55817class PatchedStringIO < ::StringIO18 def orig_read_nonblock(*_arg0); end19 def read_nonblock(size, *args, **kwargs); end20end21class StubSocket22 # @return [StubSocket] a new instance of StubSocket23 def initialize(*args); end24 def close; end25 # @return [Boolean]26 def closed?; end27 # Returns the value of attribute continue_timeout.28 def continue_timeout; end29 # Sets the attribute continue_timeout30 #31 # @param value the value to set the attribute continue_timeout to.32 def continue_timeout=(_arg0); end33 def io; end34 # Returns the value of attribute read_timeout.35 def read_timeout; end36 # Sets the attribute read_timeout37 #38 # @param value the value to set the attribute read_timeout to.39 def read_timeout=(_arg0); end40 def readuntil(*args); end41 # Returns the value of attribute write_timeout.42 def write_timeout; end43 # Sets the attribute write_timeout44 #45 # @param value the value to set the attribute write_timeout to.46 def write_timeout=(_arg0); end47end48class StubSocket::StubIO49 def setsockopt(*args); end50end51module WebMock52 include ::WebMock::API53 extend ::WebMock::API54 def after_request(*args, &block); end55 def allow_net_connect!(*args, &block); end56 def disable_net_connect!(*args, &block); end57 def net_connect_allowed?(*args, &block); end58 def registered_request?(*args, &block); end59 def reset_callbacks(*args, &block); end60 def reset_webmock(*args, &block); end61 class << self62 def after_request(options = T.unsafe(nil), &block); end63 def allow_net_connect!(options = T.unsafe(nil)); end64 def disable!(options = T.unsafe(nil)); end65 def disable_net_connect!(options = T.unsafe(nil)); end66 def disallow_net_connect!(options = T.unsafe(nil)); end67 def enable!(options = T.unsafe(nil)); end68 def enable_net_connect!(options = T.unsafe(nil)); end69 def globally_stub_request(order = T.unsafe(nil), &block); end70 def hide_body_diff!; end71 def hide_stubbing_instructions!; end72 # @private73 def included(clazz); end74 # @return [Boolean]75 def net_connect_allowed?(uri = T.unsafe(nil)); end76 # @return [Boolean]77 def net_connect_explicit_allowed?(allowed, uri = T.unsafe(nil)); end78 def print_executed_requests; end79 # @return [Boolean]80 def registered_request?(request_signature); end81 def request(method, uri); end82 def reset!; end83 def reset_callbacks; end84 def reset_webmock; end85 def show_body_diff!; end86 # @return [Boolean]87 def show_body_diff?; end88 def show_stubbing_instructions!; end89 # @return [Boolean]90 def show_stubbing_instructions?; end91 def version; end92 end93end94module WebMock::API95 extend ::WebMock::API96 def a_request(method, uri); end97 def assert_not_requested(*args, &block); end98 def assert_requested(*args, &block); end99 def hash_excluding(*args); end100 # Similar to RSpec::Mocks::ArgumentMatchers#hash_including()101 #102 # Matches a hash that includes the specified key(s) or key/value pairs.103 # Ignores any additional keys.104 #105 # @example106 #107 # object.should_receive(:message).with(hash_including(:key => val))108 # object.should_receive(:message).with(hash_including(:key))109 # object.should_receive(:message).with(hash_including(:key, :key2 => val2))110 def hash_including(*args); end111 def refute_requested(*args, &block); end112 def remove_request_stub(stub); end113 def reset_executed_requests!; end114 def stub_http_request(method, uri); end115 def stub_request(method, uri); end116 private117 # this is a based on RSpec::Mocks::ArgumentMatchers#anythingize_lonely_keys118 def anythingize_lonely_keys(*args); end119 def assert_request_not_requested(request, options = T.unsafe(nil)); end120 def assert_request_requested(request, options = T.unsafe(nil)); end121 def convert_uri_method_and_options_to_request_and_options(method, uri, options, &block); end122 class << self123 def request(method, uri); end124 end125end126class WebMock::AssertionFailure127 class << self128 # Returns the value of attribute error_class.129 def error_class; end130 # Sets the attribute error_class131 #132 # @param value the value to set the attribute error_class to.133 def error_class=(_arg0); end134 # @raise [@error_class]135 def failure(message); end136 end137end138class WebMock::BodyPattern139 include ::WebMock::RSpecMatcherDetector140 # @return [BodyPattern] a new instance of BodyPattern141 def initialize(pattern); end142 # @return [Boolean]143 def matches?(body, content_type = T.unsafe(nil)); end144 # Returns the value of attribute pattern.145 def pattern; end146 def to_s; end147 private148 def assert_non_multipart_body(content_type); end149 def body_as_hash(body, content_type); end150 def body_format(content_type); end151 # @return [Boolean]152 def empty_string?(string); end153 # Compare two hashes for equality154 #155 # For two hashes to match they must have the same length and all156 # values must match when compared using `#===`.157 #158 # The following hashes are examples of matches:159 #160 # {a: /\d+/} and {a: '123'}161 #162 # {a: '123'} and {a: '123'}163 #164 # {a: {b: /\d+/}} and {a: {b: '123'}}165 #166 # {a: {b: 'wow'}} and {a: {b: 'wow'}}167 #168 # @param query_parameters [Hash] typically the result of parsing169 # JSON, XML or URL encoded parameters.170 # @param pattern [Hash] which contains keys with a string, hash or171 # regular expression value to use for comparison.172 # @return [Boolean] true if the paramaters match the comparison173 # hash, false if not.174 def matching_body_hashes?(query_parameters, pattern, content_type); end175 def normalize_hash(hash); end176 # @return [Boolean]177 def url_encoded_body?(content_type); end178end179WebMock::BodyPattern::BODY_FORMATS = T.let(T.unsafe(nil), Hash)180class WebMock::CallbackRegistry181 class << self182 def add_callback(options, block); end183 # @return [Boolean]184 def any_callbacks?; end185 def callbacks; end186 def invoke_callbacks(options, request_signature, response); end187 def reset; end188 end189end190class WebMock::Config191 include ::Singleton192 extend ::Singleton::SingletonClassMethods193 # @return [Config] a new instance of Config194 def initialize; end195 # Returns the value of attribute allow.196 def allow; end197 # Sets the attribute allow198 #199 # @param value the value to set the attribute allow to.200 def allow=(_arg0); end201 # Returns the value of attribute allow_localhost.202 def allow_localhost; end203 # Sets the attribute allow_localhost204 #205 # @param value the value to set the attribute allow_localhost to.206 def allow_localhost=(_arg0); end207 # Returns the value of attribute allow_net_connect.208 def allow_net_connect; end209 # Sets the attribute allow_net_connect210 #211 # @param value the value to set the attribute allow_net_connect to.212 def allow_net_connect=(_arg0); end213 # Returns the value of attribute net_http_connect_on_start.214 def net_http_connect_on_start; end215 # Sets the attribute net_http_connect_on_start216 #217 # @param value the value to set the attribute net_http_connect_on_start to.218 def net_http_connect_on_start=(_arg0); end219 # Returns the value of attribute query_values_notation.220 def query_values_notation; end221 # Sets the attribute query_values_notation222 #223 # @param value the value to set the attribute query_values_notation to.224 def query_values_notation=(_arg0); end225 # Returns the value of attribute show_body_diff.226 def show_body_diff; end227 # Sets the attribute show_body_diff228 #229 # @param value the value to set the attribute show_body_diff to.230 def show_body_diff=(_arg0); end231 # Returns the value of attribute show_stubbing_instructions.232 def show_stubbing_instructions; end233 # Sets the attribute show_stubbing_instructions234 #235 # @param value the value to set the attribute show_stubbing_instructions to.236 def show_stubbing_instructions=(_arg0); end237end238class WebMock::Deprecation239 class << self240 def warning(message); end241 end242end243class WebMock::DynamicResponse < ::WebMock::Response244 # @return [DynamicResponse] a new instance of DynamicResponse245 def initialize(responder); end246 def evaluate(request_signature); end247 # Returns the value of attribute responder.248 def responder; end249 # Sets the attribute responder250 #251 # @param value the value to set the attribute responder to.252 def responder=(_arg0); end253end254class WebMock::HashValidator255 # @return [HashValidator] a new instance of HashValidator256 def initialize(hash); end257 # This code is based on https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/keys.rb258 def validate_keys(*valid_keys); end259end260class WebMock::HeadersPattern261 # @return [HeadersPattern] a new instance of HeadersPattern262 def initialize(pattern); end263 # @return [Boolean]264 def matches?(headers); end265 def pp_to_s; end266 def to_s; end267 private268 # @return [Boolean]269 def empty_headers?(headers); end270end271class WebMock::HttpLibAdapter272 class << self273 def adapter_for(lib); end274 end275end276class WebMock::HttpLibAdapterRegistry277 include ::Singleton278 extend ::Singleton::SingletonClassMethods279 # @return [HttpLibAdapterRegistry] a new instance of HttpLibAdapterRegistry280 def initialize; end281 def each_adapter(&block); end282 # Returns the value of attribute http_lib_adapters.283 def http_lib_adapters; end284 # Sets the attribute http_lib_adapters285 #286 # @param value the value to set the attribute http_lib_adapters to.287 def http_lib_adapters=(_arg0); end288 def register(lib, adapter); end289end290module WebMock::HttpLibAdapters; end291class WebMock::HttpLibAdapters::NetHttpAdapter < ::WebMock::HttpLibAdapter292 class << self293 def disable!; end294 def enable!; end295 end296end297WebMock::HttpLibAdapters::NetHttpAdapter::OriginalNetBufferedIO = Net::BufferedIO298WebMock::HttpLibAdapters::NetHttpAdapter::OriginalNetHTTP = Net::HTTP299module WebMock::Matchers; end300# this is a based on RSpec::Mocks::ArgumentMatchers::AnyArgMatcher301class WebMock::Matchers::AnyArgMatcher302 # @return [AnyArgMatcher] a new instance of AnyArgMatcher303 def initialize(ignore); end304 def ==(other); end305end306# Base class for Hash matchers307# https://github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/argument_matchers.rb308class WebMock::Matchers::HashArgumentMatcher309 # @return [HashArgumentMatcher] a new instance of HashArgumentMatcher310 def initialize(expected); end311 def ==(_actual, &block); end312 class << self313 def from_rspec_matcher(matcher); end314 end315end316# this is a based on RSpec::Mocks::ArgumentMatchers::HashExcludingMatcher317# https://github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/argument_matchers.rb318class WebMock::Matchers::HashExcludingMatcher < ::WebMock::Matchers::HashArgumentMatcher319 def ==(actual); end320 def inspect; end321end322# this is a based on RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher323# https://github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/argument_matchers.rb324class WebMock::Matchers::HashIncludingMatcher < ::WebMock::Matchers::HashArgumentMatcher325 def ==(actual); end326 def inspect; end327end328class WebMock::MethodPattern329 # @return [MethodPattern] a new instance of MethodPattern330 def initialize(pattern); end331 # @return [Boolean]332 def matches?(method); end333 def to_s; end334end335class WebMock::NetConnectNotAllowedError < ::Exception336 # @return [NetConnectNotAllowedError] a new instance of NetConnectNotAllowedError337 def initialize(request_signature); end338end339module WebMock::NetHTTPUtility340 class << self341 def check_right_http_connection; end342 def get_uri(net_http, path); end343 def puts_warning_for_right_http_if_needed; end344 def request_signature_from_request(net_http, request, body = T.unsafe(nil)); end345 def validate_headers(headers); end346 end347end348module WebMock::RSpecMatcherDetector349 # @return [Boolean]350 def rSpecHashExcludingMatcher?(matcher); end351 # @return [Boolean]352 def rSpecHashIncludingMatcher?(matcher); end353end354class WebMock::RackResponse < ::WebMock::Response355 # @return [RackResponse] a new instance of RackResponse356 def initialize(app); end357 def body_from_rack_response(response); end358 def build_rack_env(request); end359 def evaluate(request); end360 def session; end361 def session_options; end362end363class WebMock::RequestBodyDiff364 # @return [RequestBodyDiff] a new instance of RequestBodyDiff365 def initialize(request_signature, request_stub); end366 def body_diff; end367 private368 # @return [Boolean]369 def parseable_json?(body_pattern); end370 # Returns the value of attribute request_signature.371 def request_signature; end372 def request_signature_body_hash; end373 # @return [Boolean]374 def request_signature_diffable?; end375 # @return [Boolean]376 def request_signature_parseable_json?; end377 # Returns the value of attribute request_stub.378 def request_stub; end379 def request_stub_body; end380 def request_stub_body_hash; end381 # @return [Boolean]382 def request_stub_diffable?; end383 # @return [Boolean]384 def request_stub_parseable_json?; end385end386class WebMock::RequestExecutionVerifier387 # @return [RequestExecutionVerifier] a new instance of RequestExecutionVerifier388 def initialize(request_pattern = T.unsafe(nil), expected_times_executed = T.unsafe(nil), at_least_times_executed = T.unsafe(nil), at_most_times_executed = T.unsafe(nil)); end389 # Returns the value of attribute at_least_times_executed.390 def at_least_times_executed; end391 # Sets the attribute at_least_times_executed392 #393 # @param value the value to set the attribute at_least_times_executed to.394 def at_least_times_executed=(_arg0); end395 # Returns the value of attribute at_most_times_executed.396 def at_most_times_executed; end397 # Sets the attribute at_most_times_executed398 #399 # @param value the value to set the attribute at_most_times_executed to.400 def at_most_times_executed=(_arg0); end401 def description; end402 # @return [Boolean]403 def does_not_match?; end404 # Returns the value of attribute expected_times_executed.405 def expected_times_executed; end406 # Sets the attribute expected_times_executed407 #408 # @param value the value to set the attribute expected_times_executed to.409 def expected_times_executed=(_arg0); end410 def failure_message; end411 def failure_message_when_negated; end412 # @return [Boolean]413 def matches?; end414 # Returns the value of attribute request_pattern.415 def request_pattern; end416 # Sets the attribute request_pattern417 #418 # @param value the value to set the attribute request_pattern to.419 def request_pattern=(_arg0); end420 # Returns the value of attribute times_executed.421 def times_executed; end422 # Sets the attribute times_executed423 #424 # @param value the value to set the attribute times_executed to.425 def times_executed=(_arg0); end426 private427 def failure_message_phrase(is_negated = T.unsafe(nil)); end428 def quantity_phrase(is_negated = T.unsafe(nil)); end429 def times(times); end430 class << self431 def executed_requests_message; end432 end433end434class WebMock::RequestPattern435 # @return [RequestPattern] a new instance of RequestPattern436 def initialize(method, uri, options = T.unsafe(nil)); end437 # Returns the value of attribute body_pattern.438 def body_pattern; end439 # Returns the value of attribute headers_pattern.440 def headers_pattern; end441 # @return [Boolean]442 def matches?(request_signature); end443 # Returns the value of attribute method_pattern.444 def method_pattern; end445 def to_s; end446 # Returns the value of attribute uri_pattern.447 def uri_pattern; end448 # @raise [ArgumentError]449 def with(options = T.unsafe(nil), &block); end450 private451 def assign_options(options); end452 def create_uri_pattern(uri); end453 def set_basic_auth_as_headers!(options); end454 def validate_basic_auth!(basic_auth); end455end456class WebMock::RequestRegistry457 include ::Singleton458 extend ::Singleton::SingletonClassMethods459 # @return [RequestRegistry] a new instance of RequestRegistry460 def initialize; end461 # Returns the value of attribute requested_signatures.462 def requested_signatures; end463 # Sets the attribute requested_signatures464 #465 # @param value the value to set the attribute requested_signatures to.466 def requested_signatures=(_arg0); end467 def reset!; end468 def times_executed(request_pattern); end469 def to_s; end470end471class WebMock::RequestSignature472 # @return [RequestSignature] a new instance of RequestSignature473 def initialize(method, uri, options = T.unsafe(nil)); end474 # @return [Boolean]475 def ==(other); end476 # Returns the value of attribute body.477 def body; end478 # Sets the attribute body479 #480 # @param value the value to set the attribute body to.481 def body=(_arg0); end482 # @return [Boolean]483 def eql?(other); end484 def hash; end485 # Returns the value of attribute headers.486 def headers; end487 def headers=(headers); end488 # @return [Boolean]489 def json_headers?; end490 # Returns the value of attribute method.491 def method; end492 # Sets the attribute method493 #494 # @param value the value to set the attribute method to.495 def method=(_arg0); end496 def to_s; end497 # Returns the value of attribute uri.498 def uri; end499 # Sets the attribute uri500 #501 # @param value the value to set the attribute uri to.502 def uri=(_arg0); end503 # @return [Boolean]504 def url_encoded?; end505 private506 def assign_options(options); end507end508class WebMock::RequestSignatureSnippet509 # @return [RequestSignatureSnippet] a new instance of RequestSignatureSnippet510 def initialize(request_signature); end511 # Returns the value of attribute request_signature.512 def request_signature; end513 # Returns the value of attribute request_stub.514 def request_stub; end515 def request_stubs; end516 def stubbing_instructions; end517 private518 def add_body_diff(stub, text); end519 def pretty_print_to_string(string_to_print); end520 def request_params; end521 def signature_stub_body_diff(stub); end522end523class WebMock::RequestStub524 # @return [RequestStub] a new instance of RequestStub525 def initialize(method, uri); end526 def and_raise(*exceptions); end527 def and_return(*response_hashes, &block); end528 def and_timeout; end529 # @return [Boolean]530 def has_responses?; end531 # @return [Boolean]532 def matches?(request_signature); end533 # Returns the value of attribute request_pattern.534 def request_pattern; end535 # Sets the attribute request_pattern536 #537 # @param value the value to set the attribute request_pattern to.538 def request_pattern=(_arg0); end539 def response; end540 def then; end541 def times(number); end542 def to_rack(app, options = T.unsafe(nil)); end543 def to_raise(*exceptions); end544 def to_return(*response_hashes, &block); end545 def to_s; end546 def to_timeout; end547 def with(params = T.unsafe(nil), &block); end548 class << self549 def from_request_signature(signature); end550 end551end552class WebMock::Response553 # @return [Response] a new instance of Response554 def initialize(options = T.unsafe(nil)); end555 def ==(other); end556 def body; end557 def body=(body); end558 def evaluate(request_signature); end559 def exception; end560 def exception=(exception); end561 def headers; end562 def headers=(headers); end563 def options=(options); end564 # @raise [@exception]565 def raise_error_if_any; end566 def should_timeout; end567 def status; end568 def status=(status); end569 private570 def assert_valid_body!; end571 def read_raw_response(raw_response); end572 def stringify_body!; end573end574class WebMock::Response::InvalidBody < ::StandardError; end575class WebMock::ResponseFactory576 class << self577 def response_for(options); end578 end579end580class WebMock::ResponsesSequence581 # @return [ResponsesSequence] a new instance of ResponsesSequence582 def initialize(responses); end583 # @return [Boolean]584 def end?; end585 def next_response; end586 # Returns the value of attribute times_to_repeat.587 def times_to_repeat; end588 # Sets the attribute times_to_repeat589 #590 # @param value the value to set the attribute times_to_repeat to.591 def times_to_repeat=(_arg0); end592 private593 def increase_position; end594end595class WebMock::StubRegistry596 include ::Singleton597 extend ::Singleton::SingletonClassMethods598 # @return [StubRegistry] a new instance of StubRegistry599 def initialize; end600 def global_stubs; end601 def register_global_stub(order = T.unsafe(nil), &block); end602 def register_request_stub(stub); end603 # @return [Boolean]604 def registered_request?(request_signature); end605 def remove_request_stub(stub); end606 # Returns the value of attribute request_stubs.607 def request_stubs; end608 # Sets the attribute request_stubs609 #610 # @param value the value to set the attribute request_stubs to.611 def request_stubs=(_arg0); end612 def reset!; end613 def response_for_request(request_signature); end614 private615 def evaluate_response_for_request(response, request_signature); end616 def request_stub_for(request_signature); end617end618class WebMock::StubRequestSnippet619 # @return [StubRequestSnippet] a new instance of StubRequestSnippet620 def initialize(request_stub); end621 def body_pattern; end622 def to_s(with_response = T.unsafe(nil)); end623end624class WebMock::URIAddressablePattern < ::WebMock::URIPattern625 def add_query_params(query_params); end626 private627 # @return [Boolean]628 def matches_with_variations?(uri); end629 def pattern_inspect; end630 # @return [Boolean]631 def pattern_matches?(uri); end632 # @return [Boolean]633 def template_matches_uri?(template, uri); end634end635class WebMock::URICallablePattern < ::WebMock::URIPattern636 private637 # @return [Boolean]638 def pattern_matches?(uri); end639end640class WebMock::URIPattern641 include ::WebMock::RSpecMatcherDetector642 # @return [URIPattern] a new instance of URIPattern643 def initialize(pattern); end644 def add_query_params(query_params); end645 # @return [Boolean]646 def matches?(uri); end647 def to_s; end648 private649 def pattern_inspect; end650 # @return [Boolean]651 def query_params_matches?(uri); end652end653class WebMock::URIRegexpPattern < ::WebMock::URIPattern654 private655 # @return [Boolean]656 def pattern_matches?(uri); end657end658class WebMock::URIStringPattern < ::WebMock::URIPattern659 def add_query_params(query_params); end660 private661 def pattern_inspect; end662 # @return [Boolean]663 def pattern_matches?(uri); end664end665module WebMock::Util; end666class WebMock::Util::HashCounter667 # @return [HashCounter] a new instance of HashCounter668 def initialize; end669 def each(&block); end670 def get(key); end671 # Returns the value of attribute hash.672 def hash; end673 # Sets the attribute hash674 #675 # @param value the value to set the attribute hash to.676 def hash=(_arg0); end677 def put(key, num = T.unsafe(nil)); end678 def select(&block); end679end680class WebMock::Util::HashKeysStringifier681 class << self682 def stringify_keys!(arg, options = T.unsafe(nil)); end683 end684end685class WebMock::Util::Headers686 class << self687 def basic_auth_header(*credentials); end688 def decode_userinfo_from_header(header); end689 def normalize_headers(headers); end690 def pp_headers_string(headers); end691 def sorted_headers_string(headers); end692 end693end694class WebMock::Util::JSON695 class << self696 # Ensure that ":" and "," are always followed by a space697 def convert_json_to_yaml(json); end698 def parse(json); end699 def unescape(str); end700 end701end702class WebMock::Util::JSON::ParseError < ::StandardError; end703class WebMock::Util::QueryMapper704 class << self705 def collect_query_hash(query_array, empty_accumulator, options); end706 def collect_query_parts(query); end707 def dehash(hash); end708 def fill_accumulator_for_dot(accumulator, key, value); end709 def fill_accumulator_for_flat(accumulator, key, value); end710 def fill_accumulator_for_flat_array(accumulator, key, value); end711 def fill_accumulator_for_subscript(accumulator, key, value); end712 def normalize_query_hash(query_hash, empty_accumulator, options); end713 # Converts the query component to a Hash value.714 #715 # @example716 # WebMock::Util::QueryMapper.query_to_values("?one=1&two=2&three=3")717 # #=> {"one" => "1", "two" => "2", "three" => "3"}718 # WebMock::Util::QueryMapper("?one[two][three]=four").query_values719 # #=> {"one" => {"two" => {"three" => "four"}}}720 # WebMock::Util::QueryMapper.query_to_values("?one.two.three=four",721 # :notation => :dot722 # )723 # #=> {"one" => {"two" => {"three" => "four"}}}724 # WebMock::Util::QueryMapper.query_to_values("?one[two][three]=four",725 # :notation => :flat726 # )727 # #=> {"one[two][three]" => "four"}728 # WebMock::Util::QueryMapper.query_to_values("?one.two.three=four",729 # :notation => :flat730 # )731 # #=> {"one.two.three" => "four"}732 # WebMock::Util::QueryMapper(733 # "?one[two][three][]=four&one[two][three][]=five"734 # )735 # #=> {"one" => {"two" => {"three" => ["four", "five"]}}}736 # WebMock::Util::QueryMapper.query_to_values(737 # "?one=two&one=three").query_values(:notation => :flat_array)738 # #=> [['one', 'two'], ['one', 'three']]739 # @option [Symbol]740 # @param [Symbol] [Hash] a customizable set of options741 # @return [Hash, Array] The query string parsed as a Hash or Array object.742 def query_to_values(query, options = T.unsafe(nil)); end743 # new_query_values have form [['key1', 'value1'], ['key2', 'value2']]744 def to_query(parent, value, options = T.unsafe(nil)); end745 # Sets the query component for this URI from a Hash object.746 # This method produces a query string using the :subscript notation.747 # An empty Hash will result in a nil query.748 #749 # @param new_query_values [Hash, #to_hash, Array] The new query values.750 def values_to_query(new_query_values, options = T.unsafe(nil)); end751 end752end753class WebMock::Util::URI754 class << self755 def encode_unsafe_chars_in_userinfo(userinfo); end756 def heuristic_parse(uri); end757 # @return [Boolean]758 def is_uri_localhost?(uri); end759 def normalize_uri(uri); end760 def sort_query_values(query_values); end761 def strip_default_port_from_uri_string(uri_string); end762 def uris_encoded_and_unencoded(uris); end763 def uris_with_inferred_port_and_without(uris); end764 def uris_with_scheme_and_without(uris); end765 def uris_with_trailing_slash_and_without(uris); end766 def variations_of_uri_as_strings(uri_object, only_with_scheme: T.unsafe(nil)); end767 end768end769WebMock::Util::URI::ADDRESSABLE_URIS = T.let(T.unsafe(nil), Hash)770module WebMock::Util::URI::CharacterClasses; end771WebMock::Util::URI::CharacterClasses::USERINFO = T.let(T.unsafe(nil), String)772WebMock::Util::URI::NORMALIZED_URIS = T.let(T.unsafe(nil), Hash)773class WebMock::Util::ValuesStringifier774 class << self775 def stringify_values(value); end776 end777end778WebMock::VERSION = T.let(T.unsafe(nil), String)779class WebMock::VersionChecker780 # @return [VersionChecker] a new instance of VersionChecker781 def initialize(library_name, library_version, min_patch_level, max_minor_version = T.unsafe(nil), unsupported_versions = T.unsafe(nil)); end782 def check_version!; end783 private784 def colorize(text, color_code); end785 def compare_version; end786 def parse_version(version); end787 # @return [Boolean]788 def too_high?; end789 # @return [Boolean]790 def too_low?; end791 # @return [Boolean]792 def unsupported_version?; end793 def version_requirement; end794 def warn_about_too_high; end795 def warn_about_too_low; end...

Full Screen

Full Screen

request_pattern.rb

Source:request_pattern.rb Github

copy

Full Screen

...5 end6 end7 class RequestPattern8 attr_reader :method_pattern, :uri_pattern, :body_pattern, :headers_pattern9 def initialize(method, uri, options = {})10 @method_pattern = MethodPattern.new(method)11 @uri_pattern = create_uri_pattern(uri)12 @body_pattern = nil13 @headers_pattern = nil14 @with_block = nil15 assign_options(options)16 end17 def with(options = {}, &block)18 raise ArgumentError.new('#with method invoked with no arguments. Either options hash or block must be specified.') if options.empty? && !block_given?19 assign_options(options)20 @with_block = block21 self22 end23 def matches?(request_signature)24 content_type = request_signature.headers['Content-Type'] if request_signature.headers25 content_type = content_type.split(';').first if content_type26 @method_pattern.matches?(request_signature.method) &&27 @uri_pattern.matches?(request_signature.uri) &&28 (@body_pattern.nil? || @body_pattern.matches?(request_signature.body, content_type || "")) &&29 (@headers_pattern.nil? || @headers_pattern.matches?(request_signature.headers)) &&30 (@with_block.nil? || @with_block.call(request_signature))31 end32 def to_s33 string = "#{@method_pattern.to_s.upcase}"34 string << " #{@uri_pattern.to_s}"35 string << " with body #{@body_pattern.to_s}" if @body_pattern36 string << " with headers #{@headers_pattern.to_s}" if @headers_pattern37 string << " with given block" if @with_block38 string39 end40 private41 def assign_options(options)42 options = WebMock::Util::HashKeysStringifier.stringify_keys!(options, deep: true)43 HashValidator.new(options).validate_keys('body', 'headers', 'query', 'basic_auth')44 set_basic_auth_as_headers!(options)45 @body_pattern = BodyPattern.new(options['body']) if options.has_key?('body')46 @headers_pattern = HeadersPattern.new(options['headers']) if options.has_key?('headers')47 @uri_pattern.add_query_params(options['query']) if options.has_key?('query')48 end49 def set_basic_auth_as_headers!(options)50 if basic_auth = options.delete('basic_auth')51 validate_basic_auth!(basic_auth)52 options['headers'] ||= {}53 options['headers']['Authorization'] = WebMock::Util::Headers.basic_auth_header(basic_auth[0],basic_auth[1])54 end55 end56 def validate_basic_auth!(basic_auth)57 if !basic_auth.is_a?(Array) || basic_auth.map{|e| e.is_a?(String)}.uniq != [true]58 raise "The basic_auth option value should be an array which contains 2 strings: username and password"59 end60 end61 def create_uri_pattern(uri)62 if uri.is_a?(Regexp)63 URIRegexpPattern.new(uri)64 elsif uri.is_a?(Addressable::Template)65 URIAddressablePattern.new(uri)66 else67 URIStringPattern.new(uri)68 end69 end70 end71 class MethodPattern72 def initialize(pattern)73 @pattern = pattern74 end75 def matches?(method)76 @pattern == method || @pattern == :any77 end78 def to_s79 @pattern.to_s80 end81 end82 class URIPattern83 include RSpecMatcherDetector84 def initialize(pattern)85 @pattern = case pattern86 when Addressable::URI, Addressable::Template87 pattern88 else89 WebMock::Util::URI.normalize_uri(pattern)90 end91 @query_params = nil92 end93 def add_query_params(query_params)94 @query_params = if query_params.is_a?(Hash)95 query_params96 elsif query_params.is_a?(WebMock::Matchers::HashIncludingMatcher)97 query_params98 elsif rSpecHashIncludingMatcher?(query_params)99 WebMock::Matchers::HashIncludingMatcher.from_rspec_matcher(query_params)100 else101 WebMock::Util::QueryMapper.query_to_values(query_params, notation: Config.instance.query_values_notation)102 end103 end104 def to_s105 str = @pattern.inspect106 str += " with query params #{@query_params.inspect}" if @query_params107 str108 end109 end110 class URIRegexpPattern < URIPattern111 def matches?(uri)112 WebMock::Util::URI.variations_of_uri_as_strings(uri).any? { |u| u.match(@pattern) } &&113 (@query_params.nil? || @query_params == WebMock::Util::QueryMapper.query_to_values(uri.query, notation: Config.instance.query_values_notation))114 end115 def to_s116 str = @pattern.inspect117 str += " with query params #{@query_params.inspect}" if @query_params118 str119 end120 end121 class URIAddressablePattern < URIPattern122 def matches?(uri)123 if @query_params.nil?124 # Let Addressable check the whole URI125 WebMock::Util::URI.variations_of_uri_as_strings(uri).any? { |u| @pattern.match(u) }126 else127 # WebMock checks the query, Addressable checks everything else128 WebMock::Util::URI.variations_of_uri_as_strings(uri.omit(:query)).any? { |u| @pattern.match(u) } &&129 @query_params == WebMock::Util::QueryMapper.query_to_values(uri.query)130 end131 end132 def add_query_params(query_params)133 warn "WebMock warning: ignoring query params in RFC 6570 template and checking them with WebMock"134 super(query_params)135 end136 def to_s137 str = @pattern.pattern.inspect138 str += " with variables #{@pattern.variables.inspect}" if @pattern.variables139 str140 end141 end142 class URIStringPattern < URIPattern143 def matches?(uri)144 if @pattern.is_a?(Addressable::URI)145 if @query_params146 uri.omit(:query) === @pattern &&147 (@query_params.nil? || @query_params == WebMock::Util::QueryMapper.query_to_values(uri.query, notation: Config.instance.query_values_notation))148 else149 uri === @pattern150 end151 else152 false153 end154 end155 def add_query_params(query_params)156 super157 if @query_params.is_a?(Hash) || @query_params.is_a?(String)158 query_hash = (WebMock::Util::QueryMapper.query_to_values(@pattern.query, notation: Config.instance.query_values_notation) || {}).merge(@query_params)159 @pattern.query = WebMock::Util::QueryMapper.values_to_query(query_hash, notation: WebMock::Config.instance.query_values_notation)160 @query_params = nil161 end162 end163 def to_s164 str = WebMock::Util::URI.strip_default_port_from_uri_string(@pattern.to_s)165 str += " with query params #{@query_params.inspect}" if @query_params166 str167 end168 end169 class BodyPattern170 include RSpecMatcherDetector171 BODY_FORMATS = {172 'text/xml' => :xml,173 'application/xml' => :xml,174 'application/json' => :json,175 'text/json' => :json,176 'application/javascript' => :json,177 'text/javascript' => :json,178 'text/html' => :html,179 'application/x-yaml' => :yaml,180 'text/yaml' => :yaml,181 'text/plain' => :plain182 }183 attr_reader :pattern184 def initialize(pattern)185 @pattern = if pattern.is_a?(Hash)186 normalize_hash(pattern)187 elsif rSpecHashIncludingMatcher?(pattern)188 WebMock::Matchers::HashIncludingMatcher.from_rspec_matcher(pattern)189 else190 pattern191 end192 end193 def matches?(body, content_type = "")194 assert_non_multipart_body(content_type)195 if (@pattern).is_a?(Hash)196 return true if @pattern.empty?197 matching_hashes?(body_as_hash(body, content_type), @pattern)198 elsif (@pattern).is_a?(WebMock::Matchers::HashIncludingMatcher)199 @pattern == body_as_hash(body, content_type)200 else201 empty_string?(@pattern) && empty_string?(body) ||202 @pattern == body ||203 @pattern === body204 end205 end206 def to_s207 @pattern.inspect208 end209 private210 def body_as_hash(body, content_type)211 case BODY_FORMATS[content_type]212 when :json then213 WebMock::Util::JSON.parse(body)214 when :xml then215 Crack::XML.parse(body)216 else217 WebMock::Util::QueryMapper.query_to_values(body, notation: Config.instance.query_values_notation)218 end219 end220 def assert_non_multipart_body(content_type)221 if content_type =~ %r{^multipart/form-data}222 raise ArgumentError.new("WebMock does not support matching body for multipart/form-data requests yet :(")223 end224 end225 # Compare two hashes for equality226 #227 # For two hashes to match they must have the same length and all228 # values must match when compared using `#===`.229 #230 # The following hashes are examples of matches:231 #232 # {a: /\d+/} and {a: '123'}233 #234 # {a: '123'} and {a: '123'}235 #236 # {a: {b: /\d+/}} and {a: {b: '123'}}237 #238 # {a: {b: 'wow'}} and {a: {b: 'wow'}}239 #240 # @param [Hash] query_parameters typically the result of parsing241 # JSON, XML or URL encoded parameters.242 #243 # @param [Hash] pattern which contains keys with a string, hash or244 # regular expression value to use for comparison.245 #246 # @return [Boolean] true if the paramaters match the comparison247 # hash, false if not.248 def matching_hashes?(query_parameters, pattern)249 return false unless query_parameters.is_a?(Hash)250 return false unless query_parameters.keys.sort == pattern.keys.sort251 query_parameters.each do |key, actual|252 expected = pattern[key]253 if actual.is_a?(Hash) && expected.is_a?(Hash)254 return false unless matching_hashes?(actual, expected)255 else256 return false unless expected === actual257 end258 end259 true260 end261 def empty_string?(string)262 string.nil? || string == ""263 end264 def normalize_hash(hash)265 Hash[WebMock::Util::HashKeysStringifier.stringify_keys!(hash, deep: true).sort]266 end267 end268 class HeadersPattern269 def initialize(pattern)270 @pattern = WebMock::Util::Headers.normalize_headers(pattern) || {}271 end272 def matches?(headers)273 if empty_headers?(@pattern)274 empty_headers?(headers)275 else276 return false if empty_headers?(headers)277 @pattern.each do |key, value|278 return false unless headers.has_key?(key) && value === headers[key]279 end280 true281 end282 end283 def to_s...

Full Screen

Full Screen

initialize

Using AI Code Generation

copy

Full Screen

1 def initialize(name)2util = Util.new("Util")3 def initialize(name)4util = Util.new("Util")5 def initialize(name)6util = Util.new("Util")7 def initialize(name)8util = Util.new("Util")9 def initialize(name)10util = Util.new("Util")

Full Screen

Full Screen

initialize

Using AI Code Generation

copy

Full Screen

1 def initialize(name)2util = Util.new("Util")3 def initialize(name)4util = Util.new("Util")5 def initialize(name)6util = Util.new("Util")7 def initialize(name)8util = Util.new("Util")9 def initialize(name)10util = Util.new("Util")

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Webmock_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful