diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index d3a58b2083..d0ab4dfa04 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,4 +1,4 @@ -# This file was generated on 2020-12-25T18:48:30+00:00 from the rspec-dev repo. +# This file was generated on 2023-04-16T20:53:21+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. github: [JonRowe, benoittgt] diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..fa6adbf09f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +# This file was generated on 2023-12-25T16:05:21+00:00 from the rspec-dev repo. +# DO NOT modify it by hand as your changes will get lost the next time it is generated. + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e63f485908..f2d7d9308e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -# This file was generated on 2022-09-08T12:41:59+01:00 from the rspec-dev repo. +# This file was generated on 2023-12-25T16:05:21+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. name: RSpec CI @@ -13,16 +13,19 @@ on: - '*' permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true env: RSPEC_CI: true # This tells rspec-rails what branch to run in ci - RSPEC_VERSION: '= 3.12.0.pre' + RSPEC_VERSION: '~> 3.13.0' jobs: rubocop: name: Rubocop runs-on: 'ubuntu-20.04' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: '3.0' @@ -38,6 +41,8 @@ jobs: strategy: matrix: ruby: + - '3.3' + - '3.2' - '3.1' - '3.0' - 2.7 @@ -46,7 +51,6 @@ jobs: - 2.4 - 2.3 - 2.2 - - 2.1.9 env: - DIFF_LCS_VERSION: "> 1.4.3" @@ -57,11 +61,6 @@ jobs: - ruby: jruby-9.2.13.0 env: JRUBY_OPTS: "--dev" - - ruby: jruby-9.1.17.0 - bundler: 1 - os: ubuntu-18.04 - env: - JRUBY_OPTS: "--dev" - ruby: 2.7 name_extra: "with diff-lcs 1.3" env: @@ -74,7 +73,7 @@ jobs: continue-on-error: ${{ matrix.allow_failure || endsWith(matrix.ruby, 'head') }} env: ${{ matrix.env }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: bundler: ${{ matrix.bundler || '2.2.22' }} @@ -95,26 +94,32 @@ jobs: fail-fast: false matrix: container: + - version: "2.1.9" + tag: ghcr.io/rspec/docker-ci:2.1.9 + post: git config --global --add safe.directory `pwd` - version: "2.0" - tag: rspec/ci:2.0.0 + tag: ghcr.io/rspec/docker-ci:2.0.0 - version: "1.9.3" - tag: rspec/ci:1.9.3 + tag: ghcr.io/rspec/docker-ci:1.9.3 - version: "1.9.2" - tag: rspec/ci:1.9.2 + tag: ghcr.io/rspec/docker-ci:1.9.2 options: "--add-host rubygems.org:151.101.129.227 --add-host api.rubygems.org:151.101.129.227" - version: "1.8.7" - tag: rspec/ci:1.8.7 + tag: ghcr.io/rspec/docker-ci:1.8.7 options: "--add-host rubygems.org:151.101.129.227 --add-host api.rubygems.org:151.101.129.227" - version: "REE" - tag: rspec/ci:ree + tag: ghcr.io/rspec/docker-ci:ree options: "--add-host rubygems.org:151.101.129.227 --add-host api.rubygems.org:151.101.129.227" - version: "JRuby 1.7" - tag: rspec/ci:jruby-1.7 + tag: ghcr.io/rspec/docker-ci:jruby-1.7 - version: "JRuby 1.7 1.8 mode" - tag: rspec/ci:jruby-1.7 + tag: ghcr.io/rspec/docker-ci:jruby-1.7 jruby_opts: '--dev --1.8' pre: gem uninstall jruby-openssl options: "--add-host rubygems.org:151.101.129.227 --add-host api.rubygems.org:151.101.129.227" + - version: "JRuby 9.1.17.0" + tag: ghcr.io/rspec/docker-ci:jruby-9.1.17.0 + options: "--add-host rubygems.org:151.101.129.227 --add-host api.rubygems.org:151.101.129.227" env: LEGACY_CI: true JRUBY_OPTS: ${{ matrix.container.jruby_opts || '--dev' }} @@ -122,6 +127,7 @@ jobs: - uses: actions/checkout@v3 - run: ${{ matrix.container.pre }} - run: script/legacy_setup.sh + - run: ${{ matrix.container.post }} - run: bundle exec bin/rspec - run: bundle exec script/cucumber.sh @@ -137,14 +143,13 @@ jobs: - 2.4 - 2.3 - 2.2 - - 2.1.9 fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: bundler: '2.2.22' ruby-version: ${{ matrix.ruby }} bundler-cache: true - - run: cinst ansicon + - run: choco install ansicon - run: bundle exec rspec --backtrace diff --git a/.rubocop.yml b/.rubocop.yml index fa3b63edc3..07e58baa6b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -50,7 +50,7 @@ Lint/LiteralInInterpolation: Lint/NonLocalExitFromIterator: Enabled: false -# We don't care about single vs double qoutes. +# We don't care about single vs double quotes. Style/StringLiteralsInInterpolation: Enabled: false diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 1f77f17e6b..797c21a3af 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2022-09-08T12:41:59+01:00 from the rspec-dev repo. +# This file was generated on 2023-12-25T16:05:21+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/BUILD_DETAIL.md b/BUILD_DETAIL.md index dfda42849f..d09f650646 100644 --- a/BUILD_DETAIL.md +++ b/BUILD_DETAIL.md @@ -1,5 +1,5 @@ @@ -50,7 +50,7 @@ project-specific threshold, the build will fail. ## Cukes RSpec uses [cucumber](https://cucumber.io/) for both acceptance testing -and [documentation](https://relishapp.com/rspec). Since we publish our cukes +and [documentation](https://rspec.info/documentation). Since we publish our cukes as documentation, please limit new cucumber scenarios to user-facing examples that help demonstrate usage. Any tests that exist purely to prevent regressions should be written as specs, even if they are written in an acceptance style. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index b6be7666ce..b5bfa60635 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,5 +1,5 @@ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index feb34b3613..888701eaf9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ @@ -13,7 +13,7 @@ If you'd like to help make RSpec better, here are some ways you can contribute: - by running RSpec HEAD to help us catch bugs before new releases - by [reporting bugs you encounter](https://github.com/rspec/rspec-core/issues/new) with [report template](#report-template) - by [suggesting new features](https://github.com/rspec/rspec-core/issues/new) - - by improving RSpec's [Relish](https://relishapp.com/rspec) or [API](https://rspec.info/documentation/) documentation + - by improving RSpec's Feature or API [documentation](https://rspec.info/documentation/) - by improving [RSpec's website](https://rspec.info/) ([source](https://github.com/rspec/rspec.github.io)) - by taking part in [feature and issue discussions](https://github.com/rspec/rspec-core/issues) - by adding a failing test for reproducible [reported bugs](https://github.com/rspec/rspec-core/issues) diff --git a/Changelog.md b/Changelog.md index 69c725a3f2..50bfd0d27f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,50 @@ ### Development -[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.11.0...main) +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.3...main) + +### 3.13.0 / 2024-02-04 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.3...v3.13.0) + +Enhancements: + +* Support the `--backtrace` flag when using the JSON formatter. (Matt Larraz, #2980) +* Ignore commented out lines in CLI config files (e.g. `.rspec`). (Junichi Ito, #2984) +* Add `pending_failure_output` config option to allow skipping backtraces or + muting pending specs output. (Phil Pirozhkov, #2957) +* Process `--dry-run` before configuration flags that read files so that introspecting + it returns the correct value. (Xenor Chang, #3008) +* Allow specifying custom ordering strategies via `--order`. (Jon Rowe, #3025) +* Use the improved `syntax_suggest` output for `SyntaxError` when available. + (Richard Schneeman, #3015, #3026) +* Add config option (`RSpec::Core::Configuration#full_cause_backtrace`) to print the + entire backtrace of an exception cause. (David Taylor, #3046) + +### 3.12.3 / 2024-02-04 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.2...v3.12.3) + +Bug fixes: + +* Use `__send__` in output wrapper to avoid issues with IO objects that implement `send` + like `Socket`. (Richard Platel, #3045) + +### 3.12.2 / 2023-04-18 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.1...v3.12.2) + +Bug fixes: + +* Remove link to outdated documentation in generated output. (Jon Rowe, #3035) + +### 3.12.1 / 2023-02-03 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.0...v3.12.1) + +Bug fixes: + +* Prevent multiple calls to `extra_failure_lines` from adding additional whitespace + around them when the lines already contain whitespace. (Jon Rowe, #3006) + +### 3.12.0 / 2022-10-26 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.11.0...v3.12.0) + +* No changes, released to support other gems. ### 3.11.0 / 2022-02-09 [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.10.2...v3.11.0) diff --git a/DEV-README.md b/DEV-README.md index 36b80cc0b1..3527187834 100644 --- a/DEV-README.md +++ b/DEV-README.md @@ -23,6 +23,6 @@ Or ... ## Customize the dev environment The Gemfile includes the gems you'll need to be able to run specs. If you want -to customize your dev enviroment with additional tools like guard or +to customize your dev environment with additional tools like guard or ruby-debug, add any additional gem declarations to Gemfile-custom (see Gemfile-custom.sample for some examples). diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 092d8fd548..515c72de41 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -1,5 +1,5 @@ diff --git a/Gemfile b/Gemfile index 521807c5d1..085b940207 100644 --- a/Gemfile +++ b/Gemfile @@ -96,8 +96,13 @@ end if RUBY_VERSION < '2.0.0' gem 'cucumber', "<= 1.3.22" +elsif !ENV['DIFF_LCS_VERSION'].to_s.empty? && ENV['DIFF_LCS_VERSION'].scan(/\d\.\d/).first.to_f < 1.5 + # Older version of diff-lcs cause a downstream error with cucumber and modern rails + gem "activesupport", "< 7" end gem 'contracts', '< 0.16' if RUBY_VERSION < '1.9.0' +gem 'drb' if RUBY_VERSION >= '3.4' + eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom') diff --git a/Gemfile-custom.sample b/Gemfile-custom.sample index 8532039ad6..186a929888 100644 --- a/Gemfile-custom.sample +++ b/Gemfile-custom.sample @@ -1,6 +1,5 @@ group :development do gem 'interactive_rspec' - gem 'relish', '~> 0.6.0' gem 'guard-rspec', '~> 1.2.1' gem 'growl', '1.0.3' gem 'spork', '0.9.0' diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 98ecf0bbf5..f8f091e7ac 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,3 +1,8 @@ + ### Subject of the issue diff --git a/Rakefile b/Rakefile index 0f30480338..782012af6a 100644 --- a/Rakefile +++ b/Rakefile @@ -43,36 +43,6 @@ task :rdoc do sh "yardoc" end -with_changelog_in_features = lambda do |&block| - begin - sh "cp Changelog.md features/" - block.call - ensure - sh "rm features/Changelog.md" - end -end - -desc "Push docs/cukes to relishapp using the relish-client-gem" -task :relish, :version do |_t, args| - raise "rake relish[VERSION]" unless args[:version] - - with_changelog_in_features.call do - if `relish versions rspec/rspec-core`.split.map(&:strip).include? args[:version] - puts "Version #{args[:version]} already exists" - else - sh "relish versions:add rspec/rspec-core:#{args[:version]}" - end - sh "relish push rspec/rspec-core:#{args[:version]}" - end -end - -desc "Push to relish staging environment" -task :relish_staging do - with_changelog_in_features.call do - sh "relish push rspec-staging/rspec-core" - end -end - task :default => [:spec, :cucumber, :rubocop] task :verify_private_key_present do diff --git a/benchmarks/allocations/1000_groups_1_example.rb b/benchmarks/allocations/1000_groups_1_example.rb index 756a2e0599..e111bf7705 100644 --- a/benchmarks/allocations/1000_groups_1_example.rb +++ b/benchmarks/allocations/1000_groups_1_example.rb @@ -100,7 +100,7 @@ - 10K arrays - 10K sets - 5K FilterableItemRepository - - 5K HookCollecion + - 5K HookCollection class_plus count --------------------------------------- ----- diff --git a/benchmarks/capture_block_vs_yield.rb b/benchmarks/capture_block_vs_yield.rb index 2705527678..4f25ba305b 100644 --- a/benchmarks/capture_block_vs_yield.rb +++ b/benchmarks/capture_block_vs_yield.rb @@ -84,7 +84,7 @@ def call_block_n_times(n, &block) a high constant cost, taking about 5x longer than a single `yield` (even if the block is never used!). -However, fowarding a captured block can be faster than using `yield` +However, forwarding a captured block can be faster than using `yield` if the block is used many times (the breakeven point is at about 20-25 invocations), so it appears that he per-invocation cost of `yield` is higher than that of a captured-and-forwarded block. diff --git a/benchmarks/flat_map_vs_inject.rb b/benchmarks/flat_map_vs_inject.rb index 6a99d190f1..042e11d655 100644 --- a/benchmarks/flat_map_vs_inject.rb +++ b/benchmarks/flat_map_vs_inject.rb @@ -37,7 +37,7 @@ def flat_map_using_block(array, &block) Surprisingly, `flat_map(&block)` appears to be faster than `flat_map { yield }` in spite of the fact that our array here is smaller than the break-even point of 20-25 measured in the -`capture_block_vs_yield.rb` benchmark. In fact, the forwaded-block +`capture_block_vs_yield.rb` benchmark. In fact, the forwarded-block version remains faster in my benchmarks here no matter how small I shrink the `words` array. I'm not sure why! diff --git a/features/.nav b/features/.nav index d6320e624c..009cf30c66 100644 --- a/features/.nav +++ b/features/.nav @@ -1,11 +1,8 @@ -- Changelog.md -- Autotest.md - example_groups: - basic_structure.feature - shared_examples.feature - shared_context.feature - command_line: - - configure.feature - example_name_option.feature - format_option.feature - tag.feature @@ -13,7 +10,7 @@ - exit_status.feature - order.md (`--order` option) - rake_task.feature -- pending: +- pending_and_skipped_examples: - pending_examples.feature - hooks: - before_and_after_hooks.feature @@ -23,8 +20,7 @@ - subject: - implicit_subject.feature - explicit_subject.feature - - attribute_of_subject.feature - - implicit_receiver.feature + - one_liner_syntax.feature - helper_methods: - let.feature - arbitrary_methods.feature @@ -38,7 +34,6 @@ - exclusion_filters.feature - if_and_unless.feature - filter_run_when_matching.feature - - run_all_when_everything_filtered.feature - configuration: - read_options_from_file.feature - color.feature @@ -49,7 +44,7 @@ - default_path.feature - expectation_framework_integration: - configure_expectation_framework.feature - - failure_aggregation.feature + - aggregating_failures.feature - mock_framework_integration: - use_rspec.feature - use_flexmock.feature @@ -57,7 +52,6 @@ - use_rr.feature - use_any_framework.feature - formatters: - - text_formatter.feature - configurable_colors.feature - json_formatter.feature - custom_formatter.feature diff --git a/features/README.md b/features/README.md index 78ca620993..e0db04aab7 100644 --- a/features/README.md +++ b/features/README.md @@ -1,12 +1,16 @@ -rspec-core provides the structure for RSpec code examples: - - RSpec.describe Account do - it "has a balance of zero when first opened" do - # example code goes here - for more on the - # code inside the examples, see rspec-expectations - # and rspec-mocks - end - end +# RSpec Core + +`rspec-core` provides the structure for RSpec code examples: + +```ruby +RSpec.describe Account do + it "has a balance of zero when first opened" do + # example code goes here - for more on the + # code inside the examples, see rspec-expectations + # and rspec-mocks + end +end +``` ## Issues diff --git a/features/command_line/README.md b/features/command_line/README.md index df3b998f1d..802f20a04d 100644 --- a/features/command_line/README.md +++ b/features/command_line/README.md @@ -1,3 +1,5 @@ +# Command line options + The `rspec` command comes with several options you can use to customize RSpec's behavior, including output formats, filtering examples, etc. diff --git a/features/command_line/example_matches_name_option.feature b/features/command_line/example_matches_name_option.feature index de80b3cf30..badf54a722 100644 --- a/features/command_line/example_matches_name_option.feature +++ b/features/command_line/example_matches_name_option.feature @@ -103,7 +103,7 @@ Feature: `--example-matches` option | nested group second example in nested group | # https://regex101.com/r/RABd8Q/2 - Scenario: Match only matching regex with word boundarries + Scenario: Match only matching regex with word boundaries When I run `rspec . --example-matches "nested[^_]" --format d` Then the examples should all pass And the output should contain all of these: diff --git a/features/command_line/line_number_appended_to_path.feature b/features/command_line/line_number_appended_to_path.feature index 8ba778a143..8c8468244a 100644 --- a/features/command_line/line_number_appended_to_path.feature +++ b/features/command_line/line_number_appended_to_path.feature @@ -1,4 +1,4 @@ -Feature: line number appended to file path +Feature: `:` (line number appended to file path) To run one or more examples or groups, you can append the line number to the path, e.g. diff --git a/features/command_line/only_failures.feature b/features/command_line/only_failures.feature index e516c0fe83..87b7bb4c51 100644 --- a/features/command_line/only_failures.feature +++ b/features/command_line/only_failures.feature @@ -1,4 +1,4 @@ -Feature: Only Failures +Feature: Using the `--only-failures` option The `--only-failures` option filters what examples are run so that only those that failed the last time they ran are executed. To use this option, you first have to configure `config.example_status_persistence_file_path`, which RSpec will use to store the status of each example the last time it ran. diff --git a/features/command_line/order.feature b/features/command_line/order.feature new file mode 100644 index 0000000000..6513bcbb51 --- /dev/null +++ b/features/command_line/order.feature @@ -0,0 +1,119 @@ +Feature: Using the `--order` option + +Use the `--order` option to tell RSpec how to order the files, groups, and +examples. The available ordering schemes are `defined` and `rand`. + +`defined` is the default, which executes groups and examples in the order they +are defined as the spec files are loaded, with the caveat that each group +runs its examples before running its nested example groups, even if the +nested groups are defined before the examples. + +Use `rand` to randomize the order of groups and examples within the groups. +Nested groups are always run from top-level to bottom-level in order to avoid +executing `before(:context)` and `after(:context)` hooks more than once, but the +order of groups at each level is randomized. + +With `rand` you can also specify a seed. + +Use `recently-modified` to run the most recently modified files first. You can +combine it with `--only-failures` to find the most recent failing specs. Note +that `recently-modified` and `rand` are mutually exclusive. + +** Example usage ** + +The `defined` option is only necessary when you have `--order rand` stored in a +config file (e.g. `.rspec`) and you want to override it from the command line. + +
--order defined
+--order rand
+--order rand:123
+--seed 123 # same as --order rand:123
+--order recently-modified
+
+ +Scenario: Default order is `defined` + Given a file named "example_spec.rb" with: + """ruby + RSpec.describe "something" do + it "does something" do + end + + it "in order" do + end + end + """ + When I run `rspec example_spec.rb --format documentation` + Then the output should contain: + """ + something + does something + in order + """ + +Scenario: Order can be psuedo randomised (seed used here to fix the ordering for tests) + Given a file named "example_spec.rb" with: + """ruby + RSpec.describe "something" do + it "does something" do + end + + it "in order" do + end + end + """ + When I run `rspec example_spec.rb --format documentation --order rand:123` + Then the output should contain: + """ + something + in order + does something + """ + +Scenario: Configure custom ordering + Given a file named "example_spec.rb" with: + """ruby + RSpec.configure do |config| + config.register_ordering(:reverse) do |examples| + examples.reverse + end + config.order = :reverse + end + + RSpec.describe "something" do + it "does something" do + end + + it "in order" do + end + end + """ + When I run `rspec example_spec.rb --format documentation --order reverse` + Then the output should contain: + """ + something + in order + does something + """ + +Scenario: Override order to `defined` when another order is set + Given a file named "example_spec.rb" with: + """ruby + RSpec.configure do |config| + config.order = :random + config.seed = 123 + end + RSpec.describe "something" do + it "does something" do + end + + it "in order" do + end + end + """ + When I run `rspec example_spec.rb --format documentation --order defined` + Then the output should contain: + """ + something + does something + in order + """ diff --git a/features/command_line/order.md b/features/command_line/order.md deleted file mode 100644 index c5bc0f15f0..0000000000 --- a/features/command_line/order.md +++ /dev/null @@ -1,30 +0,0 @@ -Use the `--order` option to tell RSpec how to order the files, groups, and -examples. The available ordering schemes are `defined` and `rand`. - -`defined` is the default, which executes groups and examples in the order they -are defined as the spec files are loaded, with the caveat that each group -runs its examples before running its nested example groups, even if the -nested groups are defined before the examples. - -Use `rand` to randomize the order of groups and examples within the groups. -Nested groups are always run from top-level to bottom-level in order to avoid -executing `before(:context)` and `after(:context)` hooks more than once, but the -order of groups at each level is randomized. - -With `rand` you can also specify a seed. - -Use `recently-modified` to run the most recently modified files first. You can -combine it with `--only-failures` to find the most recent failing specs. Note -that `recently-modified` and `rand` are mutually exclusive. - -## Example usage - -The `defined` option is only necessary when you have `--order rand` stored in a -config file (e.g. `.rspec`) and you want to override it from the command line. - -
--order defined
---order rand
---order rand:123
---seed 123 # same as --order rand:123
---order recently-modified
-
diff --git a/features/command_line/rake_task.feature b/features/command_line/rake_task.feature index 4bb61175d3..edfa777c4d 100644 --- a/features/command_line/rake_task.feature +++ b/features/command_line/rake_task.feature @@ -1,4 +1,4 @@ -Feature: rake task +Feature: Creating a rake task RSpec ships with a rake task with a number of useful options. diff --git a/features/command_line/require_option.feature b/features/command_line/require_option.feature index 29b8c7e964..40b9e698ec 100644 --- a/features/command_line/require_option.feature +++ b/features/command_line/require_option.feature @@ -34,7 +34,7 @@ Feature: `--require` option """ And a file named "spec/example_spec.rb" with: """ruby - RSpec.describe "an embarassing situation" do + RSpec.describe "an embarrassing situation" do it "happens to everyone" do end end diff --git a/features/command_line/ruby.feature b/features/command_line/ruby.feature index d0e50ba006..4cf27b8faa 100644 --- a/features/command_line/ruby.feature +++ b/features/command_line/ruby.feature @@ -1,4 +1,4 @@ -Feature: run with `ruby` command +Feature: Run with `ruby` command You can use the `ruby` command to run specs. You just need to require `rspec/autorun`. diff --git a/features/configuration/custom_settings.feature b/features/configuration/custom_settings.feature index e4f779ac59..be6f34c63f 100644 --- a/features/configuration/custom_settings.feature +++ b/features/configuration/custom_settings.feature @@ -1,4 +1,4 @@ -Feature: custom settings +Feature: Custom settings Extensions like rspec-rails can add their own configuration settings. @@ -66,7 +66,7 @@ Feature: custom settings end RSpec.describe "custom setting" do - it "returns the value set in the last cofigure block to get eval'd" do + it "returns the value set in the last configure block to get eval'd" do expect(RSpec.configuration.custom_setting).to be(true) end diff --git a/features/configuration/deprecation_stream.feature b/features/configuration/deprecation_stream.feature index 187651e285..b59684b087 100644 --- a/features/configuration/deprecation_stream.feature +++ b/features/configuration/deprecation_stream.feature @@ -73,7 +73,7 @@ Feature: Custom deprecation stream But the output should contain "1 deprecation logged to deprecations.txt" And the file "deprecations.txt" should contain "Foo#bar is deprecated" - Scenario: configure using the CLI `--deprecation-out` option + Scenario: Configure using the CLI `--deprecation-out` option Given a file named "spec/example_spec.rb" with: """ruby require "foo" diff --git a/features/configuration/error_exit_code.feature b/features/configuration/error_exit_code.feature index f64bcdef90..a9e3ae7545 100644 --- a/features/configuration/error_exit_code.feature +++ b/features/configuration/error_exit_code.feature @@ -1,4 +1,4 @@ -Feature: error exit code +Feature: Setting an error exit code Use the `error_exit_code` option to set a custom exit code when RSpec fails outside an example. diff --git a/features/configuration/exclude_pattern.feature b/features/configuration/exclude_pattern.feature index 90af092346..e8f1011daf 100644 --- a/features/configuration/exclude_pattern.feature +++ b/features/configuration/exclude_pattern.feature @@ -1,4 +1,4 @@ -Feature: exclude_pattern +Feature: Using the `--exclude_pattern` option Use the `--exclude-pattern` option to tell RSpec to skip looking for specs in files that match the pattern specified. diff --git a/features/configuration/fail_fast.feature b/features/configuration/fail_fast.feature index 3214dce78d..33b5cf8142 100644 --- a/features/configuration/fail_fast.feature +++ b/features/configuration/fail_fast.feature @@ -1,4 +1,4 @@ -Feature: fail fast +Feature: Setting the `fail_fast` option Use the `fail_fast` option to tell RSpec to abort the run after N failures: diff --git a/features/configuration/fail_if_no_examples.feature b/features/configuration/fail_if_no_examples.feature index e6d25f5d1f..47c54d58fb 100644 --- a/features/configuration/fail_if_no_examples.feature +++ b/features/configuration/fail_if_no_examples.feature @@ -1,4 +1,4 @@ -Feature: fail if no examples +Feature: Setting the `fail_if_no_examples` option Use the `fail_if_no_examples` option to make RSpec exit with a failure status (by default 1) if there are no examples. Using this option, it is recommended to add a `--require spec_helper` option to `.rspec` file to ensure the `fail_if_no_examples` option is set even if no spec files are loaded. diff --git a/features/configuration/failure_exit_code.feature b/features/configuration/failure_exit_code.feature index d71f203576..8817dfb099 100644 --- a/features/configuration/failure_exit_code.feature +++ b/features/configuration/failure_exit_code.feature @@ -1,4 +1,4 @@ -Feature: failure exit code +Feature: Setting a failure exit code Use the `failure_exit_code` option to set a custom exit code when RSpec fails. diff --git a/features/configuration/order_and_seed.feature b/features/configuration/order_and_seed.feature index c1efa8ec9c..070b861ccc 100644 --- a/features/configuration/order_and_seed.feature +++ b/features/configuration/order_and_seed.feature @@ -1,4 +1,4 @@ -Feature: set the order and/or seed +Feature: Setting the `--order` and/or `--seed` You can set the order to run specs and specify a seed if you are running the specs using the 'random' ordering. See [the documentation on the `--order` diff --git a/features/configuration/pattern.feature b/features/configuration/pattern.feature index 7b922eae48..5ffa076a4c 100644 --- a/features/configuration/pattern.feature +++ b/features/configuration/pattern.feature @@ -1,4 +1,4 @@ -Feature: pattern +Feature: Using the `--pattern` option Use the `pattern` option to configure RSpec to look for specs in files that match a pattern instead of the default `"**/*_spec.rb"`. diff --git a/features/configuration/pending_failure_output.feature b/features/configuration/pending_failure_output.feature new file mode 100644 index 0000000000..614859b321 --- /dev/null +++ b/features/configuration/pending_failure_output.feature @@ -0,0 +1,58 @@ +Feature: Configuring pending failure output + + Configure the format of pending examples output with an option (defaults to `:full`): + + ```ruby + RSpec.configure do |c| + c.pending_failure_output = :no_backtrace + end + ``` + + Allowed options are `:full`, `:no_backtrace` and `:skip`. + + Background: + Given a file named "spec/example_spec.rb" with: + """ruby + require "spec_helper" + + RSpec.describe "something" do + pending "will never happen again" do + expect(Time.now.year).to eq(2021) + end + end + """ + + Scenario: By default outputs backtrace and details + Given a file named "spec/spec_helper.rb" with: + """ruby + """ + When I run `rspec spec` + Then the examples should all pass + And the output should contain "Pending: (Failures listed here are expected and do not affect your suite's status)" + And the output should contain "1) something will never happen again" + And the output should contain "expected: 2021" + And the output should contain "./spec/example_spec.rb:5" + + Scenario: Setting `pending_failure_output` to `:no_backtrace` hides the backtrace + Given a file named "spec/spec_helper.rb" with: + """ruby + RSpec.configure { |c| c.pending_failure_output = :no_backtrace } + """ + When I run `rspec spec` + Then the examples should all pass + And the output should contain "Pending: (Failures listed here are expected and do not affect your suite's status)" + And the output should contain "1) something will never happen again" + And the output should contain "expected: 2021" + And the output should not contain "./spec/example_spec.rb:5" + + Scenario: Setting `pending_failure_output` to `:skip` hides the backtrace + Given a file named "spec/spec_helper.rb" with: + """ruby + RSpec.configure { |c| c.pending_failure_output = :skip } + """ + When I run `rspec spec` + Then the examples should all pass + And the output should not contain "Pending: (Failures listed here are expected and do not affect your suite's status)" + And the output should not contain "1) something will never happen again" + And the output should not contain "expected: 2021" + And the output should not contain "./spec/example_spec.rb:5" diff --git a/features/configuration/profile.feature b/features/configuration/profile.feature index 7d2d6d1677..dd7469d3a6 100644 --- a/features/configuration/profile.feature +++ b/features/configuration/profile.feature @@ -1,4 +1,4 @@ -Feature: Profile examples +Feature: Profiling examples (`--profile`) The `--profile` command line option (available from `RSpec.configure` as `#profile_examples`), when set, will cause RSpec to dump out a list of your diff --git a/features/configuration/read_options_from_file.feature b/features/configuration/read_options_from_file.feature index b9457e820f..67a1a74b6d 100644 --- a/features/configuration/read_options_from_file.feature +++ b/features/configuration/read_options_from_file.feature @@ -1,4 +1,4 @@ -Feature: read command line configuration options from files +Feature: Reading command line configuration options from files RSpec reads command line configuration options from several different files, all conforming to a specific level of specificity. Options from a higher diff --git a/features/configuration/run_all_when_everything_filtered.feature b/features/configuration/run_all_when_everything_filtered.feature index 5633bbebfe..64f6219aed 100644 --- a/features/configuration/run_all_when_everything_filtered.feature +++ b/features/configuration/run_all_when_everything_filtered.feature @@ -1,7 +1,7 @@ -Feature: run all when everything filtered +Feature: Using `run_all_when_everything_filtered` Note: this feature has been superseded by - [filter_run_when_matching](../filtering/filter-run-when-matching) and will be + [`filter_run_when_matching`](../filtering/filter-run-when-matching) and will be removed in a future version of RSpec. Use the `run_all_when_everything_filtered` option to tell RSpec to run all the diff --git a/features/core_standalone.feature b/features/core_standalone.feature index 53523d9abf..30a55c9a0c 100644 --- a/features/core_standalone.feature +++ b/features/core_standalone.feature @@ -1,4 +1,4 @@ -Feature: Use rspec-core without rspec-mocks or rspec-expectations +Feature: Use `rspec-core` without `rspec-mocks` or `rspec-expectations` It is most common to use rspec-core with rspec-mocks and rspec-expectations, and rspec-core will take care of loading those libraries automatically if diff --git a/features/example_groups/aliasing.feature b/features/example_groups/aliasing.feature index da5d1a676b..92866b7d1c 100644 --- a/features/example_groups/aliasing.feature +++ b/features/example_groups/aliasing.feature @@ -1,4 +1,4 @@ -Feature: aliasing +Feature: Aliasing `describe` and `context` are the default aliases for `example_group`. You can define your own aliases for `example_group` and give those custom aliases diff --git a/features/example_groups/basic_structure.feature b/features/example_groups/basic_structure.feature index b552b66b37..41004024bd 100644 --- a/features/example_groups/basic_structure.feature +++ b/features/example_groups/basic_structure.feature @@ -1,4 +1,4 @@ -Feature: basic structure (`describe`/`it`) +Feature: The basic structure (`describe`/`it`) RSpec is a DSL for creating executable examples of how code is expected to behave, organized in groups. It uses the words "describe" and "it" so we can diff --git a/features/example_groups/shared_context.feature b/features/example_groups/shared_context.feature index 7bea9c31d4..07408f56de 100644 --- a/features/example_groups/shared_context.feature +++ b/features/example_groups/shared_context.feature @@ -1,4 +1,4 @@ -Feature: shared context +Feature: Using `shared_context` Use `shared_context` to define a block that will be evaluated in the context of example groups either locally, using `include_context` in an example group, or globally using `config.include_context`. diff --git a/features/example_groups/shared_examples.feature b/features/example_groups/shared_examples.feature index c63ce45a79..8c364a713d 100644 --- a/features/example_groups/shared_examples.feature +++ b/features/example_groups/shared_examples.feature @@ -1,4 +1,4 @@ -Feature: shared examples +Feature: Using shared examples Shared examples let you describe behaviour of classes or modules. When declared, a shared group's content is stored. It is only realized in the context of @@ -83,7 +83,7 @@ Feature: shared examples `rspec-rails`. However, in order to keep your test suite boot time down, it's a good idea to not autorequire all files in a directory like this. When running only one spec file, loading unneeded dependencies or performing - unneeded setup can have a significant, noticable effect on how long it takes + unneeded setup can have a significant, noticeable effect on how long it takes before the first example runs. 3. When all of the groups that include the shared group reside in the same file, @@ -276,7 +276,7 @@ Feature: shared examples Scenario: Shared examples are nestable by context Given a file named "context_specific_examples_spec.rb" with: - """Ruby + """ruby RSpec.describe "shared examples" do context "per context" do @@ -296,7 +296,7 @@ Feature: shared examples Scenario: Shared examples are accessible from offspring contexts Given a file named "context_specific_examples_spec.rb" with: - """Ruby + """ruby RSpec.describe "shared examples" do shared_examples "shared examples are nestable" do specify { expect(true).to eq true } @@ -319,7 +319,7 @@ Feature: shared examples Scenario: Shared examples are isolated per context Given a file named "isolated_shared_examples_spec.rb" with: - """Ruby + """ruby RSpec.describe "shared examples" do context do shared_examples "shared examples are isolated" do diff --git a/features/expectation_framework_integration/aggregating_failures.feature b/features/expectation_framework_integration/aggregating_failures.feature index cefe1c18aa..107eb65525 100644 --- a/features/expectation_framework_integration/aggregating_failures.feature +++ b/features/expectation_framework_integration/aggregating_failures.feature @@ -1,6 +1,6 @@ Feature: Aggregating Failures - RSpec::Expectations provides [`aggregate_failures`](https://relishapp.com/rspec/rspec-expectations/docs/aggregating-failures), an API that allows you to group a set of expectations and see all the failures at once, rather than it aborting on the first failure. RSpec::Core improves on this feature in a couple of ways: + RSpec::Expectations provides [`aggregate_failures`](../../rspec-expectations/aggregating-failures), an API that allows you to group a set of expectations and see all the failures at once, rather than it aborting on the first failure. RSpec::Core improves on this feature in a couple of ways: * RSpec::Core provides much better failure output, adding code snippets and backtraces to the sub-failures, just like it does for any normal failure. * RSpec::Core provides [metadata](../metadata/user-defined-metadata) integration for this feature. Each example that is tagged with `:aggregate_failures` will be wrapped in an `aggregate_failures` block. You can also use `config.define_derived_metadata` to apply this to every example automatically. diff --git a/features/expectation_framework_integration/configure_expectation_framework.feature b/features/expectation_framework_integration/configure_expectation_framework.feature index cf8c22d97b..087a7dd9e4 100644 --- a/features/expectation_framework_integration/configure_expectation_framework.feature +++ b/features/expectation_framework_integration/configure_expectation_framework.feature @@ -1,4 +1,4 @@ -Feature: configure expectation framework +Feature: Configuring an expectation framework By default, RSpec is configured to include rspec-expectations for expressing desired outcomes. You can also configure RSpec to use: diff --git a/features/filtering/exclusion_filters.feature b/features/filtering/exclusion_filters.feature index 4cf4813179..275aca43a6 100644 --- a/features/filtering/exclusion_filters.feature +++ b/features/filtering/exclusion_filters.feature @@ -1,4 +1,4 @@ -Feature: exclusion filters +Feature: Exclusion filters You can exclude examples from a run by declaring an exclusion filter and then tagging examples, or entire groups, with that filter. You can also specify diff --git a/features/filtering/filter_run_when_matching.feature b/features/filtering/filter_run_when_matching.feature index d0e6a25dc4..4d32d61031 100644 --- a/features/filtering/filter_run_when_matching.feature +++ b/features/filtering/filter_run_when_matching.feature @@ -1,4 +1,4 @@ -Feature: filter_run_when_matching +Feature: Using `filter_run_when_matching` You can configure a _conditional_ filter that only applies if there are any matching examples using `config.filter_run_when_matching`. This is commonly used for focus diff --git a/features/filtering/inclusion_filters.feature b/features/filtering/inclusion_filters.feature index 888292481c..7c67aa01ee 100644 --- a/features/filtering/inclusion_filters.feature +++ b/features/filtering/inclusion_filters.feature @@ -1,4 +1,4 @@ -Feature: inclusion filters +Feature: Inclusion filters You can constrain which examples are run by declaring an inclusion filter. The most common use case is to focus on a subset of examples as you're focused diff --git a/features/formatters/custom_formatter.feature b/features/formatters/custom_formatter.feature index ae71b51339..05531e02df 100644 --- a/features/formatters/custom_formatter.feature +++ b/features/formatters/custom_formatter.feature @@ -1,4 +1,4 @@ -Feature: custom formatters +Feature: Custom formatters RSpec ships with general purpose output formatters. You can tell RSpec which one to use using the [`--format` command line option](../command-line/format-option). diff --git a/features/formatters/json_formatter.feature b/features/formatters/json_formatter.feature index 71dc2459b9..31ed425837 100644 --- a/features/formatters/json_formatter.feature +++ b/features/formatters/json_formatter.feature @@ -1,4 +1,4 @@ -Feature: JSON formatter +Feature: The JSON formatter Scenario: Formatting example names for retry Given a file named "various_spec.rb" with: diff --git a/features/helper_methods/arbitrary_methods.feature b/features/helper_methods/arbitrary_methods.feature index e9c241d319..ef99755aa8 100644 --- a/features/helper_methods/arbitrary_methods.feature +++ b/features/helper_methods/arbitrary_methods.feature @@ -1,4 +1,4 @@ -Feature: arbitrary helper methods +Feature: Defining arbitrary helper methods You can define methods in any example group using Ruby's `def` keyword or `define_method` method. These _helper_ methods are exposed to examples in the diff --git a/features/helper_methods/let.feature b/features/helper_methods/let.feature index 7c5d0b0c1d..a2e360a56a 100644 --- a/features/helper_methods/let.feature +++ b/features/helper_methods/let.feature @@ -1,4 +1,4 @@ -Feature: let and let! +Feature: `let` and `let!` Use `let` to define a memoized helper method. The value will be cached across multiple calls in the same example but not across examples. diff --git a/features/hooks/filtering.feature b/features/hooks/filtering.feature index 340e3900de..546e17b046 100644 --- a/features/hooks/filtering.feature +++ b/features/hooks/filtering.feature @@ -1,4 +1,4 @@ -Feature: filters +Feature: Filtering `before`, `after`, and `around` hooks defined in the block passed to `RSpec.configure` can be constrained to specific examples and/or groups using diff --git a/features/hooks/when_first_matching_example_defined.feature b/features/hooks/when_first_matching_example_defined.feature index 1bf0df2d52..1d34a35bbe 100644 --- a/features/hooks/when_first_matching_example_defined.feature +++ b/features/hooks/when_first_matching_example_defined.feature @@ -1,4 +1,4 @@ -Feature: `when_first_matching_example_defined` hook +Feature: Using `when_first_matching_example_defined` hook In large projects that use RSpec, it's common to have some expensive setup logic that is only needed when certain kinds of specs have been loaded. If that kind of diff --git a/features/metadata/current_example.feature b/features/metadata/current_example.feature index abe33fea99..3e9c2f9f52 100644 --- a/features/metadata/current_example.feature +++ b/features/metadata/current_example.feature @@ -1,4 +1,4 @@ -Feature: current example +Feature: Using the current example You can reference the example object, and access its metadata, using the block argument provided to: `it`, `subject`, `let`, and the `before`, `after`, and diff --git a/features/metadata/current_scope.feature b/features/metadata/current_scope.feature index 6df122d449..2a1fb4c647 100644 --- a/features/metadata/current_scope.feature +++ b/features/metadata/current_scope.feature @@ -1,4 +1,4 @@ -Feature: RSpec provides the current scope as RSpec.current_scope +Feature: `RSpec` provides the current scope as `RSpec.current_scope` You can detect which rspec scope your helper methods or library code is executing in. This is useful if for example, your method only makes sense to call in a certain context. diff --git a/features/metadata/described_class.feature b/features/metadata/described_class.feature index 13d40fbba4..b5ad27e0e7 100644 --- a/features/metadata/described_class.feature +++ b/features/metadata/described_class.feature @@ -1,4 +1,4 @@ -Feature: described class +Feature: Using `described_class` If the first argument to an example group is a class, the class is exposed to each example in that example group via the `described_class()` method. diff --git a/features/mock_framework_integration/use_any_framework.feature b/features/mock_framework_integration/use_any_framework.feature index a87e812c9c..13fa3dffb5 100644 --- a/features/mock_framework_integration/use_any_framework.feature +++ b/features/mock_framework_integration/use_any_framework.feature @@ -1,4 +1,4 @@ -Feature: mock with an alternative framework +Feature: Mocking with an alternative framework In addition to rspec, mocha, flexmock, and RR, you can choose an alternate framework as the mocking framework. You (or the framework authors) just needs diff --git a/features/mock_framework_integration/use_flexmock.feature b/features/mock_framework_integration/use_flexmock.feature index 7d1e314620..123126b452 100644 --- a/features/mock_framework_integration/use_flexmock.feature +++ b/features/mock_framework_integration/use_flexmock.feature @@ -1,4 +1,4 @@ -Feature: mock with flexmock +Feature: Mocking with `flexmock` Configure RSpec to use flexmock as shown in the scenarios below. diff --git a/features/mock_framework_integration/use_mocha.feature b/features/mock_framework_integration/use_mocha.feature index 1d116c4a6b..733a2abc1b 100644 --- a/features/mock_framework_integration/use_mocha.feature +++ b/features/mock_framework_integration/use_mocha.feature @@ -1,4 +1,4 @@ -Feature: mock with mocha +Feature: Mocking with `mocha` Configure RSpec to use mocha as shown in the scenarios below. diff --git a/features/mock_framework_integration/use_rr.feature b/features/mock_framework_integration/use_rr.feature index 7a7a4e57fe..42970ec0f0 100644 --- a/features/mock_framework_integration/use_rr.feature +++ b/features/mock_framework_integration/use_rr.feature @@ -1,4 +1,4 @@ -Feature: mock with rr +Feature: Mocking with `rr` Configure RSpec to use rr as shown in the scenarios below. diff --git a/features/mock_framework_integration/use_rspec.feature b/features/mock_framework_integration/use_rspec.feature index 4945bdcda4..23bc322bda 100644 --- a/features/mock_framework_integration/use_rspec.feature +++ b/features/mock_framework_integration/use_rspec.feature @@ -1,4 +1,4 @@ -Feature: mock with rspec +Feature: Mocking with `rspec` RSpec uses its own mocking framework by default. You can also configure it explicitly if you wish. diff --git a/features/pending_and_skipped_examples/README.md b/features/pending_and_skipped_examples/README.md index be5c047c63..5e93f4c86a 100644 --- a/features/pending_and_skipped_examples/README.md +++ b/features/pending_and_skipped_examples/README.md @@ -1,3 +1,5 @@ +# Pending and Skipped examples + Sometimes you will have a failing example that can not be fixed, but is useful to keep around. For instance, the fix could depend on an upstream patch being merged, or the example is not supported on JRuby. RSpec provides two features for dealing with this scenario. An example can either be marked as _skipped_, in which is it not executed, or _pending_ in which it is executed but failure will not cause a failure of the entire suite. When a pending example passes (i.e. the underlying reasons for it being marked pending is no longer present) it will be marked as failed in order to communicate to you that it should no longer be marked as pending. diff --git a/features/pending_and_skipped_examples/pending_examples.feature b/features/pending_and_skipped_examples/pending_examples.feature index f1210152f7..e452a122c9 100644 --- a/features/pending_and_skipped_examples/pending_examples.feature +++ b/features/pending_and_skipped_examples/pending_examples.feature @@ -1,4 +1,4 @@ -Feature: `pending` examples +Feature: Using `pending` with examples RSpec offers a number of different ways to indicate that an example is disabled pending some action. diff --git a/features/pending_and_skipped_examples/skipped_examples.feature b/features/pending_and_skipped_examples/skipped_examples.feature index bbbb351f1c..711111f8fc 100644 --- a/features/pending_and_skipped_examples/skipped_examples.feature +++ b/features/pending_and_skipped_examples/skipped_examples.feature @@ -1,4 +1,4 @@ -Feature: `skip` examples +Feature: Using `skip` with examples RSpec offers a number of ways to indicate that an example should be skipped and not executed. diff --git a/features/spec_files/arbitrary_file_suffix.feature b/features/spec_files/arbitrary_file_suffix.feature index 17921ef4e9..6784fa06da 100644 --- a/features/spec_files/arbitrary_file_suffix.feature +++ b/features/spec_files/arbitrary_file_suffix.feature @@ -1,4 +1,4 @@ -Feature: arbitrary file suffix +Feature: Using an arbitrary file suffix Scenario: `.spec` Given a file named "a.spec" with: diff --git a/features/subject/implicit_subject.feature b/features/subject/implicit_subject.feature index 8e6c333fc0..d3bfc649ac 100644 --- a/features/subject/implicit_subject.feature +++ b/features/subject/implicit_subject.feature @@ -1,4 +1,4 @@ -Feature: implicitly defined subject +Feature: Implicitly defined subject If the first argument to an example group is a class, an instance of that class is exposed to each example in that example group via the `subject` diff --git a/lib/rspec/core/configuration.rb b/lib/rspec/core/configuration.rb index d44902449c..cef3e813a6 100644 --- a/lib/rspec/core/configuration.rb +++ b/lib/rspec/core/configuration.rb @@ -453,11 +453,30 @@ def shared_context_metadata_behavior=(value) add_setting :threadsafe # @macro add_setting - # Maximum count of failed source lines to display in the failure reports. - # (default `10`). + # Maximum count of failed source lines to display in the failure reports + # (defaults to `10`). # return [Integer] add_setting :max_displayed_failure_line_count + # @macro full_cause_backtrace + # Display the full backtrace of an exceptions cause (defaults to `false`). + # return [Boolean] + add_setting :full_cause_backtrace + + # @macro add_setting + # Format the output for pending examples. Can be set to: + # - :full (default) - pending examples appear similarly to failures + # - :no_backtrace - same as above, but with no backtrace + # - :skip - do not show the section at all + # return [Symbol] + add_read_only_setting :pending_failure_output + def pending_failure_output=(mode) + raise ArgumentError, + "`pending_failure_output` can be set to :full, :no_backtrace, " \ + "or :skip" unless [:full, :no_backtrace, :skip].include?(mode) + @pending_failure_output = mode + end + # Determines which bisect runner implementation gets used to run subsets # of the suite during a bisection. Your choices are: # @@ -557,8 +576,10 @@ def initialize @derived_metadata_blocks = FilterableItemRepository::QueryOptimized.new(:any?) @threadsafe = true @max_displayed_failure_line_count = 10 + @full_cause_backtrace = false @world = World::Null @shared_context_metadata_behavior = :trigger_inclusion + @pending_failure_output = :full define_built_in_hooks end @@ -678,7 +699,7 @@ def backtrace_exclusion_patterns end # Set regular expressions used to exclude lines in backtrace. - # @param patterns [Array] set backtrace_formatter exlusion_patterns + # @param patterns [Array] set backtrace_formatter exclusion_patterns def backtrace_exclusion_patterns=(patterns) @backtrace_formatter.exclusion_patterns = patterns end @@ -1820,7 +1841,7 @@ def raise_errors_for_deprecations! # by not setting `mock_with` or `expect_with` to anything else). # # @note If the user uses this options with `mock_with :mocha` - # (or similiar) they will still have monkey patching active + # (or similar) they will still have monkey patching active # in their test environment from mocha. # # @example @@ -2120,6 +2141,13 @@ def load_file_handling_errors(method, file) suggestions = DidYouMean.new(relative_file).call reporter.notify_non_example_exception(ex, "An error occurred while loading #{relative_file}.#{suggestions}") RSpec.world.wants_to_quit = true + rescue SyntaxError => ex + relative_file = Metadata.relative_path(file) + reporter.notify_non_example_exception( + ex, + "While loading #{relative_file} a `raise SyntaxError` occurred, RSpec will now quit." + ) + RSpec.world.rspec_is_quitting = true rescue Support::AllExceptionsExceptOnesWeMustNotRescue => ex relative_file = Metadata.relative_path(file) reporter.notify_non_example_exception(ex, "An error occurred while loading #{relative_file}.") diff --git a/lib/rspec/core/configuration_options.rb b/lib/rspec/core/configuration_options.rb index f669cda5f9..01325088e4 100644 --- a/lib/rspec/core/configuration_options.rb +++ b/lib/rspec/core/configuration_options.rb @@ -79,6 +79,10 @@ def order(keys) # deprecation (or otherwise access the reporter). :deprecation_stream, + # In order for `RSpec.configuration.dry_run?` to return `true` during + # processing the `requires` option, it must be parsed before it. + :dry_run, + # load paths depend on nothing, but must be set before `requires` # to support load-path-relative requires. :libs, @@ -169,7 +173,8 @@ def parse_args_ignoring_files_or_dirs_to_run(args, source) def args_from_options_file(path) return [] unless path && File.exist?(path) config_string = options_file_as_erb_string(path) - FlatMap.flat_map(config_string.split(/\n+/), &:shellsplit) + config_lines = config_string.split(/\n+/).reject { |s| s =~ /\A\s*#/ } + FlatMap.flat_map(config_lines, &:shellsplit) end def options_file_as_erb_string(path) diff --git a/lib/rspec/core/example_status_persister.rb b/lib/rspec/core/example_status_persister.rb index 7da584e68b..d628b76e6b 100644 --- a/lib/rspec/core/example_status_persister.rb +++ b/lib/rspec/core/example_status_persister.rb @@ -63,7 +63,7 @@ def statuses_from_this_run # were loaded but not executed (due to filtering, `--fail-fast` # or whatever) should have a `:status` of `UNKNOWN_STATUS`. # - # This willl produce a new list that: + # This will produce a new list that: # - Will be missing examples from previous runs that we know for sure # no longer exist. # - Will have the latest known status for any examples that either @@ -164,7 +164,7 @@ def formatted_header_rows end def formatted_value_rows - @foramtted_value_rows ||= rows.map do |row| + @formatted_value_rows ||= rows.map do |row| formatted_row_from(row) end end diff --git a/lib/rspec/core/formatters/exception_presenter.rb b/lib/rspec/core/formatters/exception_presenter.rb index e90a769282..22ac10aa68 100644 --- a/lib/rspec/core/formatters/exception_presenter.rb +++ b/lib/rspec/core/formatters/exception_presenter.rb @@ -56,7 +56,12 @@ def formatted_cause(exception) end unless last_cause.backtrace.nil? || last_cause.backtrace.empty? - cause << (" #{backtrace_formatter.format_backtrace(last_cause.backtrace, example.metadata).first}") + lines = backtrace_formatter.format_backtrace(last_cause.backtrace, example.metadata) + lines = [lines[0]] unless RSpec.configuration.full_cause_backtrace # rubocop:disable Metrics/BlockNesting + + lines.each do |line| + cause << (" #{line}") + end end end @@ -175,10 +180,22 @@ def failure_slash_error_lines end # rubocop:disable Lint/RescueException - def exception_message_string(exception) - exception.message.to_s - rescue Exception => other - "A #{exception.class} for which `exception.message.to_s` raises #{other.class}." + if SyntaxError.instance_methods.include?(:detailed_message) + def exception_message_string(exception) + case exception + when SyntaxError then exception.detailed_message.to_s + else + exception.message.to_s + end + rescue Exception => other + "A #{exception.class} for which `exception.message.to_s` raises #{other.class}." + end + else + def exception_message_string(exception) + exception.message.to_s + rescue Exception => other + "A #{exception.class} for which `exception.message.to_s` raises #{other.class}." + end end # rubocop:enable Lint/RescueException @@ -197,8 +214,8 @@ def extra_failure_lines @extra_failure_lines ||= begin lines = Array(example.metadata[:extra_failure_lines]) unless lines.empty? - lines.unshift('') - lines.push('') + lines.unshift('') unless lines.first == '' + lines.push('') unless lines.last == '' end lines end @@ -312,10 +329,14 @@ def pending_options ] } elsif @execution_result.status == :pending - { + options = { :message_color => RSpec.configuration.pending_color, :detail_formatter => PENDING_DETAIL_FORMATTER } + if RSpec.configuration.pending_failure_output == :no_backtrace + options[:backtrace_formatter] = EmptyBacktraceFormatter + end + options end end diff --git a/lib/rspec/core/formatters/html_snippet_extractor.rb b/lib/rspec/core/formatters/html_snippet_extractor.rb index d89cb1cc6d..50fe297cb4 100644 --- a/lib/rspec/core/formatters/html_snippet_extractor.rb +++ b/lib/rspec/core/formatters/html_snippet_extractor.rb @@ -43,7 +43,7 @@ def self.convert(code) # # @param backtrace [String] the backtrace from a test failure # @return [String] highlighted code snippet indicating where the test - # failure occured + # failure occurred # # @see #post_process def snippet(backtrace) @@ -103,7 +103,7 @@ def lines_around(file, line) # # @param highlighted [String] syntax-highlighted snippet surrounding the # offending line of code - # @param offending_line [Fixnum] line where failure occured + # @param offending_line [Fixnum] line where failure occurred # @return [String] completed snippet def post_process(highlighted, offending_line) new_lines = [] diff --git a/lib/rspec/core/formatters/json_formatter.rb b/lib/rspec/core/formatters/json_formatter.rb index ff15d90b26..7c6fde829a 100644 --- a/lib/rspec/core/formatters/json_formatter.rb +++ b/lib/rspec/core/formatters/json_formatter.rb @@ -32,15 +32,16 @@ def dump_summary(summary) @output_hash[:summary_line] = summary.totals_line end - def stop(notification) - @output_hash[:examples] = notification.examples.map do |example| - format_example(example).tap do |hash| - e = example.exception + def stop(group_notification) + @output_hash[:examples] = group_notification.notifications.map do |notification| + format_example(notification.example).tap do |hash| + e = notification.example.exception + if e - hash[:exception] = { + hash[:exception] = { :class => e.class.name, :message => e.message, - :backtrace => e.backtrace, + :backtrace => notification.formatted_backtrace, } end end diff --git a/lib/rspec/core/metadata_filter.rb b/lib/rspec/core/metadata_filter.rb index 9906f7de52..2e63baf942 100644 --- a/lib/rspec/core/metadata_filter.rb +++ b/lib/rspec/core/metadata_filter.rb @@ -92,7 +92,7 @@ module FilterableItemRepository # # This is ideal for use by a example or example group, which may # be updated multiple times with globally configured hooks, etc, - # but will not be queried frequently by other examples or examle + # but will not be queried frequently by other examples or example # groups. # @private class UpdateOptimized diff --git a/lib/rspec/core/notifications.rb b/lib/rspec/core/notifications.rb index 16a3255cce..72768ef4e2 100644 --- a/lib/rspec/core/notifications.rb +++ b/lib/rspec/core/notifications.rb @@ -120,6 +120,8 @@ def fully_formatted_failed_examples(colorizer=::RSpec::Core::Formatters::Console # @return [String] The list of pending examples, fully formatted in the # way that RSpec's built-in formatters emit. def fully_formatted_pending_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes) + return if RSpec.configuration.pending_failure_output == :skip + formatted = "\nPending: (Failures listed here are expected and do not affect your suite's status)\n".dup pending_notifications.each_with_index do |notification, index| diff --git a/lib/rspec/core/ordering.rb b/lib/rspec/core/ordering.rb index d852324dc5..6058a2f244 100644 --- a/lib/rspec/core/ordering.rb +++ b/lib/rspec/core/ordering.rb @@ -78,6 +78,30 @@ def order(list) end end + # @private + # A strategy which delays looking up the ordering until needed + class Delayed + def initialize(registry, name) + @registry = registry + @name = name + end + + def order(list) + strategy.order(list) + end + + private + + def strategy + @strategy ||= lookup_strategy + end + + def lookup_strategy + raise "Undefined ordering strategy #{@name.inspect}" unless @registry.has_strategy?(@name) + @registry.fetch(@name) + end + end + # @private # Stores the different ordering strategies. class Registry @@ -99,6 +123,10 @@ def fetch(name, &fallback) @strategies.fetch(name, &fallback) end + def has_strategy?(name) + @strategies.key?(name) + end + def register(sym, strategy) @strategies[sym] = strategy end @@ -143,9 +171,20 @@ def order=(type) :defined elsif order == 'recently-modified' :recently_modified + else + order.to_sym end - register_ordering(:global, ordering_registry.fetch(ordering_name)) if ordering_name + if ordering_name + strategy = + if ordering_registry.has_strategy?(ordering_name) + ordering_registry.fetch(ordering_name) + else + Delayed.new(ordering_registry, ordering_name) + end + + register_ordering(:global, strategy) + end end def force(hash) diff --git a/lib/rspec/core/output_wrapper.rb b/lib/rspec/core/output_wrapper.rb index b655025cbf..8e07aa8754 100644 --- a/lib/rspec/core/output_wrapper.rb +++ b/lib/rspec/core/output_wrapper.rb @@ -15,13 +15,13 @@ def respond_to?(name, priv=false) end def method_missing(name, *args, &block) - output.send(name, *args, &block) + output.__send__(name, *args, &block) end # Redirect calls for IO interface methods IO.instance_methods(false).each do |method| define_method(method) do |*args, &block| - output.send(method, *args, &block) + output.__send__(method, *args, &block) end end end diff --git a/lib/rspec/core/project_initializer/spec/spec_helper.rb b/lib/rspec/core/project_initializer/spec/spec_helper.rb index 5ae5b6962c..c80d44b974 100644 --- a/lib/rspec/core/project_initializer/spec/spec_helper.rb +++ b/lib/rspec/core/project_initializer/spec/spec_helper.rb @@ -61,7 +61,7 @@ # Limits the available syntax to the non-monkey patched syntax that is # recommended. For more details, see: - # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode + # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ config.disable_monkey_patching! # This setting enables warnings. It's recommended, but in some cases may diff --git a/lib/rspec/core/reporter.rb b/lib/rspec/core/reporter.rb index a016d0f860..10b55db2d1 100644 --- a/lib/rspec/core/reporter.rb +++ b/lib/rspec/core/reporter.rb @@ -30,7 +30,7 @@ def initialize(configuration) # Registers a listener to a list of notifications. The reporter will send # notification of events to all registered listeners. # - # @param listener [Object] An obect that wishes to be notified of reporter + # @param listener [Object] An object that wishes to be notified of reporter # events # @param notifications [Array] Array of symbols represents the events a # listener wishes to subscribe too diff --git a/lib/rspec/core/runner.rb b/lib/rspec/core/runner.rb index caf9c871af..16d07efea8 100644 --- a/lib/rspec/core/runner.rb +++ b/lib/rspec/core/runner.rb @@ -182,7 +182,11 @@ def self.handle_interrupt exit!(1) else RSpec.world.wants_to_quit = true - $stderr.puts "\nRSpec is shutting down and will print the summary report... Interrupt again to force quit." + + $stderr.puts( + "\nRSpec is shutting down and will print the summary report... Interrupt again to force quit " \ + "(warning: at_exit hooks will be skipped if you force quit)." + ) end end diff --git a/lib/rspec/core/version.rb b/lib/rspec/core/version.rb index a4620887b3..9b938e3ed0 100644 --- a/lib/rspec/core/version.rb +++ b/lib/rspec/core/version.rb @@ -3,7 +3,7 @@ module Core # Version information for RSpec Core. module Version # Current version of RSpec Core, in semantic versioning format. - STRING = '3.12.0.pre' + STRING = '3.13.0' end end end diff --git a/maintenance-branch b/maintenance-branch index ba2906d066..a71b13e28a 100644 --- a/maintenance-branch +++ b/maintenance-branch @@ -1 +1 @@ -main +3-13-maintenance diff --git a/script/ci_functions.sh b/script/ci_functions.sh index bac93360d7..9d04ee16b5 100644 --- a/script/ci_functions.sh +++ b/script/ci_functions.sh @@ -1,9 +1,9 @@ -# This file was generated on 2022-09-08T12:41:59+01:00 from the rspec-dev repo. +# This file was generated on 2023-12-25T16:05:21+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: # https://github.com/travis-ci/travis-build/blob/e9314616e182a23e6a280199cd9070bfc7cae548/lib/travis/build/script/templates/header.sh#L34-L53 -travis_retry() { +ci_retry() { local result=0 local count=1 while [ $count -le 3 ]; do diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 60bc403f33..43bbb0e401 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2022-09-08T12:41:59+01:00 from the rspec-dev repo. +# This file was generated on 2023-12-25T16:05:21+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e @@ -12,7 +12,7 @@ if is_mri; then clone_repo "rspec-core" clone_repo "rspec-expectations" clone_repo "rspec-mocks" - clone_repo "rspec-rails" + clone_repo "rspec-rails" "6-1-maintenance" if rspec_support_compatible; then clone_repo "rspec-support" diff --git a/script/cucumber.sh b/script/cucumber.sh index 7be6f49da8..77801f29f3 100755 --- a/script/cucumber.sh +++ b/script/cucumber.sh @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2022-09-08T12:41:59+01:00 from the rspec-dev repo. +# This file was generated on 2023-12-25T16:05:21+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index b582eeeac0..c057844f40 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2022-09-08T12:41:59+01:00 from the rspec-dev repo. +# This file was generated on 2023-12-25T16:05:21+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -25,7 +25,7 @@ function clone_repo { BRANCH_TO_CLONE="$2"; fi; - travis_retry eval "git clone https://github.com/rspec/$1 --depth 1 --branch ${BRANCH_TO_CLONE?}" + ci_retry eval "git clone https://github.com/rspec/$1 --depth 1 --branch ${BRANCH_TO_CLONE?}" fi; } @@ -89,16 +89,16 @@ function run_spec_suite_for { pushd ../$1 unset BUNDLE_GEMFILE bundle_install_flags=`cat .github/workflows/ci.yml | grep "bundle install" | sed 's/.* bundle install//'` - travis_retry eval "(unset RUBYOPT; exec bundle install $bundle_install_flags)" - travis_retry eval "(unset RUBYOPT; exec bundle binstubs --all)" + ci_retry eval "(unset RUBYOPT; exec bundle install $bundle_install_flags)" + ci_retry eval "(unset RUBYOPT; exec bundle binstubs --all)" run_specs_and_record_done popd else echo "" echo "WARNING: The ../$1 directory does not exist. Usually the" - echo "travis build cds into that directory and run the specs to" - echo "ensure the specs still pass with your latest changes, but" - echo "we are going to skip that step." + echo "build cds into that directory and run the specs to ensure" + echo "the specs still pass with your latest changes, but we are" + echo "going to skip that step." echo "" fi; fi; diff --git a/script/legacy_setup.sh b/script/legacy_setup.sh index 8899376f56..1c234277c4 100755 --- a/script/legacy_setup.sh +++ b/script/legacy_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2022-09-08T12:41:59+01:00 from the rspec-dev repo. +# This file was generated on 2023-12-25T16:05:21+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index d3a3563c82..3499d4bf7a 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2022-09-08T12:41:59+01:00 from the rspec-dev repo. +# This file was generated on 2023-12-25T16:05:21+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index 448a825ff5..73ada29916 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2022-09-08T12:41:59+01:00 from the rspec-dev repo. +# This file was generated on 2023-12-25T16:05:21+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/run_rubocop b/script/run_rubocop index 8fe1774b2c..f21724d52f 100755 --- a/script/run_rubocop +++ b/script/run_rubocop @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2022-09-08T12:41:59+01:00 from the rspec-dev repo. +# This file was generated on 2023-12-25T16:05:21+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index 8d51f56cab..b3fc938010 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2022-09-08T12:41:59+01:00 from the rspec-dev repo. +# This file was generated on 2023-12-25T16:05:21+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/spec/integration/bisect_runners_spec.rb b/spec/integration/bisect_runners_spec.rb index 46c04ae1e9..591b3290dd 100644 --- a/spec/integration/bisect_runners_spec.rb +++ b/spec/integration/bisect_runners_spec.rb @@ -82,11 +82,18 @@ def with_runner(&block) end " + rspec_description = + if RUBY_VERSION.to_f > 3.2 + "module RSpec" + else + "RSpec:Module" + end + with_runner do |runner| expect { runner.original_results }.to raise_error(Bisect::BisectFailedError, a_string_including( - "undefined method `escribe' for RSpec:Module", + "undefined method `escribe' for #{rspec_description}", 'stdout in a_spec', 'stderr in a_spec' )) diff --git a/spec/integration/bisect_spec.rb b/spec/integration/bisect_spec.rb index 74fbf57995..9f79a47b2a 100644 --- a/spec/integration/bisect_spec.rb +++ b/spec/integration/bisect_spec.rb @@ -15,6 +15,12 @@ def bisect(cli_args, expected_status=nil) normalize_durations(formatter_output.string) end + before do + if RSpec::Support::Ruby.jruby? && RSpec::Support::Ruby.jruby_version == '9.1.17.0' + skip "These specs are currently broken on JRuby 9.1.17.0" + end + end + context "when a load-time problem occurs while running the suite" do it 'surfaces the stdout and stderr output to the user' do output = bisect(%w[spec/rspec/core/resources/fail_on_load_spec.rb_], 1) diff --git a/spec/integration/spec_file_load_errors_spec.rb b/spec/integration/spec_file_load_errors_spec.rb index 7daa3bb5e9..1f11f6bd05 100644 --- a/spec/integration/spec_file_load_errors_spec.rb +++ b/spec/integration/spec_file_load_errors_spec.rb @@ -115,7 +115,7 @@ end end - it 'nicely handles load-time errors in user spec files' do + it 'nicely handles load-time errors in user spec files', :disable_error_highlight => true do write_file_formatted "1_spec.rb", " boom @@ -147,20 +147,28 @@ run_command "1_spec.rb 2_spec.rb 3_spec.rb" expect(last_cmd_exit_status).to eq(error_exit_code) output = normalize_durations(last_cmd_stdout) + + object_suffix = + if RUBY_VERSION.to_f > 3.2 + "" + else + ":Object" + end + expect(output).to eq unindent(<<-EOS) An error occurred while loading ./1_spec.rb. Failure/Error: boom NameError: - undefined local variable or method `boom' for main:Object + undefined local variable or method `boom' for main#{object_suffix} # ./1_spec.rb:1#{spec_line_suffix} An error occurred while loading ./3_spec.rb. Failure/Error: boom NameError: - undefined local variable or method `boom' for main:Object + undefined local variable or method `boom' for main#{object_suffix} # ./3_spec.rb:1#{spec_line_suffix} @@ -169,4 +177,82 @@ EOS end + + describe 'handling syntax errors' do + let(:formatted_output) { normalize_durations(last_cmd_stdout).gsub(Dir.pwd, '.').gsub(/\e\[[0-9;]+m/, '') } + + before(:example) do + write_file_formatted "broken_file.rb", " + class WorkInProgress + def initialize(arg) + def foo + end + end + " + end + + if RSpec::Support::RubyFeatures.supports_syntax_suggest? + it 'uses syntax_suggest formatting when available' do + in_sub_process do + require "syntax_suggest" + + run_command "--require ./broken_file" + expect(last_cmd_exit_status).to eq(error_exit_code) + + expect(formatted_output).to include unindent(<<-EOS) + While loading ./broken_file a `raise SyntaxError` occurred, RSpec will now quit. + Failure/Error: __send__(method, file) + EOS + + # A fix was backported to 3.2.3 + if RUBY_VERSION > '3.2.2' + expect(formatted_output).to include unindent(<<-EOS) + SyntaxError: + --> ./tmp/aruba/broken_file.rb + Unmatched keyword, missing `end' ? + 1 class WorkInProgress + > 2 def initialize(arg) + 3 def foo + 4 end + 5 end + EOS + else + expect(formatted_output).to include unindent(<<-EOS) + SyntaxError: + --> ./tmp/aruba/broken_file.rb + Unmatched keyword, missing `end' ? + 1 class WorkInProgress + > 2 def initialize(arg) + 4 end + 5 end + EOS + end + expect(formatted_output).to include "./tmp/aruba/broken_file.rb:5: syntax error" + + expect(formatted_output).to include unindent(<<-EOS) + Finished in n.nnnn seconds (files took n.nnnn seconds to load) + 0 examples, 0 failures, 1 error occurred outside of examples + EOS + end + end + else + it 'prints a basic error when no syntax_suggest is available/loaded', :skip => RUBY_VERSION.to_f < 1.9 || RSpec::Support::Ruby.jruby? do + run_command "--require ./broken_file" + expect(last_cmd_exit_status).to eq(error_exit_code) + + expect(formatted_output).to include unindent(<<-EOS) + While loading ./broken_file a `raise SyntaxError` occurred, RSpec will now quit. + Failure/Error: __send__(method, file) + EOS + + # This is subset of the formatted_output, it continues slightly but differs on different Rubies + expect(formatted_output).to include "SyntaxError:\n ./tmp/aruba/broken_file.rb:5: syntax error" + + expect(formatted_output).to include unindent(<<-EOS) + Finished in n.nnnn seconds (files took n.nnnn seconds to load) + 0 examples, 0 failures, 1 error occurred outside of examples + EOS + end + end + end end diff --git a/spec/rspec/core/configuration/only_failures_support_spec.rb b/spec/rspec/core/configuration/only_failures_support_spec.rb index 0db52a197f..13a1a7e385 100644 --- a/spec/rspec/core/configuration/only_failures_support_spec.rb +++ b/spec/rspec/core/configuration/only_failures_support_spec.rb @@ -92,7 +92,7 @@ def spec_files_with_failures end context "when `example_status_persistence_file_path` is configured" do - it 'returns a memoized array of unique spec files that contain failed exaples' do + it 'returns a memoized array of unique spec files that contain failed examples' do simulate_persisted_examples( { :example_id => "./spec_1.rb[1:1]", :status => "failed" }, { :example_id => "./spec_1.rb[1:2]", :status => "failed" }, diff --git a/spec/rspec/core/configuration_options_spec.rb b/spec/rspec/core/configuration_options_spec.rb index b077cb37f3..27c0c836a3 100644 --- a/spec/rspec/core/configuration_options_spec.rb +++ b/spec/rspec/core/configuration_options_spec.rb @@ -28,7 +28,7 @@ opts.configure(configuration) - expect(configuration).to have_received(:force).with(:deprecation_stream => "path/to/log").ordered + expect(configuration).to have_received(:force).with({:deprecation_stream => "path/to/log"}).ordered expect(configuration).to have_received(:requires=).ordered end @@ -39,8 +39,8 @@ opts.configure(configuration) - expect(configuration).to have_received(:force).with(:deprecation_stream => "path/to/log").ordered - expect(filter_manager).to have_received(:include).with(:foo => true).ordered + expect(configuration).to have_received(:force).with({:deprecation_stream => "path/to/log"}).ordered + expect(filter_manager).to have_received(:include).with({:foo => true}).ordered end it "configures deprecation_stream before configuring formatters" do @@ -49,10 +49,19 @@ opts.configure(configuration) - expect(configuration).to have_received(:force).with(:deprecation_stream => "path/to/log").ordered + expect(configuration).to have_received(:force).with({:deprecation_stream => "path/to/log"}).ordered expect(configuration).to have_received(:add_formatter).ordered end + it "sets dry_run before libs and requires" do + opts = config_options_object(*%w[--dry-run --require a/path -I a/lib]) + configuration = double("config").as_null_object + expect(configuration).to receive(:force).with({:dry_run => true}).ordered + expect(configuration).to receive(:libs=).ordered + expect(configuration).to receive(:requires=).ordered + opts.configure(configuration) + end + it "sends libs before requires" do opts = config_options_object(*%w[--require a/path -I a/lib]) configuration = double("config").as_null_object @@ -79,7 +88,7 @@ it "sets default_path before loading specs" do opts = config_options_object(*%w[--default-path spec]) - expect(config).to receive(:force).with(:default_path => 'spec').ordered + expect(config).to receive(:force).with({:default_path => 'spec'}).ordered expect(config).to receive(:get_files_to_run).ordered opts.configure(config) config.files_to_run @@ -94,7 +103,7 @@ it "sets default_path before `files_or_directories_to_run` since it relies on it" do opts = config_options_object(*%w[--default-path spec]) - expect(config).to receive(:force).with(:default_path => 'spec').ordered + expect(config).to receive(:force).with({:default_path => 'spec'}).ordered expect(config).to receive(:files_or_directories_to_run=).ordered opts.configure(config) end @@ -102,7 +111,7 @@ it 'configures the seed (via `order`) before requires so that required files can use the configured seed' do opts = config_options_object(*%w[ --seed 1234 --require spec_helper ]) - expect(config).to receive(:force).with(:order => "rand:1234").ordered + expect(config).to receive(:force).with({:order => "rand:1234"}).ordered expect(config).to receive(:requires=).ordered opts.configure(config) @@ -110,15 +119,15 @@ it 'configures `only_failures` before `files_or_directories_to_run` since it affects loaded files' do opts = config_options_object(*%w[ --only-failures ]) - expect(config).to receive(:force).with(:only_failures => true).ordered + expect(config).to receive(:force).with({:only_failures => true}).ordered expect(config).to receive(:files_or_directories_to_run=).ordered opts.configure(config) end { "pattern" => :pattern, "exclude-pattern" => :exclude_pattern }.each do |flag, attr| it "sets #{attr} before `requires` so users can check `files_to_run` in a `spec_helper` loaded by `--require`" do - opts = config_options_object(*%W[--require spec_helpe --#{flag} **/*.spec]) - expect(config).to receive(:force).with(attr => '**/*.spec').ordered + opts = config_options_object(*%W[--require spec_helper --#{flag} **/*.spec]) + expect(config).to receive(:force).with({attr => '**/*.spec'}).ordered expect(config).to receive(:requires=).ordered opts.configure(config) end @@ -138,20 +147,20 @@ it "forces color" do opts = config_options_object(*%w[--color]) - expect(config).to receive(:force).with(:color => true) - expect(config).to receive(:force).with(:color_mode => :automatic) + expect(config).to receive(:force).with({:color => true}) + expect(config).to receive(:force).with({:color_mode => :automatic}) opts.configure(config) end it "forces force_color" do opts = config_options_object(*%w[--force-color]) - expect(config).to receive(:force).with(:color_mode => :on) + expect(config).to receive(:force).with({:color_mode => :on}) opts.configure(config) end it "forces no_color" do opts = config_options_object(*%w[--no-color]) - expect(config).to receive(:force).with(:color_mode => :off) + expect(config).to receive(:force).with({:color_mode => :off}) opts.configure(config) end @@ -359,7 +368,7 @@ expect(parse_options("--drb", "--no-drb")).to include(:drb => false) end - it "gets overriden by a subsquent drb => true" do + it "gets overridden by a subsequent drb => true" do expect(parse_options("--no-drb", "--drb")).to include(:drb => true) end end @@ -396,7 +405,7 @@ describe "default_path" do it "gets set before files_or_directories_to_run" do config = RSpec::Core::Configuration.new - expect(config).to receive(:force).with(:default_path => 'foo').ordered + expect(config).to receive(:force).with({:default_path => 'foo'}).ordered expect(config).to receive(:get_files_to_run).ordered opts = config_options_object("--default-path", "foo") opts.configure(config) @@ -569,6 +578,13 @@ def expect_parsing_to_fail_mentioning_source(source, options=[]) expect(parse_options[:formatters]).to eq([['local']]) end + it 'ignores comment lines in option files' do + create_fixture_file("./.rspec", "# --force-color\n # --format local") + options = parse_options() + expect(options[:color_mode]).to be_nil + expect(parse_options[:formatters]).to be_nil + end + context "with custom options file" do it "ignores project and global options files" do create_fixture_file("./.rspec", "--format project") diff --git a/spec/rspec/core/configuration_spec.rb b/spec/rspec/core/configuration_spec.rb index 83b740bd36..165990f5aa 100644 --- a/spec/rspec/core/configuration_spec.rb +++ b/spec/rspec/core/configuration_spec.rb @@ -91,7 +91,7 @@ module RSpec::Core end end - context "when string represeting an integer number" do + context "when string representing an integer number" do it 'is set to number' do config.fail_fast = '5' expect(config.fail_fast).to eq 5 @@ -1793,7 +1793,7 @@ def metadata_hash(*args) expect(config.full_backtrace?).to eq true end - it 'returns false when backtrace patterns isnt empty' do + it "returns false when backtrace patterns are not empty" do config.backtrace_exclusion_patterns = [:lib] expect(config.full_backtrace?).to eq false end @@ -2377,7 +2377,7 @@ def metadata_hash(*args) end end - it 'overrides existing definitions of the aliased method name without issueing warnings' do + it 'overrides existing definitions of the aliased method name without issuing warnings' do config.expose_dsl_globally = true class << ExampleGroup @@ -2602,6 +2602,49 @@ def use_seed_on(registry) expect(ordering_strategy.order(list)).to eq([1, 2, 3, 4]) end end + + context 'given a custom ordering strategy' do + before do + allow(RSpec).to receive_messages(:configuration => config) + end + + it 'will lookup a previously registed ordering strategy' do + config.register_ordering(:custom_scheme) { |list| list.reverse } + + config.order = :custom_scheme + + strategy = config.ordering_registry.fetch(:global) + expect(strategy.order([1, 2, 3, 4])).to eq [4, 3, 2, 1] + end + + it 'will defer lookup until running' do + config.order = :custom_scheme + + strategy = config.ordering_registry.fetch(:global) + expect(strategy).to be_an_instance_of(Ordering::Delayed) + + config.register_ordering(:custom_scheme) { |list| list.reverse } + expect(strategy.order([1, 2, 3, 4])).to eq [4, 3, 2, 1] + end + + it 'will raise an error if ordering is not present when needed' do + config.order = :custom_scheme + + strategy = config.ordering_registry.fetch(:global) + expect(strategy).to be_an_instance_of(Ordering::Delayed) + + expect { strategy.order([1, 2, 3, 4]) }.to raise_error("Undefined ordering strategy :custom_scheme") + end + + it 'will lookup schemes as symbols even if given as strings' do + config.order = 'custom_scheme' + + config.register_ordering(:custom_scheme) { |list| list.reverse } + + strategy = config.ordering_registry.fetch(:global) + expect(strategy.order([1, 2, 3, 4])).to eq [4, 3, 2, 1] + end + end end describe "#register_ordering" do @@ -2906,6 +2949,36 @@ def emulate_not_configured_expectation_framework end end + describe '#pending_failure_output' do + it 'defaults to :full' do + expect(config.pending_failure_output).to eq :full + end + + it 'can be set to :full' do + config.pending_failure_output = :full + expect(config.pending_failure_output).to eq :full + end + + it 'can be set to :no_backtrace' do + config.pending_failure_output = :no_backtrace + expect(config.pending_failure_output).to eq :no_backtrace + end + + it 'can be set to :skip' do + config.pending_failure_output = :skip + expect(config.pending_failure_output).to eq :skip + end + + it 'cannot be set to any other values' do + expect { + config.pending_failure_output = :another_value + }.to raise_error( + ArgumentError, + '`pending_failure_output` can be set to :full, :no_backtrace, or :skip' + ) + end + end + # assigns files_or_directories_to_run and triggers post-processing # via `files_to_run`. def assign_files_or_directories_to_run(*value) diff --git a/spec/rspec/core/filter_manager_spec.rb b/spec/rspec/core/filter_manager_spec.rb index c4e48cd68e..8832082dc1 100644 --- a/spec/rspec/core/filter_manager_spec.rb +++ b/spec/rspec/core/filter_manager_spec.rb @@ -414,13 +414,13 @@ def add_filter(options) expect(description).to eq({ :foo => :bar }.inspect) end - it 'includes an overriden :if filter' do + it 'includes an overridden :if filter' do allow(RSpec).to receive(:deprecate) filter_manager.exclude :if => :custom_filter expect(description).to eq({ :if => :custom_filter }.inspect) end - it 'includes an overriden :unless filter' do + it 'includes an overridden :unless filter' do allow(RSpec).to receive(:deprecate) filter_manager.exclude :unless => :custom_filter expect(description).to eq({ :unless => :custom_filter }.inspect) diff --git a/spec/rspec/core/formatters/exception_presenter_spec.rb b/spec/rspec/core/formatters/exception_presenter_spec.rb index 92934ac769..1c02ec15ed 100644 --- a/spec/rspec/core/formatters/exception_presenter_spec.rb +++ b/spec/rspec/core/formatters/exception_presenter_spec.rb @@ -181,7 +181,7 @@ def initialize(message, backtrace = [], cause = nil) end caused_by_line_num = __LINE__ + 1 - let(:first_exception) { FakeException.new("Real\nculprit", ["#{__FILE__}:#{__LINE__}"]) } + let(:first_exception) { FakeException.new("Real\nculprit", ["#{__FILE__}:#{__LINE__}", "#{__FILE__}:#{__LINE__}"]) } it 'includes the first exception that caused the failure', :if => RSpec::Support::RubyFeatures.supports_exception_cause? do the_presenter = Formatters::ExceptionPresenter.new(the_exception, example) @@ -202,6 +202,32 @@ def initialize(message, backtrace = [], cause = nil) EOS end + context 'with RSpec.configuration.full_cause_backtrace enabled' do + before do + RSpec.configuration.full_cause_backtrace = true + end + + it 'prints full cause backtrace', :if => RSpec::Support::RubyFeatures.supports_exception_cause? do + the_presenter = Formatters::ExceptionPresenter.new(the_exception, example) + + expect(the_presenter.fully_formatted(1)).to eq(<<-EOS.gsub(/^ +\|/, '')) + | + | 1) Example + | Failure/Error: # The failure happened here!#{ encoding_check } + | + | Boom + | Bam + | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{line_num} + | # ------------------ + | # --- Caused by: --- + | # Real + | # culprit + | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{caused_by_line_num} + | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{caused_by_line_num} + EOS + end + end + context "when the first exception doesn't have a backgrace" do let(:first_exception) { FakeException.new("Real\nculprit", backtrace) } @@ -341,6 +367,25 @@ def to_s EOS end + it "wont add extra blank lines around extra failure lines when lines are already padded" do + extra_example = example.clone + failure_line = 'http://www.example.com/job_details/123' + extra_example.metadata[:extra_failure_lines] = ['', failure_line, ''] + the_presenter = Formatters::ExceptionPresenter.new(exception, extra_example, :indentation => 4) + expect(the_presenter.fully_formatted(1)).to eq(<<-EOS.gsub(/^ +\|/, '')) + | + | 1) Example + | Failure/Error: # The failure happened here!#{ encoding_check } + | + | Boom + | Bam + | + | #{failure_line} + | + | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{line_num} + EOS + end + describe 'line format' do let(:exception) do begin diff --git a/spec/rspec/core/formatters/helpers_spec.rb b/spec/rspec/core/formatters/helpers_spec.rb index 238bd6a99e..025fd4a7d7 100644 --- a/spec/rspec/core/formatters/helpers_spec.rb +++ b/spec/rspec/core/formatters/helpers_spec.rb @@ -108,7 +108,7 @@ expect(helper.format_seconds(50.330340)).to eq("50.33") end - it "returns human friendly elasped time" do + it "returns human friendly elapsed time" do expect(helper.format_seconds(50.1)).to eq("50.1") expect(helper.format_seconds(5)).to eq("5") expect(helper.format_seconds(5.0)).to eq("5") diff --git a/spec/rspec/core/formatters/json_formatter_spec.rb b/spec/rspec/core/formatters/json_formatter_spec.rb index ce8a7f6a48..2f54d6c723 100644 --- a/spec/rspec/core/formatters/json_formatter_spec.rb +++ b/spec/rspec/core/formatters/json_formatter_spec.rb @@ -93,6 +93,55 @@ expect(formatter_output.string).to eq expected.to_json end + context "when full backtrace is enabled" do + around do |example| + original_value = RSpec.configuration.full_backtrace? + RSpec.configuration.full_backtrace = true + example.run + RSpec.configuration.full_backtrace = original_value + end + + it "outputs the full backtrace" do + group = RSpec.describe do + it("fails") { fail "eek" } + end + + reporter.report(1) { |r| group.run(r) } + + formatted_backtrace = formatter.output_hash[:examples][0][:exception][:backtrace] + exception_backtrace = group.examples[0].exception.backtrace.map { |l| l.gsub(Dir.pwd, ".") } + + expect(formatted_backtrace).to eq(exception_backtrace) + end + end + + context "when full backtrace is disabled" do + around do |example| + original_value = RSpec.configuration.full_backtrace? + RSpec.configuration.full_backtrace = false + example.run + RSpec.configuration.full_backtrace = original_value + end + + it "outputs a strict subset of the full backtrace" do + group = RSpec.describe do + it("fails") { fail "eek" } + end + + reporter.report(1) { |r| group.run(r) } + + formatted_backtrace = formatter.output_hash[:examples][0][:exception][:backtrace] + exception_backtrace = group.examples[0].exception.backtrace.map { |l| l.gsub(Dir.pwd, ".") } + + expect(formatted_backtrace).not_to be_empty + + # Every line in the formatted backtrace is also in the original backtrace + expect(formatted_backtrace - exception_backtrace).to be_empty + # The original backtrace contains lines not in the formatted backtrace + expect(exception_backtrace - formatted_backtrace).not_to be_empty + end + end + describe "#stop" do it "adds all examples to the output hash" do send_notification :stop, stop_notification diff --git a/spec/rspec/core/formatters_spec.rb b/spec/rspec/core/formatters_spec.rb index aee305da97..2b5cb5a78e 100644 --- a/spec/rspec/core/formatters_spec.rb +++ b/spec/rspec/core/formatters_spec.rb @@ -111,7 +111,7 @@ module RSpec::Core::Formatters end it "raises ArgumentError if formatter is unknown" do - expect { loader.add :progresss, output }.to raise_error(ArgumentError) + expect { loader.add :nonexistent, output }.to raise_error(ArgumentError) end context "with a 2nd arg defining the output" do diff --git a/spec/rspec/core/memoized_helpers_spec.rb b/spec/rspec/core/memoized_helpers_spec.rb index 35ada394b6..11310d4996 100644 --- a/spec/rspec/core/memoized_helpers_spec.rb +++ b/spec/rspec/core/memoized_helpers_spec.rb @@ -67,7 +67,7 @@ def subject_value_for(describe_arg, &block) end end - it "can be overriden and super'd to from a nested group" do + it "can be overridden and super'd to from a nested group" do outer_subject_value = inner_subject_value = nil RSpec.describe(Array) do @@ -161,7 +161,7 @@ def working_with?(double) expect(subject_value).to eq([4, 5, 6]) end - it "can be overriden and super'd to from a nested group" do + it "can be overridden and super'd to from a nested group" do subject_value = nil group.describe("Nested") do subject { super() + [:override] } @@ -271,7 +271,7 @@ def working_with?(double) expect(subject_value).to eq(:inner) end - it 'is not overriden when an inner group defines a new method with the same name' do + it 'is not overridden when an inner group defines a new method with the same name' do subject_value = nil RSpec.describe do @@ -434,7 +434,7 @@ def not_ok?; false; end end end - specify 'memoized blocks prevent other threads from accessing, even when it is accesssed in a superclass' do + specify 'memoized blocks prevent other threads from accessing, even when it is accessed in a superclass' do describe_successfully do let!(:order) { ThreadOrder.new } after { order.apocalypse! :join } diff --git a/spec/rspec/core/metadata_spec.rb b/spec/rspec/core/metadata_spec.rb index b2a54209c4..73319dee00 100644 --- a/spec/rspec/core/metadata_spec.rb +++ b/spec/rspec/core/metadata_spec.rb @@ -868,7 +868,7 @@ def value_for(*args) end end - context "an an example metadata hash" do + context "on an example metadata hash" do it 'returns the described_class' do meta = nil diff --git a/spec/rspec/core/ordering_spec.rb b/spec/rspec/core/ordering_spec.rb index d68a628e87..40ce38ed94 100644 --- a/spec/rspec/core/ordering_spec.rb +++ b/spec/rspec/core/ordering_spec.rb @@ -104,6 +104,18 @@ def order_with(seed) end end + RSpec.describe Delayed do + let(:registry) { Registry.new(Configuration.new) } + + it 'looks up a strategy to order the list later on' do + strategy = Delayed.new(registry, :reverse) + expect { strategy.order([1, 2, 3, 4]) }.to raise_error("Undefined ordering strategy :reverse") + + registry.register(:reverse, Custom.new(proc { |list| list.reverse })) + expect(strategy.order([1, 2, 3, 4])).to eq([4, 3, 2, 1]) + end + end + RSpec.describe Registry do let(:configuration) { Configuration.new } subject(:registry) { Registry.new(configuration) } @@ -144,6 +156,15 @@ def order_with(seed) end end end + + describe "#has_strategy?(name)" do + it "returns true if the strategy was registered" do + expect { + registry.register(:reverse, Custom.new(proc { |list| list.reverse })) + }.to change { registry.has_strategy?(:reverse) }.from(false).to(true) + end + end + end end end diff --git a/spec/rspec/core/output_wrapper_spec.rb b/spec/rspec/core/output_wrapper_spec.rb index 8ed1341357..4e9be310c1 100644 --- a/spec/rspec/core/output_wrapper_spec.rb +++ b/spec/rspec/core/output_wrapper_spec.rb @@ -9,6 +9,14 @@ module RSpec::Core expect(output.string).to eq("message\nanother message").and eq(wrapper.string) end + it 'redirects calls when send is overridden' do + class << output + undef :send + end + wrapper.puts('message') + expect(output.string).to eq("message\n").and eq(wrapper.string) + end + describe '#output=' do let(:another_output) { StringIO.new } diff --git a/spec/rspec/core/pending_example_spec.rb b/spec/rspec/core/pending_example_spec.rb index fe9fe4b83b..5159a58373 100644 --- a/spec/rspec/core/pending_example_spec.rb +++ b/spec/rspec/core/pending_example_spec.rb @@ -22,7 +22,7 @@ expect(example).to be_pending_with('No reason given') end - it "passes if a mock expectation is not satisifed" do + it "passes if a mock expectation is not satisfied" do group = RSpec.describe('group') do example "example", :pending => "because" do expect(RSpec).to receive(:a_message_in_a_bottle) diff --git a/spec/rspec/core/reporter_spec.rb b/spec/rspec/core/reporter_spec.rb index 16e4822681..2fe50c27f9 100644 --- a/spec/rspec/core/reporter_spec.rb +++ b/spec/rspec/core/reporter_spec.rb @@ -58,7 +58,7 @@ module RSpec::Core reporter.start 3, (start_time + 5) end - it 'notifies the formatter of the seed used before notifing of start' do + it 'notifies the formatter of the seed used before notifying of start' do formatter = double("formatter") reporter.register_listener formatter, :seed reporter.register_listener formatter, :start diff --git a/spec/rspec/core_spec.rb b/spec/rspec/core_spec.rb index 5ce749da6a..8397d96729 100644 --- a/spec/rspec/core_spec.rb +++ b/spec/rspec/core_spec.rb @@ -52,7 +52,7 @@ # of files in `support/fake_libs` that substitute for the real things when # we put that directory on the load path. Here's the list: # - # * coderay -- loaded by the HTML formatter if availble for syntax highlighting. + # * coderay -- loaded by the HTML formatter if available for syntax highlighting. # * drb -- loaded when `--drb` is used. Loads other stdlibs (socket, thread, fcntl). # * erb -- loaded by `ConfigurationOptions` so `.rspec` can use ERB. Loads other stdlibs (strscan, cgi/util). # * flexmock -- loaded by our Flexmock mocking adapter. @@ -79,6 +79,10 @@ before(:example) do skip "Not reliably working on #{RUBY_DESCRIPTION}" end + elsif RSpec::Support::Ruby.jruby? && JRUBY_VERSION =~ /9\.1\.17\.0/ + before(:example, :description => /spec files/) do + pending "JRuby 9.1.17.0 generates unrelated warnings" + end end end @@ -296,14 +300,6 @@ def reporter end end - it 'uses only one thread local variable', :run_last do - # Trigger features that use thread locals... - aggregate_failures { } - RSpec.shared_examples_for("something") { } - - expect(Thread.current.keys.map(&:to_s).grep(/rspec/i).count).to eq(1) - end - describe "::Core.path_to_executable" do it 'returns the absolute location of the exe/rspec file' do expect(File.exist? RSpec::Core.path_to_executable).to be(true) @@ -342,4 +338,3 @@ def reporter expect(status.exitstatus).to eq(0) end end - diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index da6f4f1975..0bb9783643 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -69,6 +69,7 @@ def handle_current_dir_change end RSpec.configure do |c| + c.pending_failure_output = :no_backtrace c.example_status_persistence_file_path = "./spec/examples.txt" c.around(:example, :isolated_directory) do |ex| handle_current_dir_change(&ex) diff --git a/spec/support/aruba_support.rb b/spec/support/aruba_support.rb index 00d4a74316..93de143e16 100644 --- a/spec/support/aruba_support.rb +++ b/spec/support/aruba_support.rb @@ -15,7 +15,7 @@ def require_relative(relative_arg) absolute_feature = File.expand_path(relative_arg, File.dirname(File.realpath(file))) - # This was the orginal: + # This was the original: # ::Kernel.require absolute_feature ::Kernel.send(:require, absolute_feature) end @@ -49,7 +49,9 @@ def run_command(cmd) handle_current_dir_change do cd '.' do - @last_cmd_exit_status = RSpec::Core::Runner.run(cmd_parts, temp_stderr, temp_stdout) + with_isolated_stderr do + @last_cmd_exit_status = RSpec::Core::Runner.run(cmd_parts, temp_stderr, temp_stdout) + end end end ensure diff --git a/spec/support/error_highlight.rb b/spec/support/error_highlight.rb new file mode 100644 index 0000000000..adf6d273ae --- /dev/null +++ b/spec/support/error_highlight.rb @@ -0,0 +1,19 @@ +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 = DummyErrorHighlightFormatter + ex.run + ensure + ErrorHighlight.formatter = old_formatter + end + end + end +end diff --git a/spec/support/helper_methods.rb b/spec/support/helper_methods.rb index 8de71dc0bd..a4fd1de623 100644 --- a/spec/support/helper_methods.rb +++ b/spec/support/helper_methods.rb @@ -22,7 +22,7 @@ def unindent(s) end # In Ruby 2.7 taint was removed and has no effect, whilst SAFE warns that it - # has no effect and will become a normal varible in 3.0. Other engines do not + # has no effect and will become a normal variable in 3.0. Other engines do not # implement SAFE. if RUBY_VERSION >= '2.7' || (defined?(RUBY_ENGINE) && RUBY_ENGINE != "ruby") def with_safe_set_to_level_that_triggers_security_errors