source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/test_unit_assertions_adapter.rb | Ruby | mit | 93 | main | 542 | require 'test/unit/assertions'
module RSpec
module Core
# @private
module TestUnitAssertionsAdapter
include ::Test::Unit::Assertions
# Only if Minitest 5.x is included / loaded do we need to worry about
# adding a shim, older versions automatically included their assertion module.
if... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/runner.rb | Ruby | mit | 93 | main | 7,060 | module RSpec
module Core
# Provides the main entry point to run a suite of RSpec examples.
class Runner
# @attr_reader
# @private
attr_reader :options, :configuration, :world
# Register an `at_exit` hook that runs the suite when the process exits.
#
# @note This is not gen... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/pending.rb | Ruby | mit | 93 | main | 5,116 | 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... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/reporter.rb | Ruby | mit | 93 | main | 8,617 | 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... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/output_wrapper.rb | Ruby | mit | 93 | main | 606 | module RSpec
module Core
# @private
class OutputWrapper
# @private
attr_accessor :output
# @private
def initialize(output)
@output = output
end
def respond_to?(*args)
output.respond_to?(*args)
end
def method_missing(name, *args, &block)
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/metadata.rb | Ruby | mit | 93 | main | 10,503 | 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 ... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/minitest_assertions_adapter.rb | Ruby | mit | 93 | main | 956 | begin
# Only Minitest 5.x includes minitest.rb and assertions.rb files
require 'minitest'
require 'minitest/assertions'
rescue LoadError
# We must be using Minitest 4.x
require 'minitest/unit'
Minitest = MiniTest
end
module RSpec
module Core
# @private
module MinitestAssertionsAdapter
inclu... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/set.rb | Ruby | mit | 93 | main | 979 | module RSpec
module Core
# @private
#
# We use this to replace `::Set` so we can have the advantage of
# constant time key lookups for unique arrays but without the
# potential to pollute a developers environment with an extra
# piece of the stdlib. This helps to prevent false positive
# b... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/rake_task.rb | Ruby | mit | 93 | main | 6,101 | 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_... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/invocations.rb | Ruby | mit | 93 | main | 2,528 | 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
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/ruby_project.rb | Ruby | mit | 93 | main | 1,449 | # This is borrowed (slightly modified) from Scott Taylor's
# project_path project:
# http://github.com/smtlaissezfaire/project_path
module RSpec
module Core
# @private
module RubyProject
def add_to_load_path(*dirs)
dirs.each { |dir| add_dir_to_load_path(File.join(root, dir)) }
end
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/sandbox.rb | Ruby | mit | 93 | main | 1,262 | module RSpec
module Core
# A sandbox isolates the enclosed code into an environment that looks 'new'
# meaning globally accessed objects are reset for the duration of the
# sandbox.
#
# @note This module is not normally available. You must require
# `rspec/core/sandbox` to load it.
modul... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/version.rb | Ruby | mit | 93 | main | 205 | module RSpec
module Core
# Version information for RSpec Core.
module Version
# Current version of RSpec Core, in semantic versioning format.
STRING = '4.0.0.beta1'
end
end
end |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/notifications.rb | Ruby | mit | 93 | main | 19,026 | 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 ... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/hooks.rb | Ruby | mit | 93 | main | 25,579 | 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... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters.rb | Ruby | mit | 93 | main | 9,712 | 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... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/project_initializer.rb | Ruby | mit | 93 | main | 1,298 | RSpec::Support.require_rspec_support "directory_maker"
module RSpec
module Core
# @private
# Generates conventional files for an RSpec project.
class ProjectInitializer
attr_reader :destination, :stream, :template_path
DOT_RSPEC_FILE = '.rspec'
SPEC_HELPER_FILE = 'spec/spec_helper.rb'... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/ordering.rb | Ruby | mit | 93 | main | 5,456 | 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... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/example.rb | Ruby | mit | 93 | main | 22,095 | RSpec::Support.require_rspec_support 'ruby_features'
module RSpec
module Core
# Wrapper for an instance of a subclass of {ExampleGroup}. An instance of
# `RSpec::Core::Example` is returned by example definition methods
# such as {ExampleGroup.it it} and is yielded to the {ExampleGroup.it it},
# {Hook... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/filter_manager.rb | Ruby | mit | 93 | main | 6,104 | 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... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/drb.rb | Ruby | mit | 93 | main | 3,840 | 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... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/metadata_filter.rb | Ruby | mit | 93 | main | 7,504 | 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
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/shared_context.rb | Ruby | mit | 93 | main | 1,396 | module RSpec
module Core
# Exposes {ExampleGroup}-level methods to a module, so you can include that
# module in an {ExampleGroup}.
#
# @example
#
# module LoggedInAsAdmin
# extend RSpec::Core::SharedContext
# before(:example) do
# log_in_as :admin
# ... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/profiler.rb | Ruby | mit | 93 | main | 1,002 | module RSpec
module Core
# @private
class Profiler
NOTIFICATIONS = [:example_group_started, :example_group_finished, :example_started]
def initialize
@example_groups = Hash.new { |h, k| h[k] = { :count => 0 } }
end
attr_reader :example_groups
def example_group_started(... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/warnings.rb | Ruby | mit | 93 | main | 1,022 | require "rspec/support/warnings"
module RSpec
module Core
# @private
module Warnings
# @private
#
# Used internally to print deprecation warnings.
def deprecate(deprecated, data={})
RSpec.configuration.reporter.deprecation(
{
:deprecated => deprecated,
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/project_initializer/spec/spec_helper.rb | Ruby | mit | 93 | main | 3,925 | # This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require it in any
# file... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/bisect/example_minimizer.rb | Ruby | mit | 93 | main | 5,892 | RSpec::Support.require_rspec_core "bisect/utilities"
module RSpec
module Core
module Bisect
# @private
# Contains the core bisect logic. Searches for examples we can ignore by
# repeatedly running different subsets of the suite.
class ExampleMinimizer
attr_reader :shell_command, :... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/bisect/shell_command.rb | Ruby | mit | 93 | main | 3,934 | RSpec::Support.require_rspec_core "shell_escape"
RSpec::Support.require_rspec_support 'ruby_features'
require 'shellwords'
module RSpec
module Core
module Bisect
# Provides an API to generate shell commands to run the suite for a
# set of locations, using the given bisect server to capture the result... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/bisect/coordinator.rb | Ruby | mit | 93 | main | 2,161 | RSpec::Support.require_rspec_core "bisect/shell_command"
RSpec::Support.require_rspec_core "bisect/example_minimizer"
RSpec::Support.require_rspec_core "bisect/utilities"
RSpec::Support.require_rspec_core "formatters/bisect_progress_formatter"
module RSpec
module Core
module Bisect
# The main entry point i... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/bisect/shell_runner.rb | Ruby | mit | 93 | main | 1,262 | require 'open3'
RSpec::Support.require_rspec_core "bisect/server"
module RSpec
module Core
module Bisect
# Provides an API to run the suite for a set of locations, using
# the given bisect server to capture the results.
#
# Sets of specs are run by shelling out.
# @private
cla... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/bisect/utilities.rb | Ruby | mit | 93 | main | 1,887 | module RSpec
module Core
module Bisect
# @private
ExampleSetDescriptor = Struct.new(:all_example_ids, :failed_example_ids)
# @private
class BisectFailedError < StandardError
def self.for_failed_spec_run(spec_output)
new("Failed to get results from the spec run. Spec run ... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/bisect/server.rb | Ruby | mit | 93 | main | 1,763 | require 'drb/drb'
require 'drb/acl'
RSpec::Support.require_rspec_core "bisect/utilities"
module RSpec
module Core
# @private
module Bisect
# @private
# A DRb server that receives run results from a separate RSpec process
# started by the bisect process.
class Server
def self.r... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/bisect/fork_runner.rb | Ruby | mit | 93 | main | 5,032 | require 'stringio'
RSpec::Support.require_rspec_core "formatters/base_bisect_formatter"
RSpec::Support.require_rspec_core "bisect/utilities"
module RSpec
module Core
module Bisect
# A Bisect runner that runs requested subsets of the suite by forking
# sub-processes. The main process bootstraps RSpec ... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/progress_formatter.rb | Ruby | mit | 93 | main | 778 | RSpec::Support.require_rspec_core "formatters/base_text_formatter"
RSpec::Support.require_rspec_core "formatters/console_codes"
module RSpec
module Core
module Formatters
# @private
class ProgressFormatter < BaseTextFormatter
Formatters.register self, :example_passed, :example_pending, :examp... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/snippet_extractor.rb | Ruby | mit | 93 | main | 4,699 | RSpec::Support.require_rspec_support 'ruby_features'
module RSpec
module Core
module Formatters
# @private
class SnippetExtractor
NoSuchFileError = Class.new(StandardError)
NoSuchLineError = Class.new(StandardError)
def self.extract_line_at(file_path, line_number)
s... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/documentation_formatter.rb | Ruby | mit | 93 | main | 2,842 | RSpec::Support.require_rspec_core "formatters/base_text_formatter"
RSpec::Support.require_rspec_core "formatters/console_codes"
module RSpec
module Core
module Formatters
# @private
class DocumentationFormatter < BaseTextFormatter
Formatters.register self, :example_started, :example_group_sta... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/html_snippet_extractor.rb | Ruby | mit | 93 | main | 3,979 | module RSpec
module Core
module Formatters
# @api private
#
# Extracts code snippets by looking at the backtrace of the passed error
# and applies synax highlighting and line numbers using html.
class HtmlSnippetExtractor
# @private
module NullConverter
def ... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/profile_formatter.rb | Ruby | mit | 93 | main | 2,330 | RSpec::Support.require_rspec_core "formatters/console_codes"
module RSpec
module Core
module Formatters
# @api private
# Formatter for providing profile output.
class ProfileFormatter
Formatters.register self, :dump_profile
def initialize(output)
@output = output
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/syntax_highlighter.rb | Ruby | mit | 93 | main | 2,791 | RSpec::Support.require_rspec_support 'ruby_features'
module RSpec
module Core
module Formatters
# @private
# Provides terminal syntax highlighting of code snippets
# when coderay is available.
class SyntaxHighlighter
def initialize(configuration)
@configuration = configu... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/html_formatter.rb | Ruby | mit | 93 | main | 5,226 | RSpec::Support.require_rspec_core "formatters/base_text_formatter"
RSpec::Support.require_rspec_core "formatters/html_printer"
module RSpec
module Core
module Formatters
# @private
class HtmlFormatter < BaseFormatter
Formatters.register self, :start, :example_group_started, :start_dump,
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/bisect_drb_formatter.rb | Ruby | mit | 93 | main | 1,130 | require 'drb/drb'
RSpec::Support.require_rspec_core "formatters/base_bisect_formatter"
module RSpec
module Core
module Formatters
# Used by `--bisect`. When it shells out and runs a portion of the suite, it uses
# this formatter as a means to have the status reported back to it, via DRb.
#
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/failure_list_formatter.rb | Ruby | mit | 93 | main | 643 | RSpec::Support.require_rspec_core "formatters/base_formatter"
module RSpec
module Core
module Formatters
# @private
class FailureListFormatter < BaseFormatter
Formatters.register self, :example_failed, :dump_profile, :message
def example_failed(failure)
output.puts "#{failu... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/deprecation_formatter.rb | Ruby | mit | 93 | main | 7,825 | RSpec::Support.require_rspec_core "formatters/helpers"
module RSpec
module Core
module Formatters
# @private
class DeprecationFormatter
Formatters.register self, :deprecation, :deprecation_summary
attr_reader :count, :deprecation_stream, :summary_stream
def initialize(deprec... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/base_text_formatter.rb | Ruby | mit | 93 | main | 2,388 | RSpec::Support.require_rspec_core "formatters/base_formatter"
module RSpec
module Core
module Formatters
# Base for all of RSpec's built-in formatters. See
# RSpec::Core::Formatters::BaseFormatter to learn more about all of the
# methods called by the reporter.
#
# @see RSpec::Core:... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/json_formatter.rb | Ruby | mit | 93 | main | 3,303 | RSpec::Support.require_rspec_core "formatters/base_formatter"
require 'json'
module RSpec
module Core
module Formatters
# @private
class JsonFormatter < BaseFormatter
Formatters.register self, :message, :dump_summary, :dump_profile, :stop, :seed, :close
attr_reader :output_hash
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/base_formatter.rb | Ruby | mit | 93 | main | 2,074 | RSpec::Support.require_rspec_core "formatters/helpers"
require 'stringio'
module RSpec
module Core
module Formatters
# RSpec's built-in formatters are all subclasses of
# RSpec::Core::Formatters::BaseFormatter.
#
# @see RSpec::Core::Formatters::BaseTextFormatter
# @see RSpec::Core::... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/console_codes.rb | Ruby | mit | 93 | main | 2,511 | module RSpec
module Core
module Formatters
# ConsoleCodes provides helpers for formatting console output
# with ANSI codes, e.g. color's and bold.
module ConsoleCodes
# @private
VT100_CODES =
{
:black => 30,
:red => 31,
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/base_bisect_formatter.rb | Ruby | mit | 93 | main | 1,480 | RSpec::Support.require_rspec_core "bisect/utilities"
module RSpec
module Core
module Formatters
# Contains common logic for formatters used by `--bisect` to communicate results
# back to the bisect runner.
#
# Subclasses must define a `notify_results(all_example_ids, failed_example_ids)`
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/protocol.rb | Ruby | mit | 93 | main | 6,492 | module RSpec
module Core
module Formatters
# This class isn't loaded at runtime but serves to document all of the
# notifications implemented as part of the standard interface. The
# reporter will issue these during a normal test suite run, but a
# formatter will only receive those notific... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/helpers.rb | Ruby | mit | 93 | main | 4,050 | RSpec::Support.require_rspec_core "shell_escape"
module RSpec
module Core
module Formatters
# Formatters helpers.
module Helpers
# @private
SUB_SECOND_PRECISION = 5
# @private
DEFAULT_PRECISION = 2
# @api private
#
# Formats seconds into a hum... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/exception_presenter.rb | Ruby | mit | 93 | main | 20,117 | RSpec::Support.require_rspec_core "formatters/console_codes"
RSpec::Support.require_rspec_core "formatters/snippet_extractor"
RSpec::Support.require_rspec_core 'formatters/syntax_highlighter'
RSpec::Support.require_rspec_support "encoded_string"
module RSpec
module Core
module Formatters
# @private
c... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/html_printer.rb | Ruby | mit | 93 | main | 11,751 | require 'erb'
module RSpec
module Core
module Formatters
# @private
class HtmlPrinter
include ERB::Util # For the #h method.
def initialize(output)
@output = output
end
def print_html_start
@output.puts HTML_HEADER
@output.puts REPORT_HE... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/fallback_message_formatter.rb | Ruby | mit | 93 | main | 682 | module RSpec
module Core
module Formatters
# @api private
# Formatter for providing message output as a fallback when no other
# profiler implements #message
class FallbackMessageFormatter
Formatters.register self, :message
def initialize(output)
@output = output... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/formatters/bisect_progress_formatter.rb | Ruby | mit | 93 | main | 6,085 | RSpec::Support.require_rspec_core "formatters/base_text_formatter"
module RSpec
module Core
module Formatters
# @private
# Produces progress output while bisecting.
class BisectProgressFormatter < BaseTextFormatter
def initialize(output, bisect_runner)
super(output)
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/mocking_adapters/mocha.rb | Ruby | mit | 93 | main | 445 | require 'mocha/api'
module RSpec
module Core
module MockingAdapters
# @private
module Mocha
def self.framework_name
:mocha
end
include ::Mocha::API
def setup_mocks_for_rspec
mocha_setup
end
def verify_mocks_for_rspec
moc... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/mocking_adapters/rspec.rb | Ruby | mit | 93 | main | 575 | require 'rspec/mocks'
module RSpec
module Core
module MockingAdapters
# @private
module RSpec
include ::RSpec::Mocks::ExampleMethods
def self.framework_name
:rspec
end
def self.configuration
::RSpec::Mocks.configuration
end
def se... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/mocking_adapters/null.rb | Ruby | mit | 93 | main | 240 | module RSpec
module Core
module MockingAdapters
# @private
module Null
def setup_mocks_for_rspec; end
def verify_mocks_for_rspec; end
def teardown_mocks_for_rspec; end
end
end
end
end |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/mocking_adapters/flexmock.rb | Ruby | mit | 93 | main | 567 | # Created by Jim Weirich on 2007-04-10.
# Copyright (c) 2007. All rights reserved.
require 'flexmock/rspec'
module RSpec
module Core
module MockingAdapters
# @private
module Flexmock
include ::FlexMock::MockContainer
def self.framework_name
:flexmock
end
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/mocking_adapters/rr.rb | Ruby | mit | 93 | main | 607 | require 'rr'
RSpec.configuration.backtrace_exclusion_patterns.push(RR::Errors::BACKTRACE_IDENTIFIER)
module RSpec
module Core
# @private
module MockingAdapters
# @private
module RR
def self.framework_name
:rr
end
include ::RR::Extensions::InstanceMethods
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/Rakefile | Ruby | mit | 93 | main | 848 | # frozen_string_literal: true
require "bundler"
Bundler.setup
Bundler::GemHelper.install_tasks
Bundler::GemHelper.tag_prefix = 'rspec-support-'
require "rake"
require "rspec/core/rake_task"
require "rspec/core/version"
desc "Run all examples"
RSpec::Core::RakeTask.new(:spec) do |t|
t.ruby_opts = %w[-w]
end
task ... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/rspec-support.gemspec | Ruby | mit | 93 | main | 1,560 | # frozen_string_literal: true
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rspec/support/version'
Gem::Specification.new do |s|
s.name = "rspec-support"
s.version = RSpec::Support::Version::STRING
s.authors = ["David Chelimsky",... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support.rb | Ruby | mit | 93 | main | 4,333 | # frozen_string_literal: true
class Thread
attr_accessor :__rspec_local_data
class << self
alias __rspec_current_thread current
end
end
module RSpec
module Support
# @api private
#
# Defines a helper method that is optimized to require files from the
# named lib. The passed block MUST be ... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/reentrant_mutex.rb | Ruby | mit | 93 | main | 1,128 | # frozen_string_literal: true
module RSpec
module Support
# This class protects us against Mutex.new stubbed out within tests.
# @private
class Mutex < ::Mutex
class << self
define_method(:new, &::Mutex.method(:new))
end
end
# Allows a thread to lock out other threads from a ... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/matcher_definition.rb | Ruby | mit | 93 | main | 1,186 | # frozen_string_literal: true
module RSpec
module Support
# @private
def self.matcher_definitions
@matcher_definitions ||= []
end
# Used internally to break cyclic dependency between mocks, expectations,
# and support. We don't currently have a consistent implementation of our
# matche... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/comparable_version.rb | Ruby | mit | 93 | main | 1,097 | # frozen_string_literal: true
module RSpec
module Support
# @private
class ComparableVersion
include Comparable
attr_reader :string
def initialize(string)
@string = string
end
def <=>(other)
other = self.class.new(other) unless other.is_a?(self.class)
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/warnings.rb | Ruby | mit | 93 | main | 1,131 | # frozen_string_literal: true
require 'rspec/support'
RSpec::Support.require_rspec_support "caller_filter"
module RSpec
module Support
module Warnings
def deprecate(deprecated, options={})
warn_with "DEPRECATION: #{deprecated} is deprecated.", options
end
# @private
#
# Us... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/ruby_features.rb | Ruby | mit | 93 | main | 2,092 | # frozen_string_literal: true
require 'rbconfig'
RSpec::Support.require_rspec_support "comparable_version"
module RSpec
module Support
# @api private
#
# Provides query methods for different OS or OS features.
module OS
module_function
def windows?
!!(RbConfig::CONFIG['host_os'] =... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/method_signature_verifier.rb | Ruby | mit | 93 | main | 13,001 | # frozen_string_literal: true
require 'rspec/support'
RSpec::Support.require_rspec_support "ruby_features"
RSpec::Support.require_rspec_support "matcher_definition"
module RSpec
module Support
# Extracts info about the number of arguments and allowed/required
# keyword args of a given method.
#
# @p... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/caller_filter.rb | Ruby | mit | 93 | main | 3,599 | # frozen_string_literal: true
module RSpec
# Consistent implementation for "cleaning" the caller method to strip out
# non-rspec lines. This enables errors to be reported at the call site in
# the code using the library, which is far more useful than the particular
# internal method that raised an error.
cla... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/directory_maker.rb | Ruby | mit | 93 | main | 1,707 | # frozen_string_literal: true
module RSpec
module Support
# @api private
#
# Replacement for fileutils#mkdir_p because we don't want to require parts
# of stdlib in RSpec.
class DirectoryMaker
# @api private
#
# Implements nested directory construction
def self.mkdir_p(pat... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/spec.rb | Ruby | mit | 93 | main | 1,395 | # frozen_string_literal: true
require 'rspec/support'
require 'rspec/support/spec/in_sub_process'
RSpec::Support.require_rspec_support "spec/coverage"
RSpec::Support.require_rspec_support "spec/deprecation_helpers"
RSpec::Support.require_rspec_support "spec/with_isolated_stderr"
RSpec::Support.require_rspec_support "... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/hunk_generator.rb | Ruby | mit | 93 | main | 964 | # frozen_string_literal: true
require 'diff/lcs'
require 'diff/lcs/hunk'
module RSpec
module Support
# @private
class HunkGenerator
def initialize(actual, expected)
@actual = actual
@expected = expected
end
def hunks
@file_length_difference = 0
@hunks ||= d... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/fuzzy_matcher.rb | Ruby | mit | 93 | main | 1,649 | # frozen_string_literal: true
module RSpec
module Support
# Provides a means to fuzzy-match between two arbitrary objects.
# Understands array/hash nesting. Uses `===` or `==` to
# perform the matching.
module FuzzyMatcher
# @api private
def self.values_match?(expected, actual)
if... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/recursive_const_methods.rb | Ruby | mit | 93 | main | 1,667 | # frozen_string_literal: true
module RSpec
module Support
# Provides recursive constant lookup methods useful for
# constant stubbing.
module RecursiveConstMethods
# We only want to consider constants that are defined directly on a
# particular module, and not include top-level/inherited cons... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/encoded_string.rb | Ruby | mit | 93 | main | 5,586 | # frozen_string_literal: true
RSpec::Support.require_rspec_support "ruby_features"
module RSpec
module Support
# @private
class EncodedString
# Reduce allocations by storing constants.
UTF_8 = "UTF-8"
US_ASCII = "US-ASCII"
# Ruby's default replacement string is:
# U+FFFD (... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/with_keywords_when_needed.rb | Ruby | mit | 93 | main | 798 | # frozen_string_literal: true
RSpec::Support.require_rspec_support("method_signature_verifier")
module RSpec
module Support
module WithKeywordsWhenNeeded
# This module adds keyword sensitive support for core ruby methods
# where we cannot use `ruby2_keywords` directly.
module_function
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/object_formatter.rb | Ruby | mit | 93 | main | 7,228 | # frozen_string_literal: true
RSpec::Support.require_rspec_support 'matcher_definition'
module RSpec
module Support
# Provide additional output details beyond what `inspect` provides when
# printing Time, DateTime, or BigDecimal
# @api private
class ObjectFormatter # rubocop:disable Metrics/ClassLen... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/differ.rb | Ruby | mit | 93 | main | 6,439 | # frozen_string_literal: true
RSpec::Support.require_rspec_support 'encoded_string'
RSpec::Support.require_rspec_support "object_formatter"
require 'pp'
module RSpec
module Support
# rubocop:disable Metrics/ClassLength
class Differ
def diff(actual, expected)
diff = ""
unless actual.n... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/source.rb | Ruby | mit | 93 | main | 2,203 | # frozen_string_literal: true
RSpec::Support.require_rspec_support 'encoded_string'
RSpec::Support.require_rspec_support 'ruby_features'
module RSpec
module Support
# @private
# Represents a Ruby source file and provides access to AST and tokens.
class Source
attr_reader :source, :path
# Th... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/spec/deprecation_helpers.rb | Ruby | mit | 93 | main | 1,650 | # frozen_string_literal: true
module RSpecHelpers
def expect_deprecation_with_call_site(file, line, snippet=//)
expect(RSpec.configuration.reporter).to receive(:deprecation).
with(include(:deprecated => match(snippet), :call_site => include([file, line].join(':'))))
end
def expect_deprecation_without_... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/spec/shell_out.rb | Ruby | mit | 93 | main | 2,841 | # frozen_string_literal: true
require 'open3'
require 'rake/file_utils'
require 'shellwords'
module RSpec
module Support
module ShellOut
def with_env(vars)
original = ENV.to_hash
vars.each { |k, v| ENV[k] = v }
begin
yield
ensure
ENV.replace(original)
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/spec/with_isolated_stderr.rb | Ruby | mit | 93 | main | 262 | # frozen_string_literal: true
module RSpec
module Support
module WithIsolatedStdErr
def with_isolated_stderr
original = $stderr
$stderr = StringIO.new
yield
ensure
$stderr = original
end
end
end
end |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/spec/string_matcher.rb | Ruby | mit | 93 | main | 1,182 | # frozen_string_literal: true
require 'rspec/matchers'
# Special matcher for comparing encoded strings so that
# we don't run any expectation failures through the Differ,
# which also relies on EncodedString. Instead, confirm the
# strings have the same bytes.
RSpec::Matchers.define :be_identical_string do |expected|
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/spec/library_wide_checks.rb | Ruby | mit | 93 | main | 5,299 | # frozen_string_literal: true
require 'rspec/support/spec/shell_out'
RSpec::Support.require_rspec_support 'ruby_features'
module RSpec
module Support
module WhitespaceChecks
# This malformed whitespace detection logic has been borrowed from bundler:
# https://github.com/bundler/bundler/blob/v1.8.0/s... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/spec/in_sub_process.rb | Ruby | mit | 93 | main | 2,419 | # frozen_string_literal: true
module RSpec
module Support
module InSubProcess
if Process.respond_to?(:fork)
UnmarshableObject = Struct.new(:error)
# Useful as a way to isolate a global change to a subprocess.
def in_sub_process(prevent_warnings=true) # rubocop:disable Metrics/Met... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/spec/coverage.rb | Ruby | mit | 93 | main | 1,498 | # frozen_string_literal: true
require 'rspec/support'
RSpec::Support.require_rspec_support "ruby_features"
module RSpec
module Support
module Spec
module Coverage
def self.setup(&block)
# Simplecov emits some ruby warnings when loaded, so silence them.
old_verbose, $VERBOSE = ... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/spec/with_isolated_directory.rb | Ruby | mit | 93 | main | 287 | # frozen_string_literal: true
require 'tmpdir'
RSpec.shared_context "isolated directory" do
around do |ex|
Dir.mktmpdir do |tmp_dir|
Dir.chdir(tmp_dir, &ex)
end
end
end
RSpec.configure do |c|
c.include_context "isolated directory", :isolated_directory => true
end |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/spec/stderr_splitter.rb | Ruby | mit | 93 | main | 1,385 | # frozen_string_literal: true
require 'stringio'
module RSpec
module Support
class StdErrSplitter
def initialize(original)
@orig_stderr = original
@output_tracker = ::StringIO.new
@last_line = nil
end
def respond_to_missing?(*args)
@orig_stderr.respond_to?(*... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/source/location.rb | Ruby | mit | 93 | main | 551 | # frozen_string_literal: true
module RSpec
module Support
class Source
# @private
# Represents a source location of node or token.
Location = Struct.new(:line, :column) do
include Comparable
def self.location?(array)
array.is_a?(Array) && array.size == 2 && array.all?... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/source/token.rb | Ruby | mit | 93 | main | 2,289 | # frozen_string_literal: true
RSpec::Support.require_rspec_support 'source/location'
module RSpec
module Support
class Source
# @private
# A wrapper for Ripper token which is generated with `Ripper.lex`.
class Token
CLOSING_TYPES_BY_OPENING_TYPE = {
:on_lbracket => :on_rbr... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/lib/rspec/support/source/node.rb | Ruby | mit | 93 | main | 2,681 | # frozen_string_literal: true
RSpec::Support.require_rspec_support 'source/location'
module RSpec
module Support
class Source
# @private
# A wrapper for Ripper AST node which is generated with `Ripper.sexp`.
class Node
include Enumerable
attr_reader :sexp, :parent
def... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/benchmarks/caller_vs_caller_locations_vs_raise.rb | Ruby | mit | 93 | main | 5,478 | # frozen_string_literal: true
# This benchmark arose from rspec/rspec-support#199 where we experimented with
# faster ways of generating / capturing a backtrace and whether it made sense
# to lazily generate it using `raise` to capture the backtrace via an exception.
# See also rspec/rspec-mocks#937
require 'benchmar... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/benchmarks/ripper.rb | Ruby | mit | 93 | main | 1,047 | # frozen_string_literal: true
require 'benchmark/ips'
require 'ripper'
ruby_version = defined?(JRUBY_VERSION) ? JRUBY_VERSION : RUBY_VERSION
puts "#{RUBY_ENGINE} #{ruby_version}"
source = File.read(__FILE__)
Benchmark.ips do |x|
x.report("Ripper") do
Ripper.sexp(source)
Ripper.lex(source)
end
end
__END... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/benchmarks/caller.rb | Ruby | mit | 93 | main | 2,407 | # frozen_string_literal: true
$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
require 'benchmark'
require 'rspec/support/caller_filter'
n = 10000
puts "#{n} times - ruby #{RUBY_VERSION}"
puts
puts "* Using a chunked fetch is quicker than the old method of array-access."
Benchmark.bm(20) do |bm|
bm.re... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/benchmarks/skip_frames_for_caller_filter.rb | Ruby | mit | 93 | main | 852 | # frozen_string_literal: true
require 'rspec/support/caller_filter'
eval <<-EOS, binding, "/lib/rspec/core/some_file.rb", 1 # make it think this code is in rspec-core
class Recurser
def self.recurse(times, *args)
return RSpec::CallerFilter.first_non_rspec_line(*args) if times.zero?
recurse(times - 1... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/benchmarks/map_hash.rb | Ruby | mit | 93 | main | 1,955 | # frozen_string_literal: true
require 'benchmark/ips'
def use_map_and_hash_bracket(input)
Hash[ input.map { |k, v| [k.to_s, v.to_s] } ]
end
def use_inject(input)
input.inject({}) do |hash, (k, v)|
hash[k.to_s] = v.to_s
hash
end
end
[10, 100, 1000].each do |size|
hash = Hash[1.upto(size).map { |i| [i... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/benchmarks/class_exec_vs_klass_exec.rb | Ruby | mit | 93 | main | 1,243 | # frozen_string_literal: true
require 'benchmark/ips'
require 'rspec/support'
require 'rspec/support/with_keywords_when_needed'
Klass = Class.new do
def test(*args, **kwargs)
end
end
def class_exec_args
Klass.class_exec(:a, :b) { }
end
def klass_exec_args
RSpec::Support::WithKeywordsWhenNeeded.class_exec(Kl... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/benchmarks/caller_vs_caller_locations.rb | Ruby | mit | 93 | main | 623 | # frozen_string_literal: true
require 'benchmark/ips'
Benchmark.ips do |x|
x.report("caller() ") { caller }
x.report("caller_locations() ") { caller_locations }
x.report("caller(1, 2) ") { caller(1, 2) }
x.report("caller_locations(1, 2)") { caller_locations(1, 2) }
end
__END__
calle... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/spec/spec_helper.rb | Ruby | mit | 93 | main | 437 | # frozen_string_literal: true
require 'rspec/support/spec'
# Preload io/console on MacOS JRuby to avoid warnings later due to https://github.com/jruby/jruby/issues/8271
require 'io/console' if RSpec::Support::Ruby.jruby? && RSpec::Support::OS.apple_silicon?
RSpec::Support::Spec::Coverage.setup
RSpec::Matchers.define... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-support/spec/rspec/support_spec.rb | Ruby | mit | 93 | main | 10,790 | # frozen_string_literal: true
require 'rspec/support'
require 'rspec/support/spec/library_wide_checks'
module RSpec
describe Support do
extend Support::RubyFeatures
it_behaves_like "library wide checks", "rspec-support",
:consider_a_test_env_file => %r{rspec/support/spec},
:allowed_loaded_featu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.