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/spec/rspec/core/reporter_spec.rb | Ruby | mit | 93 | main | 11,471 | module RSpec::Core
RSpec.describe Reporter do
include FormatterSupport
let(:config) { Configuration.new }
let(:world) { World.new(config) }
let(:reporter) { Reporter.new config }
let(:start_time) { Time.now }
let(:example) { super() }
describe "finish" do
let(:formatter) { dou... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/example_execution_result_spec.rb | Ruby | mit | 93 | main | 766 | module RSpec
module Core
class Example
RSpec.describe ExecutionResult do
it 'has `status` and `pending_message` attributes' do
expect(ExecutionResult.new).to have_attributes(
:status => nil,
:pending_message => nil
)
end
it 'provides a `pe... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/example_group_spec.rb | Ruby | mit | 93 | main | 66,335 | module RSpec::Core
RSpec.describe ExampleGroup do
it_behaves_like "metadata hash builder" do
def metadata_hash(*args)
group = RSpec.describe('example description', *args)
group.metadata
end
end
%w[ expect double spy ].each do |method|
context "when calling `#{method}`, a... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/aggregate_failures_spec.rb | Ruby | mit | 93 | main | 5,728 | RSpec.describe "Aggregating failures" do
shared_examples_for "failure aggregation" do |exception_attribute, example_meta|
context "via the `aggregate_failures` method" do
context 'when the example has an expectation failure, plus an `after` hook and an `around` hook failure' do
it 'presents a flat l... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/metadata_filter_spec.rb | Ruby | mit | 93 | main | 10,068 | module RSpec
module Core
RSpec.describe MetadataFilter do
describe ".filter_applies?" do
attr_accessor :parent_group_metadata, :group_metadata, :example_metadata
def create_metadatas
container = self
RSpec.describe "parent group", :caller => ["/foo_spec.rb:#{__LINE__}"]... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/hooks_spec.rb | Ruby | mit | 93 | main | 15,352 | module RSpec::Core
RSpec.describe Hooks do
class HooksHost
include Hooks
def parent_groups
[]
end
def register_hook(position, scope, *args, &block)
block ||= Proc.new { }
__send__(position, scope, *args, &block)
hook_collection_for(position, scope).first
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/dsl_spec.rb | Ruby | mit | 93 | main | 1,325 | require 'rspec/support/spec/in_sub_process'
main = self
RSpec.describe "The RSpec DSL" do
include RSpec::Support::InSubProcess
shared_examples_for "dsl methods" do |*method_names|
it 'are only available off of `RSpec`' do
in_sub_process do
setup
expect(::RSpec).to respond_to(*method_na... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/memoized_helpers_spec.rb | Ruby | mit | 93 | main | 19,087 | require 'thread_order'
module RSpec::Core
RSpec.describe MemoizedHelpers do
before(:each) { RSpec.configuration.configure_expectation_framework }
def subject_value_for(describe_arg, &block)
example_group = RSpec.describe(describe_arg, &block)
subject_value = nil
example_group.example { sub... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/suite_hooks_spec.rb | Ruby | mit | 93 | main | 5,027 | require "support/runner_support"
module RSpec::Core
RSpec.describe "Configuration :suite hooks" do
[:before, :after, :prepend_before, :append_before, :prepend_after, :append_after].each do |registration_method|
type = registration_method.to_s.split('_').last
describe "a `:suite` hook registered with... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/example_status_persister_spec.rb | Ruby | mit | 93 | main | 12,345 | require 'rspec/core/example_status_persister'
require 'tempfile'
module RSpec::Core
RSpec.describe "Example status persisting" do
it 'can load a previously persisted set of example statuses from disk' do
examples = [
{ :example_id => "spec_1.rb[1:1]", :status => "passed" },
{ :example_id =>... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/failed_example_notification_spec.rb | Ruby | mit | 93 | main | 820 | module RSpec::Core::Notifications
RSpec.describe FailedExampleNotification do
before do
allow(RSpec.configuration).to receive(:color_enabled?).and_return(true)
end
it "uses the default color for the shared example backtrace line" do
example = nil
group = RSpec.describe "testing" do
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/example_group_constants_spec.rb | Ruby | mit | 93 | main | 456 | RSpec.describe "::RSpec::Core::ExampleGroup" do
context "does not cause problems when users reference a top level constant of the same name" do
file_in_outer_group = File
example { expect(File).to eq ::File }
example { expect(file_in_outer_group).to be(::File) }
describe "File" do
file_in_inner... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/example_spec.rb | Ruby | mit | 93 | main | 32,239 | require 'pp'
require 'stringio'
RSpec.describe RSpec::Core::Example, :parent_metadata => 'sample' do
let(:example_group) do
RSpec.describe('group description')
end
let(:example_instance) do
example_group.example('example description') { }
end
it_behaves_like "metadata hash builder" do
def meta... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/option_parser_spec.rb | Ruby | mit | 93 | main | 13,984 | require 'rspec/core/drb'
require 'rspec/core/bisect/coordinator'
module RSpec::Core
RSpec.describe OptionParser do
before do
allow(RSpec.configuration).to receive(:reporter) do
fail "OptionParser is not allowed to access `config.reporter` since we want " +
"ConfigurationOptions to have... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/profiler_spec.rb | Ruby | mit | 93 | main | 2,667 | require 'rspec/core/profiler'
RSpec.describe 'RSpec::Core::Profiler' do
let(:profiler) { RSpec::Core::Profiler.new }
it 'starts with an empty hash of example_groups' do
expect(profiler.example_groups).to be_empty.and be_a Hash
end
context 'when hooked into the reporter' do
include FormatterSupport
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/ordering_spec.rb | Ruby | mit | 93 | main | 5,924 | module RSpec
module Core
module Ordering
RSpec.describe Identity do
it "does not affect the ordering of the items" do
expect(Identity.new.order([1, 2, 3])).to eq([1, 2, 3])
end
end
RSpec.describe Random do
describe '.order' do
subject { described_clas... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/world_spec.rb | Ruby | mit | 93 | main | 11,122 | class Bar; end
class Foo; end
module RSpec::Core
RSpec.describe RSpec::Core::World do
let(:configuration) { RSpec.configuration }
let(:world) { RSpec.world }
describe '#reset' do
it 'clears #example_groups' do
world.example_groups << :example_group
world.reset
expect(world.... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/project_initializer_spec.rb | Ruby | mit | 93 | main | 4,059 | require 'rspec/core/project_initializer'
module RSpec::Core
RSpec.describe ProjectInitializer, :isolated_directory => true do
describe "#run" do
context "with no args" do
subject(:command_line_config) { ProjectInitializer.new(:report_stream => output) }
let(:output) { StringIO.new }
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/configuration_spec.rb | Ruby | mit | 93 | main | 93,673 | require 'tmpdir'
require 'rspec/support/spec/in_sub_process'
module RSpec::Core
RSpec.describe Configuration do
include RSpec::Support::InSubProcess
let(:config) { Configuration.new }
let(:exclusion_filter) { config.exclusion_filter.rules }
let(:inclusion_filter) { config.inclusion_filter.rules }
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/pending_spec.rb | Ruby | mit | 93 | main | 218 | RSpec.describe RSpec::Core::Pending do
it 'only defines methods that are part of the DSL' do
expect(RSpec::Core::Pending.instance_methods(false).map(&:to_sym)).to \
match_array([:pending, :skip])
end
end |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/warnings_spec.rb | Ruby | mit | 93 | main | 2,477 | RSpec.describe "rspec warnings and deprecations" do
describe "#deprecate" do
it "passes the hash to the reporter" do
expect(RSpec.configuration.reporter).to receive(:deprecation).with(hash_including :deprecated => "deprecated_method", :replacement => "replacement")
RSpec.deprecate("deprecated_method"... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/rake_task_spec.rb | Ruby | mit | 93 | main | 15,424 | require "rspec/core/rake_task"
require 'tempfile'
module RSpec::Core
RSpec.describe RakeTask do
let(:task) { RakeTask.new }
def ruby
FileUtils::RUBY
end
def spec_command
task.__send__(:spec_command)
end
context "with a name passed to the constructor" do
let(:task) { RakeT... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/notifications_spec.rb | Ruby | mit | 93 | main | 16,375 | require 'rspec/core/notifications'
# ANSI codes aren't easy to read in failure output, so use tags instead
class TagColorizer
def self.wrap(text, code_or_symbol)
"<#{code_or_symbol}>#{text}</#{code_or_symbol}>"
end
end
RSpec.describe "FailedExampleNotification" do
include FormatterSupport
let(:example) {... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/set_spec.rb | Ruby | mit | 93 | main | 914 | RSpec.describe 'RSpec::Core::Set' do
let(:set) { RSpec::Core::Set.new([1, 2, 3]) }
it 'takes an array of values' do
expect(set).to include(1, 2, 3)
end
it 'can be appended to' do
set << 4
expect(set).to include 4
end
it 'can have more values merged in' do
set.merge([4, 5]).merge([6])
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/did_you_mean_spec.rb | Ruby | mit | 93 | main | 1,383 | module RSpec
module Core
RSpec.describe DidYouMean do
describe '#call' do
context "when `DidYouMean::SpellChecker` is available", :skip => !defined?(::DidYouMean::SpellChecker) do
context 'Success' do
let(:name) { './spec/rspec/core/did_you_mean_spec.rb' }
it 'retur... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/drb_spec.rb | Ruby | mit | 93 | main | 9,932 | require 'rspec/core/drb'
RSpec.describe RSpec::Core::DRbRunner, :isolated_directory => true, :isolated_home => true, :type => :drb, :skip => RUBY_PLATFORM == 'java' do
let(:config) { RSpec::Core::Configuration.new }
let(:out) { StringIO.new }
let(:err) { StringIO.new }
include_context "spec files"
de... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/hooks_filtering_spec.rb | Ruby | mit | 93 | main | 18,901 | module RSpec::Core
RSpec.describe "config block hook filtering" do
context "when hooks are defined after a group has been defined" do
before do
RSpec.configuration.order = :defined
end
it "still applies" do
sequence = []
group = RSpec.describe do
example { seq... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters_spec.rb | Ruby | mit | 93 | main | 8,848 | require 'pathname'
module RSpec::Core::Formatters
RSpec.describe Loader do
let(:output) { StringIO.new }
let(:reporter) { instance_double "Reporter", :register_listener => nil }
let(:loader) { Loader.new reporter }
describe "#add(formatter)" do
let(:path) { File.join(Dir.tmpdir, 'output.t... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/pending_example_spec.rb | Ruby | mit | 93 | main | 6,291 | RSpec.describe "an example" do
context "declared pending with metadata" do
it "uses the value assigned to :pending as the message" do
group = RSpec.describe('group') do
example "example", :pending => 'just because' do
fail
end
end
example = group.examples.first
ex... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/backtrace_formatter_spec.rb | Ruby | mit | 93 | main | 13,502 | module RSpec::Core
RSpec.describe BacktraceFormatter do
def make_backtrace_formatter(exclusion_patterns=nil, inclusion_patterns=nil)
BacktraceFormatter.new.tap do |bc|
bc.exclusion_patterns = exclusion_patterns if exclusion_patterns
bc.inclusion_patterns = inclusion_patterns if inclusion_pat... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/filter_manager_spec.rb | Ruby | mit | 93 | main | 16,249 | module RSpec::Core
RSpec.describe FilterManager do
def opposite(name)
name =~ /^in/ ? name.sub(/^(in)/,'ex') : name.sub(/^(ex)/,'in')
end
subject(:filter_manager) { FilterManager.new }
let(:inclusions) { filter_manager.inclusions }
let(:exclusions) { filter_manager.exclusions }
def pru... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/shared_context_spec.rb | Ruby | mit | 93 | main | 3,218 | RSpec.describe RSpec::SharedContext do
it "is accessible as RSpec::Core::SharedContext" do
RSpec::Core::SharedContext
end
it "is accessible as RSpec::SharedContext" do
RSpec::SharedContext
end
it "supports before and after hooks" do
before_all_hook = false
before_each_hook = false
after_... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/rspec_matchers_spec.rb | Ruby | mit | 93 | main | 1,504 | module RSpec::Matchers
def __method_with_super
super
end
module ModThatIncludesMatchers
include RSpec::Matchers
end
RSpec.configure do |c|
c.include RSpec::Matchers, :include_rspec_matchers => true
c.include ModThatIncludesMatchers, :include_mod_that_includes_rspec_matchers => true
end
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/runner_spec.rb | Ruby | mit | 93 | main | 16,129 | require 'rspec/core/drb'
require 'support/runner_support'
module RSpec::Core
RSpec.describe Runner do
describe 'invocation' do
before do
# Simulate invoking the suite like exe/rspec does.
allow(RSpec::Core::Runner).to receive(:run)
RSpec::Core::Runner.invoke
end
it 'doe... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/syntax_highlighter_spec.rb | Ruby | mit | 93 | main | 4,670 | require 'rspec/core/formatters/syntax_highlighter'
module RSpec::Core::Formatters
RSpec.describe SyntaxHighlighter do
let(:config) { RSpec::Core::Configuration.new.tap { |config| config.color_mode = :on } }
let(:highlighter) { SyntaxHighlighter.new(config) }
context "when CodeRay is available", :s... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/console_codes_spec.rb | Ruby | mit | 93 | main | 2,717 | require 'rspec/core/formatters/console_codes'
RSpec.describe "RSpec::Core::Formatters::ConsoleCodes" do
let(:console_codes) { RSpec::Core::Formatters::ConsoleCodes }
describe "#console_code_for(code_or_symbol)" do
context "when given a VT100 integer code" do
it "returns the code" do
expect(conso... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/json_formatter_spec.rb | Ruby | mit | 93 | main | 8,978 | require 'rspec/core/formatters/json_formatter'
require 'json'
require 'rspec/core/reporter'
# todo, someday:
# it "lists the groups (describe and context) separately"
# it "includes full 'execution_result'"
# it "relativizes backtrace paths"
# it "includes profile information (implements dump_profile)"
# it "shows the... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/snippet_extractor_spec.rb | Ruby | mit | 93 | main | 10,540 | require 'rspec/core/formatters/snippet_extractor'
require 'support/helper_methods'
module RSpec::Core::Formatters
RSpec.describe SnippetExtractor do
include RSpecHelpers
subject(:expression_lines) do
SnippetExtractor.extract_expression_lines_at(file_path, line_number, max_line_count)
end
let(... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/deprecation_formatter_spec.rb | Ruby | mit | 93 | main | 10,344 | require 'rspec/core/reporter'
require 'rspec/core/formatters/deprecation_formatter'
require 'tempfile'
module RSpec::Core::Formatters
RSpec.describe DeprecationFormatter do
include FormatterSupport
let(:summary_stream) { StringIO.new }
def notification(hash)
::RSpec::Core::Notifications::Deprecat... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/html_formatter_spec.rb | Ruby | mit | 93 | main | 2,595 | require 'rspec/core/formatters/html_formatter'
module RSpec
module Core
module Formatters
RSpec.describe HtmlFormatter do
include FormatterSupport
let(:root) { File.expand_path("#{File.dirname(__FILE__)}/../../../..") }
let(:expected_file) do
"#{File.dirname(__FILE__)}/h... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/documentation_formatter_spec.rb | Ruby | mit | 93 | main | 5,200 | require 'rspec/core/formatters/documentation_formatter'
module RSpec::Core::Formatters
RSpec.describe DocumentationFormatter do
include FormatterSupport
before do
send_notification :start, start_notification(2)
end
def execution_result(values)
RSpec::Core::Example::ExecutionResult.new.t... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/helpers_spec.rb | Ruby | mit | 93 | main | 4,116 | require 'rspec/core/formatters/helpers'
RSpec.describe RSpec::Core::Formatters::Helpers do
helper = described_class
describe "format duration" do
context '< 1' do
it "returns '0.xxxxx seconds' formatted string" do
expect(helper.format_duration(0.123456)).to eq("0.12346 seconds")
end
en... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/profile_formatter_spec.rb | Ruby | mit | 93 | main | 3,048 | require 'rspec/core/formatters/profile_formatter'
RSpec.describe RSpec::Core::Formatters::ProfileFormatter do
include FormatterSupport
def profile *groups
setup_profiler
groups.each { |group| group.run(reporter) }
examples = groups.map(&:examples).flatten
total_time = examples.map { |e| e.executio... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/failure_list_formatter_spec.rb | Ruby | mit | 93 | main | 842 | require 'rspec/core/formatters/failure_list_formatter'
module RSpec::Core::Formatters
RSpec.describe FailureListFormatter do
include FormatterSupport
it 'produces the expected full output' do
output = run_example_specs_with_formatter('failures')
expect(output).to eq(<<-EOS.gsub(/^\s+\|/, ''))
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/base_text_formatter_spec.rb | Ruby | mit | 93 | main | 12,014 | require 'rspec/core/formatters/base_text_formatter'
RSpec.describe RSpec::Core::Formatters::BaseTextFormatter do
include FormatterSupport
context "when closing the formatter", :isolated_directory => true do
let(:output_to_close) { File.new("./output_to_close", "w") }
let(:formatter) { described_class.new(... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/html_snippet_extractor_spec.rb | Ruby | mit | 93 | main | 1,440 | require 'rspec/core/formatters/html_snippet_extractor'
module RSpec
module Core
module Formatters
RSpec.describe HtmlSnippetExtractor do
it "falls back on a default message when it doesn't understand a line" do
expect(RSpec::Core::Formatters::HtmlSnippetExtractor.new.snippet_for("blech"))... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/fallback_message_formatter_spec.rb | Ruby | mit | 93 | main | 526 | require 'rspec/core/reporter'
require 'rspec/core/formatters/fallback_message_formatter'
module RSpec::Core::Formatters
RSpec.describe FallbackMessageFormatter do
include FormatterSupport
describe "#message" do
it 'writes the message to the output' do
expect {
send_notification :mess... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/exception_presenter_spec.rb | Ruby | mit | 93 | main | 36,360 | require 'pathname'
module RSpec::Core
RSpec.describe Formatters::ExceptionPresenter do
include FormatterSupport
let(:example) { new_example }
let(:presenter) { Formatters::ExceptionPresenter.new(exception, example) }
before do
allow(example.execution_result).to receive(:exception) { exception... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/formatters/progress_formatter_spec.rb | Ruby | mit | 93 | main | 1,716 | require 'rspec/core/formatters/progress_formatter'
RSpec.describe RSpec::Core::Formatters::ProgressFormatter do
include FormatterSupport
before do
send_notification :start, start_notification(2)
end
it 'prints a . on example_passed' do
send_notification :example_passed, example_notification
expec... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/bisect/example_minimizer_spec.rb | Ruby | mit | 93 | main | 5,386 | require 'rspec/core/bisect/example_minimizer'
require 'rspec/core/bisect/server'
require 'rspec/core/bisect/shell_command'
require 'support/fake_bisect_runner'
module RSpec::Core
RSpec.describe Bisect::ExampleMinimizer do
around do |ex|
# so example ids do not have to be escaped
with_env_vars('SHELL'... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/bisect/coordinator_spec.rb | Ruby | mit | 93 | main | 9,586 | require 'rspec/core/bisect/coordinator'
require 'support/fake_bisect_runner'
require 'support/formatter_support'
module RSpec::Core
RSpec.describe Bisect::Coordinator, :simulate_shell_allowing_unquoted_ids do
include FormatterSupport
let(:config) { instance_double(Configuration, :bisect_runner_class => fake... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/bisect/shell_runner_spec.rb | Ruby | mit | 93 | main | 3,477 | require 'rspec/core/bisect/shell_command'
require 'rspec/core/bisect/shell_runner'
require 'rspec/core/bisect/utilities'
module RSpec::Core
RSpec.describe Bisect::ShellRunner do
let(:server) { instance_double("RSpec::Core::Bisect::Server", :drb_port => 1234) }
let(:shell_command) { Bisect::ShellCommand.new(o... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/bisect/shell_command_spec.rb | Ruby | mit | 93 | main | 9,709 | require 'rspec/core/bisect/shell_command'
require 'rspec/core/formatters/bisect_drb_formatter'
module RSpec::Core
RSpec.describe Bisect::ShellCommand do
let(:server) { instance_double("RSpec::Core::Bisect::Server", :drb_port => 1234) }
let(:shell_command) { described_class.new(original_cli_args) }
descr... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/bisect/utilities_spec.rb | Ruby | mit | 93 | main | 2,112 | require 'rspec/core/bisect/utilities'
module RSpec::Core
RSpec.describe Bisect::Notifier do
class ExampleFormatterClass
def foo(notification); end
end
let(:formatter) { instance_spy(ExampleFormatterClass) }
let(:notifier) { Bisect::Notifier.new(formatter) }
it 'publishes events to the wra... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/bisect/server_spec.rb | Ruby | mit | 93 | main | 5,843 | require 'rspec/core/bisect/server'
require 'support/formatter_support'
module RSpec::Core
RSpec.describe Bisect::Server do
RSpec::Matchers.define :have_running_server do
match do |drb|
begin
drb.current_server.alive?
rescue DRb::DRbServerNotFound
false
end
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/resources/inconsistently_ordered_specs.rb | Ruby | mit | 93 | main | 360 | # Deliberately named _specs.rb to avoid being loaded except when specified
RSpec.configure do |c|
c.register_ordering(:shuffled, &:shuffle)
end
RSpec.describe "Group", :order => :shuffled do
10.times do |i|
# rubocop:disable Lint/EmptyBlock
it("passes #{i}") { }
# rubocop:enable Lint/EmptyBlock
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/resources/custom_example_group_runner.rb | Ruby | mit | 93 | main | 215 | module Custom
class ExampleGroupRunner
attr_reader :options, :arg
def initialize(options, arg)
@options, @arg = options, arg
end
def load_files(files)
end
def run
end
end
end |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/resources/formatter_specs.rb | Ruby | mit | 93 | main | 1,443 | # Deliberately named _specs.rb to avoid being loaded except when specified
RSpec.shared_examples_for "shared" do
it "is marked as pending but passes" do
pending
expect(1).to eq(1)
end
end
RSpec.describe "pending spec with no implementation" do
it "is pending"
end
RSpec.describe "pending command with bl... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/resources/bisect/consistently_ordered_2_specs.rb | Ruby | mit | 93 | main | 231 | # Deliberately named _specs.rb to avoid being loaded except when specified
require "rspec/core/resources/bisect/frieren_quote"
RSpec.describe "Order2" do
before { FrierenQuote.change }
it("passes") { expect(1).to eq 1 }
end |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/resources/bisect/consistently_ordered_3_specs.rb | Ruby | mit | 93 | main | 271 | # Deliberately named _specs.rb to avoid being loaded except when specified
require "rspec/core/resources/bisect/frieren_quote"
RSpec.describe "Order3" do
it("fails order-dependency") { expect(FrierenQuote.one).to eq "That is what hero Himmel would have done." }
end |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/resources/bisect/frieren_quote.rb | Ruby | mit | 93 | main | 236 | class FrierenQuote
class << self
def one
@one ||= "That is what hero Himmel would have done."
end
def change
@one = "The greatest enjoyment comes only during the pursuit of magic, you know."
end
end
end |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/rspec/core/configuration/only_failures_support_spec.rb | Ruby | mit | 93 | main | 8,643 | module RSpec::Core
RSpec.describe Configuration, "--only-failures support" do
let(:config) { Configuration.new }
def simulate_persisted_examples(*examples)
config.example_status_persistence_file_path = "examples.txt"
persister = class_double(ExampleStatusPersister).as_stubbed_const
allow(p... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/support/fake_bisect_runner.rb | Ruby | mit | 93 | main | 737 | require 'rspec/core/bisect/utilities'
FakeBisectRunner = Struct.new(:all_ids, :always_failures, :dependent_failures) do
def start(_shell_command, _spec_runner)
yield self
end
def original_results
failures = always_failures | dependent_failures.keys
RSpec::Core::Bisect::ExampleSetDescriptor.new(all_i... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/support/sandboxing.rb | Ruby | mit | 93 | main | 629 | require 'rspec/core/sandbox'
# Because testing RSpec with RSpec tries to modify the same global
# objects, we sandbox every test.
RSpec.configure do |c|
c.around do |ex|
RSpec::Core::Sandbox.sandboxed do |config|
# If there is an example-within-an-example, we want to make sure the inner example
# doe... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/support/config_options_helper.rb | Ruby | mit | 93 | main | 285 | module ConfigOptionsHelper
extend RSpec::SharedContext
around(:each) { |e| without_env_vars('SPEC_OPTS', &e) }
def config_options_object(*args)
RSpec::Core::ConfigurationOptions.new(args)
end
def parse_options(*args)
config_options_object(*args).options
end
end |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/support/spec_files.rb | Ruby | mit | 93 | main | 971 | RSpec.shared_context "spec files" do
def failing_spec_filename
@failing_spec_filename ||= File.expand_path(File.dirname(__FILE__)) + "/_failing_spec.rb"
end
def passing_spec_filename
@passing_spec_filename ||= File.expand_path(File.dirname(__FILE__)) + "/_passing_spec.rb"
end
def create_passing_spec... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/support/helper_methods.rb | Ruby | mit | 93 | main | 633 | module RSpecHelpers
SAFE_LEVEL_THAT_TRIGGERS_SECURITY_ERRORS = 1
def relative_path(path)
RSpec::Core::Metadata.relative_path(path)
end
def ignoring_warnings
original = $VERBOSE
$VERBOSE = nil
result = yield
$VERBOSE = original
result
end
# Intended for use with indented heredocs.
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/support/isolated_home_directory.rb | Ruby | mit | 93 | main | 1,076 | require 'tmpdir'
require 'fileutils'
require 'pathname'
RSpec.shared_context "isolated home directory" do
around do |ex|
Dir.mktmpdir do |tmp_dir|
# If user running this test suite has a custom $XDG_CONFIG_HOME, also
# clear that out when changing $HOME so tests don't touch the user's real
# co... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/support/shared_example_groups.rb | Ruby | mit | 93 | main | 1,343 | RSpec.shared_examples_for "metadata hash builder" do
let(:hash) { metadata_hash(:foo, :bar, :bazz => 23) }
it 'treats symbols as metadata keys with a true value' do
expect(hash[:foo]).to be(true)
expect(hash[:bar]).to be(true)
end
it 'still processes hash values normally' do
expect(hash[:bazz]).to... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/support/runner_support.rb | Ruby | mit | 93 | main | 405 | module RSpec::Core
RSpec.shared_context "Runner support" do
let(:out) { StringIO.new }
let(:err) { StringIO.new }
let(:config) { RSpec.configuration }
let(:world) { RSpec.world }
def build_runner(*args)
Runner.new(build_config_options(*args))
end
de... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/support/aruba_support.rb | Ruby | mit | 93 | main | 1,671 | require 'support/helper_methods'
module ArubaLoader
extend RSpec::Support::WithIsolatedStdErr
with_isolated_stderr do
require 'aruba/api'
end
end
RSpec.shared_context "aruba support" do
include Aruba::Api
include RSpecHelpers
let(:stderr) { StringIO.new }
let(:stdout) { StringIO.new }
before { ... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/support/matchers.rb | Ruby | mit | 93 | main | 3,950 | RSpec::Matchers.define :map_specs do |specs|
match do |autotest|
@specs = specs
@autotest = prepare(autotest)
autotest.test_files_for(@file) == specs
end
chain :to do |file|
@file = file
end
failure_message do
"expected #{@autotest.class} to map #{@specs.inspect} to #{@file.inspect}\ngot... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/support/formatter_support.rb | Ruby | mit | 93 | main | 10,727 | module FormatterSupport
def run_example_specs_with_formatter(formatter_option, options={}, &block)
output = run_rspec_with_formatter(formatter_option, options.merge(:extra_options => ["spec/rspec/core/resources/formatter_specs.rb"]), &block)
return output unless options.fetch(:normalize_output, true)
out... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/support/error_highlight.rb | Ruby | mit | 93 | main | 431 | if defined?(ErrorHighlight)
class DummyErrorHighlightFormatter
def self.message_for(_spot)
""
end
end
RSpec.configure do |c|
c.around(:disable_error_highlight => true) do |ex|
begin
old_formatter = ErrorHighlight.formatter
ErrorHighlight.formatter = DummyErrorHighlightForm... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/support/fake_libs/open3.rb | Ruby | mit | 93 | main | 365 | unless caller.any? { |line| line.include?("rspec/core/bisect/shell_runner.rb") }
raise "open3 loaded from unexpected file. " \
"It is allowed to be loaded by the Bisect::ShellRunner " \
"because that is not loaded in the same process as end-user code, " \
"and we generally don't want open3 loa... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/integration/bisect_spec.rb | Ruby | mit | 93 | main | 3,893 | RSpec::Support.require_rspec_core "formatters/bisect_progress_formatter"
module RSpec::Core
RSpec.describe "Bisect", :slow, :simulate_shell_allowing_unquoted_ids do
include FormatterSupport
def bisect(cli_args, expected_status=nil)
options = ConfigurationOptions.new(cli_args)
expect {
s... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/integration/order_spec.rb | Ruby | mit | 93 | main | 7,958 | require 'support/aruba_support'
RSpec.describe 'command line' do
include_context "aruba support"
before(:all) { setup_aruba }
before :all do
write_file 'spec/simple_spec.rb', "
RSpec.describe 'group 1' do
specify('group 1 example 1') {}
specify('group 1 example 2') {}
specify(... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/integration/failed_line_detection_spec.rb | Ruby | mit | 93 | main | 4,263 | require 'support/aruba_support'
RSpec.describe 'Failed line detection' do
include_context "aruba support"
it "finds the source of a failure in a spec file that is defined at the current directory instead of in the normal `spec` subdir" do
write_file "the_spec.rb", "
RSpec.describe do
it 'fails v... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/integration/fail_if_no_examples_spec.rb | Ruby | mit | 93 | main | 3,135 | require 'support/aruba_support'
RSpec.describe 'Fail if no examples' do
include_context "aruba support"
context 'when 1 passing example' do
def passing_example(fail_if_no_examples)
"
RSpec.configure { |c| c.fail_if_no_examples = #{fail_if_no_examples} }
RSpec.describe 'something' do
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/integration/location_rerun_spec.rb | Ruby | mit | 93 | main | 5,325 | require 'support/aruba_support'
RSpec.describe 'Failed spec rerun location' do
include RSpecHelpers
include_context "aruba support"
before do
# Setup some shared examples and call them in a separate file
# from where they are called to demonstrate how nested example ids work
write_file_formatted "s... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/integration/bisect_runners_spec.rb | Ruby | mit | 93 | main | 3,622 | require 'support/aruba_support'
require 'rspec/core/bisect/shell_command'
require 'rspec/core/bisect/shell_runner'
require 'rspec/core/bisect/fork_runner'
module RSpec::Core
RSpec.shared_examples_for "a bisect runner" do
include_context "aruba support"
let(:shell_command) { Bisect::ShellCommand.new([]) }
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/integration/suite_hooks_errors_spec.rb | Ruby | mit | 93 | main | 4,136 | require 'support/aruba_support'
require 'support/formatter_support'
RSpec.describe 'Suite hook errors' do
include_context "aruba support"
include FormatterSupport
let(:failure_exit_code) { rand(97) + 2 } # 2..99
let(:error_exit_code) { failure_exit_code + 2 } # 4..101
if RSpec::Support::Ruby.jruby? && RSpe... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/integration/filtering_spec.rb | Ruby | mit | 93 | main | 9,647 | require 'support/aruba_support'
RSpec.describe 'Filtering' do
include_context "aruba support"
it 'prints a rerun command for shared examples in external files that works to rerun' do
write_file "spec/support/shared_examples.rb", "
RSpec.shared_examples 'with a failing example' do
example { expec... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/integration/spec_file_load_errors_spec.rb | Ruby | mit | 93 | main | 8,506 | require 'support/aruba_support'
require 'support/formatter_support'
RSpec.describe 'Spec file load errors' do
include_context "aruba support"
include FormatterSupport
let(:failure_exit_code) { rand(97) + 2 } # 2..99
let(:error_exit_code) { failure_exit_code + 1 } # 3..100
if RSpec::Support::Ruby.jruby?
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/integration/pending_failure_output_spec.rb | Ruby | mit | 93 | main | 2,245 | require 'support/aruba_support'
RSpec.describe 'Pending failure output spec' do
include_context "aruba support"
it 'by default outputs backtrace and details' do
write_file 'spec/example_spec.rb', <<-RUBY
RSpec.describe "something" do
pending "will never happen again" do
expect(Time.now.year)... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/integration/output_stream_spec.rb | Ruby | mit | 93 | main | 1,856 | require 'support/aruba_support'
RSpec.describe 'Output stream' do
include_context 'aruba support'
context 'when a formatter set in a configure block' do
it 'writes to the right output stream' do
write_file_formatted 'spec/example_spec.rb', <<-SPEC
RSpec.configure do |c|
c.formatter = :... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/spec/integration/persistence_failures_spec.rb | Ruby | mit | 93 | main | 2,310 | require 'support/aruba_support'
RSpec.describe 'Persistence failures' do
include_context "aruba support"
context "when `config.example_status_persistence_file_path` is configured" do
context "to an invalid file path (e.g. spec/spec_helper.rb/examples.txt)" do
before do
write_file_formatted "spec... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core.rb | Ruby | mit | 93 | main | 5,948 | # rubocop:disable Style/GlobalVars
$_rspec_core_load_started_at = Time.now
# rubocop:enable Style/GlobalVars
require "rspec/support"
RSpec::Support.require_rspec_support "caller_filter"
RSpec::Support.define_optimized_require_for_rspec(:core) { |f| require_relative f }
%w[
version
warnings
set
filter_manage... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/shell_escape.rb | Ruby | mit | 93 | main | 1,609 | RSpec::Support.require_rspec_support 'ruby_features'
module RSpec
module Core
# @private
# Deals with the fact that `shellwords` only works on POSIX systems.
module ShellEscape
module_function
def quote(argument)
"'#{argument.to_s.gsub("'", "\\\\'")}'"
end
if RSpec::Supp... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/example_group.rb | Ruby | mit | 93 | main | 31,427 | 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
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/shared_example_group.rb | Ruby | mit | 93 | main | 7,604 | RSpec::Support.require_rspec_support "with_keywords_when_needed"
module RSpec
module Core
# Represents some functionality that is shared with multiple example groups.
# The functionality is defined by the provided block, which is lazily
# eval'd when the `SharedExampleGroupModule` instance is included in... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/dsl.rb | Ruby | mit | 93 | main | 1,543 | module RSpec
module Core
# DSL defines methods to group examples, most notably `describe`,
# and exposes them as class methods of {RSpec}.
#
# By default the methods `describe`, `context` and `example_group`
# are exposed. These methods define a named context for one or
# more examples. The gi... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/configuration_options.rb | Ruby | mit | 93 | main | 7,025 | 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
... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/did_you_mean.rb | Ruby | mit | 93 | main | 1,489 | module RSpec
module Core
# @private
# Wrapper around Ruby's `DidYouMean::SpellChecker` when available to provide file name suggestions.
class DidYouMean
attr_reader :relative_file_name
def initialize(relative_file_name)
@relative_file_name = relative_file_name
end
if defi... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/example_status_persister.rb | Ruby | mit | 93 | main | 7,358 | 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... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/memoized_helpers.rb | Ruby | mit | 93 | main | 16,653 | 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... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/configuration.rb | Ruby | mit | 93 | main | 80,478 | 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"
RSpec::Support.require_rspec_support 'ruby_features'
module RSpec
module Core
# rubocop:... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/option_parser.rb | Ruby | mit | 93 | main | 12,323 | # 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... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/world.rb | Ruby | mit | 93 | main | 8,026 | module RSpec
module Core
# @api private
#
# Internal container for global non-configuration data.
class World
# @private
attr_reader :example_groups, :filtered_examples, :example_group_counts_by_spec_file
# Used internally to determine what to do when a SIGINT is received.
att... |
github | rspec/rspec | https://github.com/rspec/rspec | rspec-core/lib/rspec/core/backtrace_formatter.rb | Ruby | mit | 93 | main | 2,015 | 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.