function_name
stringlengths
2
43
file_path
stringlengths
20
71
focal_code
stringlengths
176
2.2k
file_content
stringlengths
428
89.7k
language
stringclasses
1 value
function_component
dict
metadata
dict
hash_deep_dup
httparty/lib/httparty/module_inheritable_attributes.rb
def self.hash_deep_dup(hash) duplicate = hash.dup duplicate.each_pair do |key, value| if value.is_a?(Hash) duplicate[key] = hash_deep_dup(value) elsif value.is_a?(Proc) duplicate[key] = value.dup else duplicate[key] = value end end ...
# frozen_string_literal: true module HTTParty module ModuleInheritableAttributes #:nodoc: def self.included(base) base.extend(ClassMethods) end # borrowed from Rails 3.2 ActiveSupport def self.hash_deep_dup(hash) duplicate = hash.dup duplicate.each_pair do |key, value| if ...
Ruby
{ "end_line": 24, "name": "hash_deep_dup", "signature": "def self.hash_deep_dup(hash)", "start_line": 10 }
{ "class_name": "", "class_signature": "", "module": "HTTParty" }
inherited
httparty/lib/httparty/module_inheritable_attributes.rb
def inherited(subclass) super @mattr_inheritable_attrs.each do |inheritable_attribute| ivar = :"@#{inheritable_attribute}" subclass.instance_variable_set(ivar, instance_variable_get(ivar).clone) if instance_variable_get(ivar).respond_to?(:merge) subclass.class_...
# frozen_string_literal: true module HTTParty module ModuleInheritableAttributes #:nodoc: def self.included(base) base.extend(ClassMethods) end # borrowed from Rails 3.2 ActiveSupport def self.hash_deep_dup(hash) duplicate = hash.dup duplicate.each_pair do |key, value| if ...
Ruby
{ "end_line": 53, "name": "inherited", "signature": "def inherited(subclass)", "start_line": 38 }
{ "class_name": "", "class_signature": "", "module": "HTTParty" }
digest_auth
httparty/lib/httparty/net_digest_auth.rb
def digest_auth(username, password, response) authenticator = DigestAuthenticator.new( username, password, @method, @path, response ) authenticator.authorization_header.each do |v| add_field('Authorization', v) end authenticator.cookie_head...
# frozen_string_literal: true require 'digest/md5' require 'net/http' module Net module HTTPHeader def digest_auth(username, password, response) authenticator = DigestAuthenticator.new( username, password, @method, @path, response ) authenticator.author...
Ruby
{ "end_line": 24, "name": "digest_auth", "signature": "def digest_auth(username, password, response)", "start_line": 8 }
{ "class_name": "", "class_signature": "", "module": "Net" }
authorization_header
httparty/lib/httparty/net_digest_auth.rb
def authorization_header @cnonce = md5(random) header = [ %(Digest username="#{@username}"), %(realm="#{@response['realm']}"), %(nonce="#{@response['nonce']}"), %(uri="#{@path}"), %(response="#{request_digest}") ] header << %(algorithm="...
# frozen_string_literal: true require 'digest/md5' require 'net/http' module Net module HTTPHeader def digest_auth(username, password, response) authenticator = DigestAuthenticator.new( username, password, @method, @path, response ) authenticator.author...
Ruby
{ "end_line": 56, "name": "authorization_header", "signature": "def authorization_header", "start_line": 36 }
{ "class_name": "DigestAuthenticator", "class_signature": "class DigestAuthenticator", "module": "Net" }
parse
httparty/lib/httparty/net_digest_auth.rb
def parse(response_header) header = response_header['www-authenticate'] header = header.gsub(/qop=(auth(?:-int)?)/, 'qop="\\1"') header =~ /Digest (.*)/ params = {} if $1 non_quoted = $1.gsub(/(\w+)="(.*?)"/) { params[$1] = $2 } non_quoted.gsub(/(\w+)=([^,]*...
# frozen_string_literal: true require 'digest/md5' require 'net/http' module Net module HTTPHeader def digest_auth(username, password, response) authenticator = DigestAuthenticator.new( username, password, @method, @path, response ) authenticator.author...
Ruby
{ "end_line": 76, "name": "parse", "signature": "def parse(response_header)", "start_line": 64 }
{ "class_name": "DigestAuthenticator", "class_signature": "class DigestAuthenticator", "module": "Net" }
parse
httparty/lib/httparty/parser.rb
def parse return nil if body.nil? return nil if body == 'null' return nil if body.valid_encoding? && body.strip.empty? if body.valid_encoding? && body.encoding == Encoding::UTF_8 @body = body.gsub(/\A#{UTF8_BOM}/, '') end if supports_format? parse_supported_format ...
# frozen_string_literal: true module HTTParty # The default parser used by HTTParty, supports xml, json, html, csv and # plain text. # # == Custom Parsers # # If you'd like to do your own custom parsing, subclassing HTTParty::Parser # will make that process much easier. There are a few different ways you...
Ruby
{ "end_line": 116, "name": "parse", "signature": "def parse", "start_line": 104 }
{ "class_name": "Parser", "class_signature": "class Parser", "module": "HTTParty" }
initialize
httparty/lib/httparty/request.rb
def initialize(http_method, path, o = {}) @changed_hosts = false @credentials_sent = false self.http_method = http_method self.options = { limit: o.delete(:no_follow) ? 1 : 5, assume_utf16_is_big_endian: true, default_params: {}, follow_redirects: true, p...
# frozen_string_literal: true require 'erb' module HTTParty class Request #:nodoc: SupportedHTTPMethods = [ Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Patch, Net::HTTP::Put, Net::HTTP::Delete, Net::HTTP::Head, Net::HTTP::Options, Net::HTTP::Move, Net::HTTP:...
Ruby
{ "end_line": 77, "name": "initialize", "signature": "def initialize(http_method, path, o = {})", "start_line": 61 }
{ "class_name": "Request", "class_signature": "class Request", "module": "HTTParty" }
path=
httparty/lib/httparty/request.rb
def path=(uri) uri_adapter = options[:uri_adapter] @path = if uri.is_a?(uri_adapter) uri elsif String.try_convert(uri) uri_adapter.parse(uri).normalize else raise ArgumentError, "bad argument (expected #{uri_adapter} object or URI string)" end end
# frozen_string_literal: true require 'erb' module HTTParty class Request #:nodoc: SupportedHTTPMethods = [ Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Patch, Net::HTTP::Put, Net::HTTP::Delete, Net::HTTP::Head, Net::HTTP::Options, Net::HTTP::Move, Net::HTTP:...
Ruby
{ "end_line": 90, "name": "path=", "signature": "def path=(uri)", "start_line": 79 }
{ "class_name": "Request", "class_signature": "class Request", "module": "HTTParty" }
uri
httparty/lib/httparty/request.rb
def uri if redirect && path.relative? && path.path[0] != '/' last_uri_host = @last_uri.path.gsub(/[^\/]+$/, '') path.path = "/#{path.path}" if last_uri_host[-1] != '/' path.path = "#{last_uri_host}#{path.path}" end if path.relative? && path.host new_uri = options[:uri...
# frozen_string_literal: true require 'erb' module HTTParty class Request #:nodoc: SupportedHTTPMethods = [ Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Patch, Net::HTTP::Put, Net::HTTP::Delete, Net::HTTP::Head, Net::HTTP::Options, Net::HTTP::Move, Net::HTTP:...
Ruby
{ "end_line": 126, "name": "uri", "signature": "def uri", "start_line": 100 }
{ "class_name": "Request", "class_signature": "class Request", "module": "HTTParty" }
perform
httparty/lib/httparty/request.rb
def perform(&block) validate setup_raw_request chunked_body = nil current_http = http begin self.last_response = current_http.request(@raw_request) do |http_response| if block chunks = [] http_response.read_body do |fragment| encode...
# frozen_string_literal: true require 'erb' module HTTParty class Request #:nodoc: SupportedHTTPMethods = [ Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Patch, Net::HTTP::Put, Net::HTTP::Delete, Net::HTTP::Head, Net::HTTP::Options, Net::HTTP::Move, Net::HTTP:...
Ruby
{ "end_line": 178, "name": "perform", "signature": "def perform(&block)", "start_line": 150 }
{ "class_name": "Request", "class_signature": "class Request", "module": "HTTParty" }
setup_raw_request
httparty/lib/httparty/request.rb
def setup_raw_request if options[:headers].respond_to?(:to_hash) headers_hash = options[:headers].to_hash else headers_hash = nil end @raw_request = http_method.new(request_uri(uri), headers_hash) @raw_request.body_stream = options[:body_stream] if options[:body_stream] ...
# frozen_string_literal: true require 'erb' module HTTParty class Request #:nodoc: SupportedHTTPMethods = [ Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Patch, Net::HTTP::Put, Net::HTTP::Delete, Net::HTTP::Head, Net::HTTP::Options, Net::HTTP::Move, Net::HTTP:...
Ruby
{ "end_line": 259, "name": "setup_raw_request", "signature": "def setup_raw_request", "start_line": 228 }
{ "class_name": "Request", "class_signature": "class Request", "module": "HTTParty" }
query_string
httparty/lib/httparty/request.rb
def query_string(uri) query_string_parts = [] query_string_parts << uri.query unless uri.query.nil? if options[:query].respond_to?(:to_hash) query_string_parts << normalize_query(options[:default_params].merge(options[:query].to_hash)) else query_string_parts << normalize_query(...
# frozen_string_literal: true require 'erb' module HTTParty class Request #:nodoc: SupportedHTTPMethods = [ Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Patch, Net::HTTP::Put, Net::HTTP::Delete, Net::HTTP::Head, Net::HTTP::Options, Net::HTTP::Move, Net::HTTP:...
Ruby
{ "end_line": 294, "name": "query_string", "signature": "def query_string(uri)", "start_line": 281 }
{ "class_name": "Request", "class_signature": "class Request", "module": "HTTParty" }
handle_response
httparty/lib/httparty/request.rb
def handle_response(raw_body, &block) if response_redirects? handle_redirection(&block) else raw_body ||= last_response.body body = decompress(raw_body, last_response['content-encoding']) unless raw_body.nil? unless body.nil? body = encode_text(body, last_response...
# frozen_string_literal: true require 'erb' module HTTParty class Request #:nodoc: SupportedHTTPMethods = [ Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Patch, Net::HTTP::Put, Net::HTTP::Delete, Net::HTTP::Head, Net::HTTP::Options, Net::HTTP::Move, Net::HTTP:...
Ruby
{ "end_line": 319, "name": "handle_response", "signature": "def handle_response(raw_body, &block)", "start_line": 300 }
{ "class_name": "Request", "class_signature": "class Request", "module": "HTTParty" }
handle_redirection
httparty/lib/httparty/request.rb
def handle_redirection(&block) options[:limit] -= 1 if options[:logger] logger = HTTParty::Logger.build(options[:logger], options[:log_level], options[:log_format]) logger.format(self, last_response) end self.path = last_response['location'] self.redirect = true ...
# frozen_string_literal: true require 'erb' module HTTParty class Request #:nodoc: SupportedHTTPMethods = [ Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Patch, Net::HTTP::Put, Net::HTTP::Delete, Net::HTTP::Head, Net::HTTP::Options, Net::HTTP::Move, Net::HTTP:...
Ruby
{ "end_line": 343, "name": "handle_redirection", "signature": "def handle_redirection(&block)", "start_line": 321 }
{ "class_name": "Request", "class_signature": "class Request", "module": "HTTParty" }
initialize
httparty/lib/httparty/response.rb
def initialize(request, response, parsed_block, options = {}) @request = request @response = response @body = options[:body] || response.body @parsed_block = parsed_block @headers = Headers.new(response.to_hash) if request.options[:logger] logger = ::HT...
# frozen_string_literal: true module HTTParty class Response < Object def self.underscore(string) string.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z])([A-Z])/, '\1_\2').downcase end def self._load(data) req, resp, parsed_resp, resp_body = Marshal.load(data) new(req, resp, -> { p...
Ruby
{ "end_line": 34, "name": "initialize", "signature": "def initialize(request, response, parsed_block, options = {})", "start_line": 17 }
{ "class_name": "Response", "class_signature": "class Response < < Object", "module": "HTTParty" }
encode_utf_16
httparty/lib/httparty/text_encoder.rb
def encode_utf_16 if text.bytesize >= 2 if text.getbyte(0) == 0xFF && text.getbyte(1) == 0xFE return text.force_encoding('UTF-16LE') elsif text.getbyte(0) == 0xFE && text.getbyte(1) == 0xFF return text.force_encoding('UTF-16BE') end end if assume_utf16_is_b...
# frozen_string_literal: true module HTTParty class TextEncoder attr_reader :text, :content_type, :assume_utf16_is_big_endian def initialize(text, assume_utf16_is_big_endian: true, content_type: nil) @text = +text @content_type = content_type @assume_utf16_is_big_endian = assume_utf16_is_b...
Ruby
{ "end_line": 49, "name": "encode_utf_16", "signature": "def encode_utf_16", "start_line": 35 }
{ "class_name": "TextEncoder", "class_signature": "class TextEncoder", "module": "HTTParty" }
logstash_message
httparty/lib/httparty/logger/logstash_formatter.rb
def logstash_message require 'json' { '@timestamp' => current_time, '@version' => 1, 'content_length' => content_length || '-', 'http_method' => http_method, 'message' => message, 'path' => path, 'response_code' => response.code, ...
# frozen_string_literal: true module HTTParty module Logger class LogstashFormatter #:nodoc: TAG_NAME = HTTParty.name attr_accessor :level, :logger def initialize(logger, level) @logger = logger @level = level.to_sym end def format(request, response) @req...
Ruby
{ "end_line": 39, "name": "logstash_message", "signature": "def logstash_message", "start_line": 26 }
{ "class_name": "LogstashFormatter", "class_signature": "class LogstashFormatter", "module": "HTTParty" }
generate_multipart
httparty/lib/httparty/request/body.rb
def generate_multipart normalized_params = params.flat_map { |key, value| HashConversions.normalize_keys(key, value) } multipart = normalized_params.inject(''.b) do |memo, (key, value)| memo << "--#{boundary}#{NEWLINE}".b memo << %(Content-Disposition: form-data; name="#{key}").b ...
# frozen_string_literal: true require_relative 'multipart_boundary' module HTTParty class Request class Body NEWLINE = "\r\n" private_constant :NEWLINE def initialize(params, query_string_normalizer: nil, force_multipart: false) @params = params @query_string_normalizer = quer...
Ruby
{ "end_line": 59, "name": "generate_multipart", "signature": "def generate_multipart", "start_line": 42 }
{ "class_name": "Request", "class_signature": "class Request", "module": "HTTParty" }
content_body
httparty/lib/httparty/request/body.rb
def content_body(object) if file?(object) object = (file = object).read object.force_encoding(Encoding::BINARY) if object.respond_to?(:force_encoding) file.rewind if file.respond_to?(:rewind) object.to_s else object.to_s.b end end
# frozen_string_literal: true require_relative 'multipart_boundary' module HTTParty class Request class Body NEWLINE = "\r\n" private_constant :NEWLINE def initialize(params, query_string_normalizer: nil, force_multipart: false) @params = params @query_string_normalizer = quer...
Ruby
{ "end_line": 92, "name": "content_body", "signature": "def content_body(object)", "start_line": 83 }
{ "class_name": "Request", "class_signature": "class Request", "module": "HTTParty" }
initialize
httparty/lib/httparty/response/headers.rb
def initialize(header_values = nil) @header = {} if header_values header_values.each_pair do |k,v| if v.is_a?(Array) v.each do |sub_v| add_field(k, sub_v) end else add_field(k, v) end end ...
# frozen_string_literal: true require 'delegate' module HTTParty class Response #:nodoc: class Headers < ::SimpleDelegator include ::Net::HTTPHeader def initialize(header_values = nil) @header = {} if header_values header_values.each_pair do |k,v| if v.is_a?(Ar...
Ruby
{ "end_line": 24, "name": "initialize", "signature": "def initialize(header_values = nil)", "start_line": 10 }
{ "class_name": "Response", "class_signature": "class Response", "module": "HTTParty" }
authorize
pundit/lib/pundit/context.rb
def authorize(possibly_namespaced_record, query:, policy_class:) record = pundit_model(possibly_namespaced_record) policy = if policy_class policy_class.new(user, record) else policy!(possibly_namespaced_record) end raise NotAuthorizedError, query: query, record: record, p...
# frozen_string_literal: true module Pundit # {Pundit::Context} is intended to be created once per request and user, and # it is then used to perform authorization checks throughout the request. # # @example Using Sinatra # helpers do # def current_user = ... # # def pundit # @pundit ...
Ruby
{ "end_line": 73, "name": "authorize", "signature": "def authorize(possibly_namespaced_record, query:, policy_class:)", "start_line": 62 }
{ "class_name": "Context", "class_signature": "class Context", "module": "Pundit" }
policy_scope
pundit/lib/pundit/context.rb
def policy_scope(scope) policy_scope_class = policy_finder(scope).scope return unless policy_scope_class begin policy_scope = policy_scope_class.new(user, pundit_model(scope)) rescue ArgumentError raise InvalidConstructorError, "Invalid #<#{policy_scope_class}> constructor is ca...
# frozen_string_literal: true module Pundit # {Pundit::Context} is intended to be created once per request and user, and # it is then used to perform authorization checks throughout the request. # # @example Using Sinatra # helpers do # def current_user = ... # # def pundit # @pundit ...
Ruby
{ "end_line": 120, "name": "policy_scope", "signature": "def policy_scope(scope)", "start_line": 109 }
{ "class_name": "Context", "class_signature": "class Context", "module": "Pundit" }
cached_find
pundit/lib/pundit/context.rb
def cached_find(record) policy_cache.fetch(user: user, record: record) do klass = yield policy_finder(record) next unless klass model = pundit_model(record) begin klass.new(user, model) rescue ArgumentError raise InvalidConstructorError, "Invalid #<#{k...
# frozen_string_literal: true module Pundit # {Pundit::Context} is intended to be created once per request and user, and # it is then used to perform authorization checks throughout the request. # # @example Using Sinatra # helpers do # def current_user = ... # # def pundit # @pundit ...
Ruby
{ "end_line": 171, "name": "cached_find", "signature": "def cached_find(record)", "start_line": 158 }
{ "class_name": "Context", "class_signature": "class Context", "module": "Pundit" }
initialize
pundit/lib/pundit/error.rb
def initialize(options = {}) if options.is_a? String message = options else @query = options[:query] @record = options[:record] @policy = options[:policy] message = options.fetch(:message) do record_name = record.is_a?(Class) ? record.to_s : "this #{record...
# frozen_string_literal: true module Pundit # @api private # @since v1.0.0 # To avoid name clashes with common Error naming when mixing in Pundit, # keep it here with compact class style definition. class Error < StandardError; end # Error that will be raised when authorization has failed # @since v0.1....
Ruby
{ "end_line": 51, "name": "initialize", "signature": "def initialize(options = {})", "start_line": 36 }
{ "class_name": "NotAuthorizedError", "class_signature": "class NotAuthorizedError < < Error", "module": "Pundit" }
param_key
pundit/lib/pundit/policy_finder.rb
def param_key # rubocop:disable Metrics/AbcSize model = object.is_a?(Array) ? object.last : object if model.respond_to?(:model_name) model.model_name.param_key.to_s elsif model.is_a?(Class) model.to_s.demodulize.underscore else model.class.to_s.demodulize.underscore ...
# frozen_string_literal: true # String#safe_constantize, String#demodulize, String#underscore, String#camelize require "active_support/core_ext/string/inflections" module Pundit # Finds policy and scope classes for given object. # @since v0.1.0 # @api public # @example # user = User.find(params[:id]) # ...
Ruby
{ "end_line": 86, "name": "param_key", "signature": "def param_key # rubocop:disable Metrics/AbcSize", "start_line": 76 }
{ "class_name": "PolicyFinder", "class_signature": "class PolicyFinder", "module": "Pundit" }
find
pundit/lib/pundit/policy_finder.rb
def find(subject) if subject.is_a?(Array) modules = subject.dup last = modules.pop context = modules.map { |x| find_class_name(x) }.join("::") [context, find(last)].join("::") elsif subject.respond_to?(:policy_class) subject.policy_class elsif subject.class.resp...
# frozen_string_literal: true # String#safe_constantize, String#demodulize, String#underscore, String#camelize require "active_support/core_ext/string/inflections" module Pundit # Finds policy and scope classes for given object. # @since v0.1.0 # @api public # @example # user = User.find(params[:id]) # ...
Ruby
{ "end_line": 110, "name": "find", "signature": "def find(subject)", "start_line": 96 }
{ "class_name": "PolicyFinder", "class_signature": "class PolicyFinder", "module": "Pundit" }
find_class_name
pundit/lib/pundit/policy_finder.rb
def find_class_name(subject) if subject.respond_to?(:model_name) subject.model_name elsif subject.class.respond_to?(:model_name) subject.class.model_name elsif subject.is_a?(Class) subject elsif subject.is_a?(Symbol) subject.to_s.camelize else subjec...
# frozen_string_literal: true # String#safe_constantize, String#demodulize, String#underscore, String#camelize require "active_support/core_ext/string/inflections" module Pundit # Finds policy and scope classes for given object. # @since v0.1.0 # @api public # @example # user = User.find(params[:id]) # ...
Ruby
{ "end_line": 133, "name": "find_class_name", "signature": "def find_class_name(subject)", "start_line": 121 }
{ "class_name": "PolicyFinder", "class_signature": "class PolicyFinder", "module": "Pundit" }
initialize
rspec-core/lib/rspec/core/backtrace_formatter.rb
def initialize @full_backtrace = false patterns = %w[ /lib\d*/ruby/ bin/ exe/rspec /lib/bundler/ /exe/bundle: ] patterns << "org/jruby/" if RUBY_PLATFORM == 'java' patterns.map! { |s| Regexp.new(s.gsub("/", File::SEPARATOR)) } @exclusion_patterns = [Regexp.union(RSpec::CallerFi...
module RSpec module Core # @private class BacktraceFormatter # @private attr_accessor :exclusion_patterns, :inclusion_patterns def initialize @full_backtrace = false patterns = %w[ /lib\d*/ruby/ bin/ exe/rspec /lib/bundler/ /exe/bundle: ] patterns << "org/jruby/" if...
Ruby
{ "end_line": 20, "name": "initialize", "signature": "def initialize", "start_line": 8 }
{ "class_name": "BacktraceFormatter", "class_signature": "class BacktraceFormatter", "module": "RSpec" }
format_backtrace
rspec-core/lib/rspec/core/backtrace_formatter.rb
def format_backtrace(backtrace, options={}) return [] unless backtrace return backtrace if options[:full_backtrace] || backtrace.empty? backtrace.map { |l| backtrace_line(l) }.compact. tap do |filtered| if filtered.empty? filtered.concat backtrace ...
module RSpec module Core # @private class BacktraceFormatter # @private attr_accessor :exclusion_patterns, :inclusion_patterns def initialize @full_backtrace = false patterns = %w[ /lib\d*/ruby/ bin/ exe/rspec /lib/bundler/ /exe/bundle: ] patterns << "org/jruby/" if...
Ruby
{ "end_line": 47, "name": "format_backtrace", "signature": "def format_backtrace(backtrace, options={})", "start_line": 33 }
{ "class_name": "BacktraceFormatter", "class_signature": "class BacktraceFormatter", "module": "RSpec" }
deprecation_stream=
rspec-core/lib/rspec/core/configuration.rb
def deprecation_stream=(value) if @reporter && !value.equal?(@deprecation_stream) warn "RSpec's reporter has already been initialized with " \ "#{deprecation_stream.inspect} as the deprecation stream, so your change to "\ "`deprecation_stream` will be ignored. You should config...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 178, "name": "deprecation_stream=", "signature": "def deprecation_stream=(value)", "start_line": 168 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
fail_fast=
rspec-core/lib/rspec/core/configuration.rb
def fail_fast=(value) case value when true, 'true' @fail_fast = true when false, 'false', 0 @fail_fast = false when nil @fail_fast = nil else @fail_fast = value.to_i if value.to_i == 0 # TODO: in RSpec 4, consider rai...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 233, "name": "fail_fast=", "signature": "def fail_fast=(value)", "start_line": 214 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
output_stream=
rspec-core/lib/rspec/core/configuration.rb
def output_stream=(value) if @reporter && !value.equal?(@output_stream) warn "RSpec's reporter has already been initialized with " \ "#{output_stream.inspect} as the output stream, so your change to "\ "`output_stream` will be ignored. You should configure it earlier for " \ ...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 284, "name": "output_stream=", "signature": "def output_stream=(value)", "start_line": 274 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
shared_context_metadata_behavior=
rspec-core/lib/rspec/core/configuration.rb
def shared_context_metadata_behavior=(value) case value when :trigger_inclusion, :apply_to_host_groups @shared_context_metadata_behavior = value else raise ArgumentError, "Cannot set `RSpec.configuration." \ "shared_context_metadata_behavior` to `#{value.inspect}`...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 443, "name": "shared_context_metadata_behavior=", "signature": "def shared_context_metadata_behavior=(value)", "start_line": 434 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
bisect_runner=
rspec-core/lib/rspec/core/configuration.rb
def bisect_runner=(value) if @bisect_runner_class && value != @bisect_runner raise "`config.bisect_runner = #{value.inspect}` can no longer take " \ "effect as the #{@bisect_runner.inspect} bisect runnner is already " \ "in use. This config setting must be set in a file loaded ...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 516, "name": "bisect_runner=", "signature": "def bisect_runner=(value)", "start_line": 506 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
initialize
rspec-core/lib/rspec/core/configuration.rb
def initialize # rubocop:disable Style/GlobalVars @start_time = $_rspec_core_load_started_at || ::RSpec::Core::Time.now # rubocop:enable Style/GlobalVars @expectation_frameworks = [] @include_modules = FilterableItemRepository::QueryOptimized.new(:any?) @extend_modules =...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 592, "name": "initialize", "signature": "def initialize", "start_line": 534 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
mock_framework
rspec-core/lib/rspec/core/configuration.rb
def mock_framework if @mock_framework.nil? begin mock_with :rspec rescue LoadError mock_with :nothing end end @mock_framework end
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 685, "name": "mock_framework", "signature": "def mock_framework", "start_line": 676 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
mock_with
rspec-core/lib/rspec/core/configuration.rb
def mock_with(framework) framework_module = if framework.is_a?(Module) framework else const_name = MOCKING_ADAPTERS.fetch(framework) do raise ArgumentError, "Unknown mocking framework: #{framework.inspect}. " \ "Pa...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 823, "name": "mock_with", "signature": "def mock_with(framework)", "start_line": 793 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
expectation_frameworks
rspec-core/lib/rspec/core/configuration.rb
def expectation_frameworks if @expectation_frameworks.empty? begin expect_with :rspec rescue LoadError expect_with Module.new end end @expectation_frameworks end
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 835, "name": "expectation_frameworks", "signature": "def expectation_frameworks", "start_line": 826 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
expect_with
rspec-core/lib/rspec/core/configuration.rb
def expect_with(*frameworks) modules = frameworks.map do |framework| case framework when Module framework when :rspec require 'rspec/expectations' # Tag this exception class so our exception formatting logic knows # that it satisfies...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 905, "name": "expect_with", "signature": "def expect_with(*frameworks)", "start_line": 865 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
reporter
rspec-core/lib/rspec/core/configuration.rb
def reporter # @reporter_buffer should only ever be set in this method to cover # initialization of @reporter. @reporter_buffer || @reporter ||= begin @reporter_buffer = DeprecationReporterBuffer.new formatter_loader.prepare_default output_wrapper, deprecation_s...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 1074, "name": "reporter", "signature": "def reporter", "start_line": 1063 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
last_run_statuses
rspec-core/lib/rspec/core/configuration.rb
def last_run_statuses @last_run_statuses ||= Hash.new(UNKNOWN_STATUS).tap do |statuses| if (path = example_status_persistence_file_path) begin ExampleStatusPersister.load_from(path).inject(statuses) do |hash, example| status = example[:status] ...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 1127, "name": "last_run_statuses", "signature": "def last_run_statuses", "start_line": 1108 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
apply_derived_metadata_to
rspec-core/lib/rspec/core/configuration.rb
def apply_derived_metadata_to(metadata) already_run_blocks = Set.new # We loop and attempt to re-apply metadata blocks to support cascades # (e.g. where a derived bit of metadata triggers the application of # another piece of derived metadata, etc) # # We limit our loopi...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 1971, "name": "apply_derived_metadata_to", "signature": "def apply_derived_metadata_to(metadata)", "start_line": 1948 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
with_suite_hooks
rspec-core/lib/rspec/core/configuration.rb
def with_suite_hooks return yield if dry_run? begin RSpec.current_scope = :before_suite_hook run_suite_hooks("a `before(:suite)` hook", @before_suite_hooks) yield ensure RSpec.current_scope = :after_suite_hook run_suite_hooks("an `after(:suite)`...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 2110, "name": "with_suite_hooks", "signature": "def with_suite_hooks", "start_line": 2098 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
bisect_runner_class
rspec-core/lib/rspec/core/configuration.rb
def bisect_runner_class @bisect_runner_class ||= begin case bisect_runner when :fork RSpec::Support.require_rspec_core 'bisect/fork_runner' Bisect::ForkRunner when :shell RSpec::Support.require_rspec_core 'bisect/shell_runner' Bisect:...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 2146, "name": "bisect_runner_class", "signature": "def bisect_runner_class", "start_line": 2132 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
load_file_handling_errors
rspec-core/lib/rspec/core/configuration.rb
def load_file_handling_errors(method, file) __send__(method, file) rescue LoadError => ex relative_file = Metadata.relative_path(file) suggestions = DidYouMean.new(relative_file).call reporter.notify_non_example_exception(ex, "An error occurred while loading #{relative_file}.#{sugg...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 2176, "name": "load_file_handling_errors", "signature": "def load_file_handling_errors(method, file)", "start_line": 2150 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
handle_suite_hook
rspec-core/lib/rspec/core/configuration.rb
def handle_suite_hook(scope, meta) return nil unless scope == :suite unless meta.empty? # TODO: in RSpec 4, consider raising an error here. # We warn only for backwards compatibility. RSpec.warn_with "WARNING: `:suite` hooks do not support metadata since " \ ...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 2191, "name": "handle_suite_hook", "signature": "def handle_suite_hook(scope, meta)", "start_line": 2178 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
run_suite_hooks
rspec-core/lib/rspec/core/configuration.rb
def run_suite_hooks(hook_description, hooks) context = SuiteHookContext.new(hook_description, reporter) hooks.each do |hook| begin hook.run(context) rescue Support::AllExceptionsExceptOnesWeMustNotRescue => ex context.set_exception(ex) # Do not r...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 2209, "name": "run_suite_hooks", "signature": "def run_suite_hooks(hook_description, hooks)", "start_line": 2193 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
get_files_to_run
rspec-core/lib/rspec/core/configuration.rb
def get_files_to_run(paths) files = FlatMap.flat_map(paths_to_check(paths)) do |path| path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR File.directory?(path) ? gather_directories(path) : extract_location(path) end.uniq return files unless only_fai...
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 2221, "name": "get_files_to_run", "signature": "def get_files_to_run(paths)", "start_line": 2211 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
extract_location
rspec-core/lib/rspec/core/configuration.rb
def extract_location(path) match = /^(.*?)((?:\:\d+)+)$/.match(path) if match captures = match.captures path = captures[0] lines = captures[1][1..-1].split(":").map(&:to_i) filter_manager.add_location path, lines else path, scoped_ids = Example....
RSpec::Support.require_rspec_core "backtrace_formatter" RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "output_wrapper" module RSpec module Core # rubocop:disable Metrics/ClassLength # Stores runtime con...
Ruby
{ "end_line": 2281, "name": "extract_location", "signature": "def extract_location(path)", "start_line": 2266 }
{ "class_name": "Configuration", "class_signature": "class Configuration", "module": "RSpec" }
organize_options
rspec-core/lib/rspec/core/configuration_options.rb
def organize_options @filter_manager_options = [] @options = (file_options << command_line_options << env_options).each do |opts| @filter_manager_options << [:include, opts.delete(:inclusion_filter)] if opts.key?(:inclusion_filter) @filter_manager_options << [:exclude, opts.delete(:...
require 'erb' require 'shellwords' module RSpec module Core # Responsible for utilizing externally provided configuration options, # whether via the command line, `.rspec`, `~/.rspec`, # `$XDG_CONFIG_HOME/rspec/options`, `.rspec-local` or a custom options # file. class ConfigurationOptions ...
Ruby
{ "end_line": 57, "name": "organize_options", "signature": "def organize_options", "start_line": 44 }
{ "class_name": "ConfigurationOptions", "class_signature": "class ConfigurationOptions", "module": "RSpec" }
options
rspec-core/lib/rspec/core/drb.rb
def options argv = [] argv << "--color" if @submitted_options[:color] argv << "--force-color" if @submitted_options[:color_mode] == :on argv << "--no-color" if @submitted_options[:color_mode] == :off argv << "--profile" if @submitted_options[:profile_examples] ...
require 'drb/drb' module RSpec module Core # @private class DRbRunner def initialize(options, configuration=RSpec.configuration) @options = options @configuration = configuration end def drb_port @options.options[:drb_port] || ENV['RSPEC_DRB'] || 8989 en...
Ruby
{ "end_line": 63, "name": "options", "signature": "def options", "start_line": 41 }
{ "class_name": "DRbOptions", "class_signature": "class DRbOptions", "module": "RSpec" }
find_and_eval_shared
rspec-core/lib/rspec/core/example_group.rb
def self.find_and_eval_shared(label, name, inclusion_location, *args, &customization_block) shared_module = RSpec.world.shared_example_group_registry.find(parent_groups, name) unless shared_module raise ArgumentError, "Could not find shared #{label} #{name.inspect}" end share...
RSpec::Support.require_rspec_support 'recursive_const_methods' module RSpec module Core # rubocop:disable Metrics/ClassLength # ExampleGroup and {Example} are the main structural elements of # rspec-core. Consider this example: # # RSpec.describe Thing do # it "does something" do ...
Ruby
{ "end_line": 390, "name": "find_and_eval_shared", "signature": "def self.find_and_eval_shared(label, name, inclusion_location, *args, &customization_block)", "start_line": 379 }
{ "class_name": "ExampleGroup", "class_signature": "class ExampleGroup", "module": "RSpec" }
set_it_up
rspec-core/lib/rspec/core/example_group.rb
def self.set_it_up(description, args, registration_collection, &example_group_block) # Ruby 1.9 has a bug that can lead to infinite recursion and a # SystemStackError if you include a module in a superclass after # including it in a subclass: https://gist.github.com/845896 # To prevent t...
RSpec::Support.require_rspec_support 'recursive_const_methods' module RSpec module Core # rubocop:disable Metrics/ClassLength # ExampleGroup and {Example} are the main structural elements of # rspec-core. Consider this example: # # RSpec.describe Thing do # it "does something" do ...
Ruby
{ "end_line": 447, "name": "set_it_up", "signature": "def self.set_it_up(description, args, registration_collection, &example_group_block)", "start_line": 410 }
{ "class_name": "ExampleGroup", "class_signature": "class ExampleGroup", "module": "RSpec" }
run_before_context_hooks
rspec-core/lib/rspec/core/example_group.rb
def self.run_before_context_hooks(example_group_instance) set_ivars(example_group_instance, superclass_before_context_ivars) @currently_executing_a_context_hook = true ContextHookMemoized::Before.isolate_for_context_hook(example_group_instance) do hooks.run(:before, :context, example...
RSpec::Support.require_rspec_support 'recursive_const_methods' module RSpec module Core # rubocop:disable Metrics/ClassLength # ExampleGroup and {Example} are the main structural elements of # rspec-core. Consider this example: # # RSpec.describe Thing do # it "does something" do ...
Ruby
{ "end_line": 558, "name": "run_before_context_hooks", "signature": "def self.run_before_context_hooks(example_group_instance)", "start_line": 547 }
{ "class_name": "ExampleGroup", "class_signature": "class ExampleGroup", "module": "RSpec" }
run_after_context_hooks
rspec-core/lib/rspec/core/example_group.rb
def self.run_after_context_hooks(example_group_instance) set_ivars(example_group_instance, before_context_ivars) @currently_executing_a_context_hook = true ContextHookMemoized::After.isolate_for_context_hook(example_group_instance) do hooks.run(:after, :context, example_group_instanc...
RSpec::Support.require_rspec_support 'recursive_const_methods' module RSpec module Core # rubocop:disable Metrics/ClassLength # ExampleGroup and {Example} are the main structural elements of # rspec-core. Consider this example: # # RSpec.describe Thing do # it "does something" do ...
Ruby
{ "end_line": 596, "name": "run_after_context_hooks", "signature": "def self.run_after_context_hooks(example_group_instance)", "start_line": 585 }
{ "class_name": "ExampleGroup", "class_signature": "class ExampleGroup", "module": "RSpec" }
ordering_strategy
rspec-core/lib/rspec/core/example_group.rb
def self.ordering_strategy order = metadata.fetch(:order, :global) registry = RSpec.configuration.ordering_registry registry.fetch(order) do warn <<-WARNING.gsub(/^ +\|/, '') |WARNING: Ignoring unknown ordering specified using `:order => #{order.inspect}` metadata. ...
RSpec::Support.require_rspec_support 'recursive_const_methods' module RSpec module Core # rubocop:disable Metrics/ClassLength # ExampleGroup and {Example} are the main structural elements of # rspec-core. Consider this example: # # RSpec.describe Thing do # it "does something" do ...
Ruby
{ "end_line": 638, "name": "ordering_strategy", "signature": "def self.ordering_strategy", "start_line": 625 }
{ "class_name": "ExampleGroup", "class_signature": "class ExampleGroup", "module": "RSpec" }
method_missing
rspec-core/lib/rspec/core/example_group.rb
def self.method_missing(name, *args) if method_defined?(name) raise WrongScopeError, "`#{name}` is not available on an example group (e.g. a " \ "`describe` or `context` block). It is only available from " \ "within individual examples (e.g. `it` blocks)...
RSpec::Support.require_rspec_support 'recursive_const_methods' module RSpec module Core # rubocop:disable Metrics/ClassLength # ExampleGroup and {Example} are the main structural elements of # rspec-core. Consider this example: # # RSpec.describe Thing do # it "does something" do ...
Ruby
{ "end_line": 753, "name": "method_missing", "signature": "def self.method_missing(name, *args)", "start_line": 742 }
{ "class_name": "ExampleGroup", "class_signature": "class ExampleGroup", "module": "RSpec" }
method_missing
rspec-core/lib/rspec/core/example_group.rb
def method_missing(name, *args) if self.class.respond_to?(name) raise WrongScopeError, "`#{name}` is not available from within an example (e.g. an " \ "`it` block) or from constructs that run in the scope of an " \ "example (e.g. `before`, `let`, etc). I...
RSpec::Support.require_rspec_support 'recursive_const_methods' module RSpec module Core # rubocop:disable Metrics/ClassLength # ExampleGroup and {Example} are the main structural elements of # rspec-core. Consider this example: # # RSpec.describe Thing do # it "does something" do ...
Ruby
{ "end_line": 768, "name": "method_missing", "signature": "def method_missing(name, *args)", "start_line": 758 }
{ "class_name": "ExampleGroup", "class_signature": "class ExampleGroup", "module": "RSpec" }
with_frame
rspec-core/lib/rspec/core/example_group.rb
def self.with_frame(name, location) current_stack = shared_example_group_inclusions if current_stack.any? { |frame| frame.shared_group_name == name } raise ArgumentError, "can't include shared examples recursively" else current_stack << new(name, location) yield ...
RSpec::Support.require_rspec_support 'recursive_const_methods' module RSpec module Core # rubocop:disable Metrics/ClassLength # ExampleGroup and {Example} are the main structural elements of # rspec-core. Consider this example: # # RSpec.describe Thing do # it "does something" do ...
Ruby
{ "end_line": 826, "name": "with_frame", "signature": "def self.with_frame(name, location)", "start_line": 816 }
{ "class_name": "SharedExampleGroupInclusionStackFrame", "class_signature": "class SharedExampleGroupInclusionStackFrame", "module": "RSpec" }
base_name_for
rspec-core/lib/rspec/core/example_group.rb
def self.base_name_for(group) return "Anonymous".dup if group.description.empty? # Convert to CamelCase. name = ' ' + group.description name.gsub!(/[^0-9a-zA-Z]+([0-9a-zA-Z])/) do match = ::Regexp.last_match[1] match.upcase! match end name.lstrip! ...
RSpec::Support.require_rspec_support 'recursive_const_methods' module RSpec module Core # rubocop:disable Metrics/ClassLength # ExampleGroup and {Example} are the main structural elements of # rspec-core. Consider this example: # # RSpec.describe Thing do # it "does something" do ...
Ruby
{ "end_line": 881, "name": "base_name_for", "signature": "def self.base_name_for(group)", "start_line": 862 }
{ "class_name": "", "class_signature": "", "module": "RSpec" }
persist
rspec-core/lib/rspec/core/example_status_persister.rb
def persist RSpec::Support::DirectoryMaker.mkdir_p(File.dirname(@file_name)) File.open(@file_name, File::RDWR | File::CREAT) do |f| # lock the file while reading / persisting to avoid a race # condition where parallel or unrelated spec runs race to # update the same file ...
RSpec::Support.require_rspec_support "directory_maker" module RSpec module Core # Persists example ids and their statuses so that we can filter # to just the ones that failed the last time they ran. # @private class ExampleStatusPersister def self.load_from(file_name) return [] unless F...
Ruby
{ "end_line": 36, "name": "persist", "signature": "def persist", "start_line": 23 }
{ "class_name": "ExampleStatusPersister", "class_signature": "class ExampleStatusPersister", "module": "RSpec" }
statuses_from_this_run
rspec-core/lib/rspec/core/example_status_persister.rb
def statuses_from_this_run @examples.map do |ex| result = ex.execution_result { :example_id => ex.id, :status => result.status ? result.status.to_s : Configuration::UNKNOWN_STATUS, :run_time => result.run_time ? Formatters::Helpers.format_duration(r...
RSpec::Support.require_rspec_support "directory_maker" module RSpec module Core # Persists example ids and their statuses so that we can filter # to just the ones that failed the last time they ran. # @private class ExampleStatusPersister def self.load_from(file_name) return [] unless F...
Ruby
{ "end_line": 56, "name": "statuses_from_this_run", "signature": "def statuses_from_this_run", "start_line": 46 }
{ "class_name": "ExampleStatusPersister", "class_signature": "class ExampleStatusPersister", "module": "RSpec" }
prune
rspec-core/lib/rspec/core/filter_manager.rb
def prune(examples) # Semantically, this is unnecessary (the filtering below will return the empty # array unmodified), but for perf reasons it's worth exiting early here. Users # commonly have top-level examples groups that do not have any direct examples # and instead have nested group...
module RSpec module Core # @private class FilterManager attr_reader :exclusions, :inclusions def initialize @exclusions, @inclusions = FilterRules.build end # @api private # # @param file_path [String] # @param line_numbers [Array] def add_location(fil...
Ruby
{ "end_line": 55, "name": "prune", "signature": "def prune(examples)", "start_line": 34 }
{ "class_name": "FilterManager", "class_signature": "class FilterManager", "module": "RSpec" }
setup_default
rspec-core/lib/rspec/core/formatters.rb
def setup_default(output_stream, deprecation_stream) add default_formatter, output_stream if @formatters.empty? unless @formatters.any? { |formatter| DeprecationFormatter === formatter } add DeprecationFormatter, deprecation_stream, output_stream end unless existing_formatter_implement...
RSpec::Support.require_rspec_support "directory_maker" # ## Built-in Formatters # # * progress (default) - Prints dots for passing examples, `F` for failures, `*` # for pending. # * documentation - Prints the docstrings passed to `describe` and `it` methods # (and their aliases...
Ruby
{ "end_line": 141, "name": "setup_default", "signature": "def setup_default(output_stream, deprecation_stream)", "start_line": 126 }
{ "class_name": "Loader", "class_signature": "class Loader", "module": "RSpec" }
add
rspec-core/lib/rspec/core/formatters.rb
def add(formatter_to_use, *paths) # If a formatter instance was passed, we can register it directly, # with no need for any of the further processing that happens below. if Loader.formatters.key?(formatter_to_use.class) register formatter_to_use, notifications_for(formatter_to_use.class) ...
RSpec::Support.require_rspec_support "directory_maker" # ## Built-in Formatters # # * progress (default) - Prints dots for passing examples, `F` for failures, `*` # for pending. # * documentation - Prints the docstrings passed to `describe` and `it` methods # (and their aliases...
Ruby
{ "end_line": 177, "name": "add", "signature": "def add(formatter_to_use, *paths)", "start_line": 144 }
{ "class_name": "Loader", "class_signature": "class Loader", "module": "RSpec" }
built_in_formatter
rspec-core/lib/rspec/core/formatters.rb
def built_in_formatter(key) case key.to_s when 'd', 'doc', 'documentation' DocumentationFormatter when 'h', 'html' HtmlFormatter when 'p', 'progress' ProgressFormatter when 'j', 'json' JsonFormatter when 'bisect-drb' BisectDRbFormatter wh...
RSpec::Support.require_rspec_support "directory_maker" # ## Built-in Formatters # # * progress (default) - Prints dots for passing examples, `F` for failures, `*` # for pending. # * documentation - Prints the docstrings passed to `describe` and `it` methods # (and their aliases...
Ruby
{ "end_line": 226, "name": "built_in_formatter", "signature": "def built_in_formatter(key)", "start_line": 211 }
{ "class_name": "Loader", "class_signature": "class Loader", "module": "RSpec" }
custom_formatter
rspec-core/lib/rspec/core/formatters.rb
def custom_formatter(formatter_ref) if Class === formatter_ref formatter_ref elsif string_const?(formatter_ref) begin formatter_ref.gsub(/^::/, '').split('::').inject(Object) { |a, e| a.const_get e } rescue NameError require(path_for(formatter_ref)) ? retry : rais...
RSpec::Support.require_rspec_support "directory_maker" # ## Built-in Formatters # # * progress (default) - Prints dots for passing examples, `F` for failures, `*` # for pending. # * documentation - Prints the docstrings passed to `describe` and `it` methods # (and their aliases...
Ruby
{ "end_line": 244, "name": "custom_formatter", "signature": "def custom_formatter(formatter_ref)", "start_line": 234 }
{ "class_name": "Loader", "class_signature": "class Loader", "module": "RSpec" }
register
rspec-core/lib/rspec/core/hooks.rb
def register(prepend_or_append, position, *args, &block) scope, options = scope_and_options_from(*args) if scope == :suite # TODO: consider making this an error in RSpec 4. For SemVer reasons, # we are only warning in RSpec 3. RSpec.warn_with "WARNING: `#{positio...
module RSpec module Core # Provides `before`, `after` and `around` hooks as a means of # supporting common setup and teardown. This module is extended # onto {ExampleGroup}, making the methods available from any `describe` # or `context` block and included in {Configuration}, making them # availab...
Ruby
{ "end_line": 469, "name": "register", "signature": "def register(prepend_or_append, position, *args, &block)", "start_line": 449 }
{ "class_name": "HookCollections", "class_signature": "class HookCollections", "module": "RSpec" }
ensure_hooks_initialized_for
rspec-core/lib/rspec/core/hooks.rb
def ensure_hooks_initialized_for(position, scope) if position == :before if scope == :example @before_example_hooks ||= @filterable_item_repo_class.new(:all?) else @before_context_hooks ||= @filterable_item_repo_class.new(:all?) end els...
module RSpec module Core # Provides `before`, `after` and `around` hooks as a means of # supporting common setup and teardown. This module is extended # onto {ExampleGroup}, making the methods available from any `describe` # or `context` block and included in {Configuration}, making them # availab...
Ruby
{ "end_line": 569, "name": "ensure_hooks_initialized_for", "signature": "def ensure_hooks_initialized_for(position, scope)", "start_line": 553 }
{ "class_name": "HookCollections", "class_signature": "class HookCollections", "module": "RSpec" }
process
rspec-core/lib/rspec/core/hooks.rb
def process(host, parent_groups, globals, position, scope) hooks_to_process = globals.processable_hooks_for(position, scope, host) return if hooks_to_process.empty? hooks_to_process -= FlatMap.flat_map(parent_groups) do |group| group.hooks.all_hooks_for(position, scope) ...
module RSpec module Core # Provides `before`, `after` and `around` hooks as a means of # supporting common setup and teardown. This module is extended # onto {ExampleGroup}, making the methods available from any `describe` # or `context` block and included in {Configuration}, making them # availab...
Ruby
{ "end_line": 582, "name": "process", "signature": "def process(host, parent_groups, globals, position, scope)", "start_line": 571 }
{ "class_name": "HookCollections", "class_signature": "class HookCollections", "module": "RSpec" }
extract_scope_from
rspec-core/lib/rspec/core/hooks.rb
def extract_scope_from(args) if known_scope?(args.first) normalized_scope_for(args.shift) elsif args.any? { |a| a.is_a?(Symbol) } error_message = "You must explicitly give a scope " \ "(#{SCOPES.join(", ")}) or scope alias " \ "(#{SCOPE_ALIASES.key...
module RSpec module Core # Provides `before`, `after` and `around` hooks as a means of # supporting common setup and teardown. This module is extended # onto {ExampleGroup}, making the methods available from any `describe` # or `context` block and included in {Configuration}, making them # availab...
Ruby
{ "end_line": 603, "name": "extract_scope_from", "signature": "def extract_scope_from(args)", "start_line": 591 }
{ "class_name": "HookCollections", "class_signature": "class HookCollections", "module": "RSpec" }
call
rspec-core/lib/rspec/core/invocations.rb
def call(options, err, out) RSpec::Support.require_rspec_core "bisect/coordinator" runner = Runner.new(options).tap { |r| r.configure(err, out) } formatter = bisect_formatter_klass_for(options.options[:bisect]).new( out, runner.configuration.bisect_runner ) ...
module RSpec module Core # @private module Invocations # @private class InitializeProject def call(*_args) RSpec::Support.require_rspec_core "project_initializer" ProjectInitializer.new.run 0 end end # @private class DRbWithFallback ...
Ruby
{ "end_line": 41, "name": "call", "signature": "def call(options, err, out)", "start_line": 29 }
{ "class_name": "Bisect", "class_signature": "class Bisect", "module": "RSpec" }
call
rspec-core/lib/rspec/core/invocations.rb
def call(_options, _err, out) overall_version = RSpec::Core::Version::STRING unless overall_version =~ /[a-zA-Z]+/ overall_version = overall_version.split('.').first(2).join('.') end out.puts "RSpec #{overall_version}" [:Core, :Expectations, :Mocks, :Rails...
module RSpec module Core # @private module Invocations # @private class InitializeProject def call(*_args) RSpec::Support.require_rspec_core "project_initializer" ProjectInitializer.new.run 0 end end # @private class DRbWithFallback ...
Ruby
{ "end_line": 74, "name": "call", "signature": "def call(_options, _err, out)", "start_line": 53 }
{ "class_name": "PrintVersion", "class_signature": "class PrintVersion", "module": "RSpec" }
enforce_value_expectation
rspec-core/lib/rspec/core/memoized_helpers.rb
def enforce_value_expectation(matcher, method_name) return if matcher_supports_value_expectations?(matcher) RSpec.deprecate( "#{method_name} #{RSpec::Support::ObjectFormatter.format(matcher)}", :message => "The implicit block expectation syntax is deprecated, you should ...
RSpec::Support.require_rspec_support 'reentrant_mutex' module RSpec module Core # This module is included in {ExampleGroup}, making the methods # available to be called from within example blocks. # # @see ClassMethods module MemoizedHelpers # @note `subject` was contributed by Joe Ferris t...
Ruby
{ "end_line": 161, "name": "enforce_value_expectation", "signature": "def enforce_value_expectation(matcher, method_name)", "start_line": 150 }
{ "class_name": "", "class_signature": "", "module": "RSpec" }
isolate_for_context_hook
rspec-core/lib/rspec/core/memoized_helpers.rb
def self.isolate_for_context_hook(example_group_instance) exploding_memoized = self example_group_instance.instance_exec do @__memoized = exploding_memoized begin yield ensure # This is doing a reset instead of just isolating for cont...
RSpec::Support.require_rspec_support 'reentrant_mutex' module RSpec module Core # This module is included in {ExampleGroup}, making the methods # available to be called from within example blocks. # # @see ClassMethods module MemoizedHelpers # @note `subject` was contributed by Joe Ferris t...
Ruby
{ "end_line": 220, "name": "isolate_for_context_hook", "signature": "def self.isolate_for_context_hook(example_group_instance)", "start_line": 201 }
{ "class_name": "ContextHookMemoized", "class_signature": "class ContextHookMemoized", "module": "RSpec" }
fetch_or_store
rspec-core/lib/rspec/core/memoized_helpers.rb
def self.fetch_or_store(key, &_block) description = if key == :subject "subject" else "let declaration `#{key}`" end raise <<-EOS #{description} accessed in #{article} #{hook_expression} hook at: #...
RSpec::Support.require_rspec_support 'reentrant_mutex' module RSpec module Core # This module is included in {ExampleGroup}, making the methods # available to be called from within example blocks. # # @see ClassMethods module MemoizedHelpers # @note `subject` was contributed by Joe Ferris t...
Ruby
{ "end_line": 238, "name": "fetch_or_store", "signature": "def self.fetch_or_store(key, &_block)", "start_line": 222 }
{ "class_name": "ContextHookMemoized", "class_signature": "class ContextHookMemoized", "module": "RSpec" }
let
rspec-core/lib/rspec/core/memoized_helpers.rb
def let(name, &block) # We have to pass the block directly to `define_method` to # allow it to use method constructs like `super` and `return`. raise "#let or #subject called without a block" if block.nil? # A list of reserved words that can't be used as a name for a memoized he...
RSpec::Support.require_rspec_support 'reentrant_mutex' module RSpec module Core # This module is included in {ExampleGroup}, making the methods # available to be called from within example blocks. # # @see ClassMethods module MemoizedHelpers # @note `subject` was contributed by Joe Ferris t...
Ruby
{ "end_line": 345, "name": "let", "signature": "def let(name, &block)", "start_line": 306 }
{ "class_name": "", "class_signature": "", "module": "RSpec" }
subject
rspec-core/lib/rspec/core/memoized_helpers.rb
def subject(name=nil, &block) if name let(name, &block) alias_method :subject, name self::NamedSubjectPreventSuper.__send__(:define_method, name) do raise NotImplementedError, "`super` in named subjects is not supported" end else ...
RSpec::Support.require_rspec_support 'reentrant_mutex' module RSpec module Core # This module is included in {ExampleGroup}, making the methods # available to be called from within example blocks. # # @see ClassMethods module MemoizedHelpers # @note `subject` was contributed by Joe Ferris t...
Ruby
{ "end_line": 455, "name": "subject", "signature": "def subject(name=nil, &block)", "start_line": 444 }
{ "class_name": "", "class_signature": "", "module": "RSpec" }
module_for
rspec-core/lib/rspec/core/memoized_helpers.rb
def self.module_for(example_group) get_constant_or_yield(example_group, :LetDefinitions) do mod = Module.new do include(Module.new { example_group.const_set(:NamedSubjectPreventSuper, self) }) end example_group.const_set(:LetDefinitions, mod) ...
RSpec::Support.require_rspec_support 'reentrant_mutex' module RSpec module Core # This module is included in {ExampleGroup}, making the methods # available to be called from within example blocks. # # @see ClassMethods module MemoizedHelpers # @note `subject` was contributed by Joe Ferris t...
Ruby
{ "end_line": 539, "name": "module_for", "signature": "def self.module_for(example_group)", "start_line": 528 }
{ "class_name": "", "class_signature": "", "module": "RSpec" }
populate
rspec-core/lib/rspec/core/metadata.rb
def populate ensure_valid_user_keys metadata[:block] = block metadata[:description_args] = description_args metadata[:description] = build_description_from(*metadata[:description_args]) metadata[:full_description] = full_description metadata[:...
module RSpec module Core # Each ExampleGroup class and Example instance owns an instance of # Metadata, which is Hash extended to support lazy evaluation of values # associated with keys that may or may not be used by any example or group. # # In addition to metadata that is used internally, this ...
Ruby
{ "end_line": 139, "name": "populate", "signature": "def populate", "start_line": 128 }
{ "class_name": "HashPopulator", "class_signature": "class HashPopulator", "module": "RSpec" }
populate_location_attributes
rspec-core/lib/rspec/core/metadata.rb
def populate_location_attributes backtrace = user_metadata.delete(:caller) file_path, line_number = if backtrace file_path_and_line_number_from(backtrace) elsif block.respond_to?(:source_location) ...
module RSpec module Core # Each ExampleGroup class and Example instance owns an instance of # Metadata, which is Hash extended to support lazy evaluation of values # associated with keys that may or may not be used by any example or group. # # In addition to metadata that is used internally, this ...
Ruby
{ "end_line": 162, "name": "populate_location_attributes", "signature": "def populate_location_attributes", "start_line": 143 }
{ "class_name": "HashPopulator", "class_signature": "class HashPopulator", "module": "RSpec" }
ensure_valid_user_keys
rspec-core/lib/rspec/core/metadata.rb
def ensure_valid_user_keys RESERVED_KEYS.each do |key| next unless user_metadata.key?(key) raise <<-EOM.gsub(/^\s+\|/, '') |#{"*" * 50} |:#{key} is not allowed | |RSpec reserves some hash keys for its own internal use, ...
module RSpec module Core # Each ExampleGroup class and Example instance owns an instance of # Metadata, which is Hash extended to support lazy evaluation of values # associated with keys that may or may not be used by any example or group. # # In addition to metadata that is used internally, this ...
Ruby
{ "end_line": 209, "name": "ensure_valid_user_keys", "signature": "def ensure_valid_user_keys", "start_line": 191 }
{ "class_name": "HashPopulator", "class_signature": "class HashPopulator", "module": "RSpec" }
create
rspec-core/lib/rspec/core/metadata.rb
def self.create(group_metadata, user_metadata, index_provider, description, block) example_metadata = group_metadata.dup group_metadata = Hash.new(&ExampleGroupHash.backwards_compatibility_default_proc do |hash| hash[:parent_example_group] end) group_metadata.update(e...
module RSpec module Core # Each ExampleGroup class and Example instance owns an instance of # Metadata, which is Hash extended to support lazy evaluation of values # associated with keys that may or may not be used by any example or group. # # In addition to metadata that is used internally, this ...
Ruby
{ "end_line": 230, "name": "create", "signature": "def self.create(group_metadata, user_metadata, index_provider, description, block)", "start_line": 214 }
{ "class_name": "ExampleHash", "class_signature": "class ExampleHash < < HashPopulator", "module": "RSpec" }
create
rspec-core/lib/rspec/core/metadata.rb
def self.create(parent_group_metadata, user_metadata, example_group_index, *args, &block) group_metadata = hash_with_backwards_compatibility_default_proc if parent_group_metadata group_metadata.update(parent_group_metadata) group_metadata[:parent_example_group] = parent_grou...
module RSpec module Core # Each ExampleGroup class and Example instance owns an instance of # Metadata, which is Hash extended to support lazy evaluation of values # associated with keys that may or may not be used by any example or group. # # In addition to metadata that is used internally, this ...
Ruby
{ "end_line": 259, "name": "create", "signature": "def self.create(parent_group_metadata, user_metadata, example_group_index, *args, &block)", "start_line": 248 }
{ "class_name": "ExampleGroupHash", "class_signature": "class ExampleGroupHash < < HashPopulator", "module": "RSpec" }
backwards_compatibility_default_proc
rspec-core/lib/rspec/core/metadata.rb
def self.backwards_compatibility_default_proc(&example_group_selector) Proc.new do |hash, key| case key when :example_group # We commonly get here when rspec-core is applying a previously # configured filter rule, such as when a gem configures: ...
module RSpec module Core # Each ExampleGroup class and Example instance owns an instance of # Metadata, which is Hash extended to support lazy evaluation of values # associated with keys that may or may not be used by any example or group. # # In addition to metadata that is used internally, this ...
Ruby
{ "end_line": 300, "name": "backwards_compatibility_default_proc", "signature": "def self.backwards_compatibility_default_proc(&example_group_selector)", "start_line": 265 }
{ "class_name": "ExampleGroupHash", "class_signature": "class ExampleGroupHash < < HashPopulator", "module": "RSpec" }
filter_applies?
rspec-core/lib/rspec/core/metadata_filter.rb
def filter_applies?(key, filter_value, metadata) silence_metadata_example_group_deprecations do return location_filter_applies?(filter_value, metadata) if key == :locations return id_filter_applies?(filter_value, metadata) if key == :ids return filters_apply?(key, fil...
module RSpec module Core # Contains metadata filtering logic. This has been extracted from # the metadata classes because it operates ON a metadata hash but # does not manage any of the state in the hash. We're moving towards # having metadata be a raw hash (not a custom subclass), so externalizing ...
Ruby
{ "end_line": 30, "name": "filter_applies?", "signature": "def filter_applies?(key, filter_value, metadata)", "start_line": 16 }
{ "class_name": "", "class_signature": "", "module": "RSpec" }
for
rspec-core/lib/rspec/core/notifications.rb
def self.for(example) execution_result = example.execution_result return SkippedExampleNotification.new(example) if execution_result.example_skipped? return new(example) unless execution_result.status == :pending || execution_result.status == :failed klass = if execution_result.pending...
RSpec::Support.require_rspec_core "formatters/console_codes" RSpec::Support.require_rspec_core "formatters/exception_presenter" RSpec::Support.require_rspec_core "formatters/helpers" RSpec::Support.require_rspec_core "shell_escape" module RSpec::Core # Notifications are value objects passed to formatters to provide ...
Ruby
{ "end_line": 56, "name": "for", "signature": "def self.for(example)", "start_line": 41 }
{ "class_name": "ExampleNotification", "class_signature": "class ExampleNotification", "module": "RSpec" }
fully_formatted
rspec-core/lib/rspec/core/notifications.rb
def fully_formatted(pending_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes) formatted_caller = RSpec.configuration.backtrace_formatter.backtrace_line(example.location) [ colorizer.wrap("\n #{pending_number}) #{example.full_description}", :pending), "\n ", F...
RSpec::Support.require_rspec_core "formatters/console_codes" RSpec::Support.require_rspec_core "formatters/exception_presenter" RSpec::Support.require_rspec_core "formatters/helpers" RSpec::Support.require_rspec_core "shell_escape" module RSpec::Core # Notifications are value objects passed to formatters to provide ...
Ruby
{ "end_line": 245, "name": "fully_formatted", "signature": "def fully_formatted(pending_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes)", "start_line": 235 }
{ "class_name": "SkippedExampleNotification", "class_signature": "class SkippedExampleNotification < < ExampleNotification", "module": "RSpec" }
totals_line
rspec-core/lib/rspec/core/notifications.rb
def totals_line summary = Formatters::Helpers.pluralize(example_count, "example") + ", " + Formatters::Helpers.pluralize(failure_count, "failure") summary += ", #{pending_count} pending" if pending_count > 0 if errors_outside_of_examples_count > 0 summary += ( ", ...
RSpec::Support.require_rspec_core "formatters/console_codes" RSpec::Support.require_rspec_core "formatters/exception_presenter" RSpec::Support.require_rspec_core "formatters/helpers" RSpec::Support.require_rspec_core "shell_escape" module RSpec::Core # Notifications are value objects passed to formatters to provide ...
Ruby
{ "end_line": 336, "name": "totals_line", "signature": "def totals_line", "start_line": 324 }
{ "class_name": "SummaryNotification", "class_signature": "class SummaryNotification", "module": "RSpec" }
duplicate_rerun_locations
rspec-core/lib/rspec/core/notifications.rb
def duplicate_rerun_locations @duplicate_rerun_locations ||= begin locations = RSpec.world.all_examples.map(&:location_rerun_argument) Set.new.tap do |s| locations.group_by { |l| l }.each do |l, ls| s << l if ls.count > 1 end end end ...
RSpec::Support.require_rspec_core "formatters/console_codes" RSpec::Support.require_rspec_core "formatters/exception_presenter" RSpec::Support.require_rspec_core "formatters/helpers" RSpec::Support.require_rspec_core "shell_escape" module RSpec::Core # Notifications are value objects passed to formatters to provide ...
Ruby
{ "end_line": 420, "name": "duplicate_rerun_locations", "signature": "def duplicate_rerun_locations", "start_line": 410 }
{ "class_name": "SummaryNotification", "class_signature": "class SummaryNotification", "module": "RSpec" }
parse
rspec-core/lib/rspec/core/option_parser.rb
def parse(source=nil) return { :files_or_directories_to_run => [] } if original_args.empty? args = original_args.dup options = args.delete('--tty') ? { :tty => true } : {} begin parser(options).parse!(args) rescue OptionParser::InvalidOption => e abort "#{e.message}#{" (de...
# http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html require 'optparse' module RSpec::Core # @private class Parser def self.parse(args, source=nil) new(args).parse(source) end attr_reader :original_args def initialize(original_args) @original_args = original...
Ruby
{ "end_line": 31, "name": "parse", "signature": "def parse(source=nil)", "start_line": 17 }
{ "class_name": "Parser", "class_signature": "class Parser", "module": "RSpec" }
jenkins_hash_digest
rspec-core/lib/rspec/core/ordering.rb
def jenkins_hash_digest(string) hash = 0 string.each_byte do |byte| hash += byte hash &= MAX_32_BIT hash += ((hash << 10) & MAX_32_BIT) hash &= MAX_32_BIT hash ^= hash >> 6 end hash += ((hash << 3) & MAX_32_BIT) ...
module RSpec module Core # @private module Ordering # @private # The default global ordering (defined order). class Identity def order(items) items end end # @private # Orders items randomly. class Random def initialize(configuration...
Ruby
{ "end_line": 56, "name": "jenkins_hash_digest", "signature": "def jenkins_hash_digest(string)", "start_line": 39 }
{ "class_name": "Random", "class_signature": "class Random", "module": "RSpec" }
order=
rspec-core/lib/rspec/core/ordering.rb
def order=(type) order, seed = type.to_s.split(':') @seed = seed.to_i if seed ordering_name = if order.include?('rand') :random elsif order == 'defined' :defined elsif order == 'rec...
module RSpec module Core # @private module Ordering # @private # The default global ordering (defined order). class Identity def order(items) items end end # @private # Orders items randomly. class Random def initialize(configuration...
Ruby
{ "end_line": 188, "name": "order=", "signature": "def order=(type)", "start_line": 164 }
{ "class_name": "ConfigurationManager", "class_signature": "class ConfigurationManager", "module": "RSpec" }
force
rspec-core/lib/rspec/core/ordering.rb
def force(hash) if hash.key?(:seed) self.seed = hash[:seed] @seed_forced = true @order_forced = true elsif hash.key?(:order) self.order = hash[:order] @order_forced = true end end
module RSpec module Core # @private module Ordering # @private # The default global ordering (defined order). class Identity def order(items) items end end # @private # Orders items randomly. class Random def initialize(configuration...
Ruby
{ "end_line": 199, "name": "force", "signature": "def force(hash)", "start_line": 190 }
{ "class_name": "ConfigurationManager", "class_signature": "class ConfigurationManager", "module": "RSpec" }
pending
rspec-core/lib/rspec/core/pending.rb
def pending(message=nil, &_block) current_example = RSpec.current_example if block_given? raise ArgumentError, <<-EOS.gsub(/^\s+\|/, '') |The semantics of `RSpec::Core::Pending#pending` have changed in |RSpec 3. In RSpec 2.x, it caused the example to be skipped. In ...
module RSpec module Core # Provides methods to mark examples as pending. These methods are available # to be called from within any example or hook. module Pending # Raised in the middle of an example to indicate that it should be marked # as skipped. class SkipDeclaredInExample < Standa...
Ruby
{ "end_line": 89, "name": "pending", "signature": "def pending(message=nil, &_block)", "start_line": 62 }
{ "class_name": "", "class_signature": "", "module": "RSpec" }
mark_pending!
rspec-core/lib/rspec/core/pending.rb
def self.mark_pending!(example, message_or_bool) message = if !message_or_bool || !(String === message_or_bool) NO_REASON_GIVEN else message_or_bool end example.metadata[:pending] = true example.execution_result.pending...
module RSpec module Core # Provides methods to mark examples as pending. These methods are available # to be called from within any example or hook. module Pending # Raised in the middle of an example to indicate that it should be marked # as skipped. class SkipDeclaredInExample < Standa...
Ruby
{ "end_line": 145, "name": "mark_pending!", "signature": "def self.mark_pending!(example, message_or_bool)", "start_line": 135 }
{ "class_name": "", "class_signature": "", "module": "RSpec" }
initialize
rspec-core/lib/rspec/core/rake_task.rb
def initialize(*args, &task_block) @name = args.shift || :spec @ruby_opts = nil @rspec_opts = nil @verbose = true @fail_on_error = true @rspec_path = DEFAULT_RSPEC_PATH @pattern = DEFAULT_PATTERN define(args, &task_block) ...
require 'rake' require 'rake/tasklib' require 'rspec/support' RSpec::Support.require_rspec_support "ruby_features" # :nocov: unless RSpec::Support.respond_to?(:require_rspec_core) RSpec::Support.define_optimized_require_for_rspec(:core) { |f| require_relative "../#{f}" } end # :nocov: RSpec::Support.require_rspec_...
Ruby
{ "end_line": 89, "name": "initialize", "signature": "def initialize(*args, &task_block)", "start_line": 79 }
{ "class_name": "RakeTask", "class_signature": "class RakeTask < < ::Rake::TaskLib", "module": "RSpec" }
run_task
rspec-core/lib/rspec/core/rake_task.rb
def run_task(verbose) command = spec_command puts command if verbose if with_clean_environment return if system({}, command, :unsetenv_others => true) else return if system(command) end puts failure_message if failure_message return unless f...
require 'rake' require 'rake/tasklib' require 'rspec/support' RSpec::Support.require_rspec_support "ruby_features" # :nocov: unless RSpec::Support.respond_to?(:require_rspec_core) RSpec::Support.define_optimized_require_for_rspec(:core) { |f| require_relative "../#{f}" } end # :nocov: RSpec::Support.require_rspec_...
Ruby
{ "end_line": 107, "name": "run_task", "signature": "def run_task(verbose)", "start_line": 92 }
{ "class_name": "RakeTask", "class_signature": "class RakeTask < < ::Rake::TaskLib", "module": "RSpec" }
initialize
rspec-core/lib/rspec/core/reporter.rb
def initialize(configuration) @configuration = configuration @listeners = Hash.new { |h, k| h[k] = Set.new } @examples = [] @failed_examples = [] @pending_examples = [] @duration = @start = @load_time = nil @non_example_exception_count = 0 @setup_default = lambda {} ...
module RSpec::Core # A reporter will send notifications to listeners, usually formatters for the # spec suite run. class Reporter # @private RSPEC_NOTIFICATIONS = Set.new( [ :close, :deprecation, :deprecation_summary, :dump_failures, :dump_pending, :dump_profile, :dump_summary, :exam...
Ruby
{ "end_line": 25, "name": "initialize", "signature": "def initialize(configuration)", "start_line": 14 }
{ "class_name": "Reporter", "class_signature": "class Reporter", "module": "RSpec" }
finish
rspec-core/lib/rspec/core/reporter.rb
def finish close_after do stop notify :start_dump, Notifications::NullNotification notify :dump_pending, Notifications::ExamplesNotification.new(self) notify :dump_failures, Notifications::ExamplesNotification.new(self) notify :deprecation_summary, Notifications::NullNo...
module RSpec::Core # A reporter will send notifications to listeners, usually formatters for the # spec suite run. class Reporter # @private RSPEC_NOTIFICATIONS = Set.new( [ :close, :deprecation, :deprecation_summary, :dump_failures, :dump_pending, :dump_profile, :dump_summary, :exam...
Ruby
{ "end_line": 190, "name": "finish", "signature": "def finish", "start_line": 173 }
{ "class_name": "Reporter", "class_signature": "class Reporter", "module": "RSpec" }