Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rspec/rspec-core
base: v2.10.0
head fork: rspec/rspec-core
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
This comparison is big! We're only showing the most recent 250 commits
Commits on Jan 15, 2015
@myronmarston myronmarston Got things to work on 1.8.7. ab2b613
@myronmarston myronmarston Run `:context` hooks from shared contexts that apply to one example. 639db76
@myronmarston myronmarston Make :context hooks in config apply to individual matching examples. 3e1184c
@myronmarston myronmarston Skip specs failing due to a JRuby 1.7 bug when run in ruby 2.0 mode. 658e6e0
@myronmarston myronmarston Add benchmarks for treating an example’s group instance’s singleton c…
…lass as a group.
@myronmarston myronmarston Add profiling support with stackprof. f054a61
@myronmarston myronmarston Update docs to explain how singleton example groups work. 8a09786
@myronmarston myronmarston Remove unnecessary module inclusion. c2f04ed
@myronmarston myronmarston Split FilterableItemRepository into two implementations.
They are optimized for different cases.
@myronmarston myronmarston Use optimized filterable item repository in the appropriate places.
- Config should use the QueryOptimized one because config
  usually sets up global hooks, inclusions, etc once at the
  start of the process (e.g. in `spec_helper`) and then is
  repeatedly queried as each example or group is defined.
- Examples and groups should use the UpdateOptimized one as
  they are not queried by other examples or groups the way
  config is; instead, they can be updated multiple times
  based on having multiple global config hooks to process.
  Cutting out the additional update processing done by
  the QueryOptimized implementation greatly improves
  the performance of the `with_config_hooks` benchmark.
@myronmarston myronmarston Improve perf of metadata-based shared group inclusion.
The call to `RSpec::CallerFilter.first_non_rspec_line`
took most of the time. I originally planned to leverage
rspec/rspec-support#155 but realized we could avoid
calling that entirely by re-using the location from
the group’s metadata.

I re-ran all the benchmarks and updated them. They
look much, much better.
@e2 e2 docs: emphasize gem backtrace exclusion patterns
@myronmarston myronmarston Merge pull request #1847 from e2/doc_multiple_backtrace_gem_filter
docs: emphasize gem backtrace exclusion patterns
Commits on Jan 16, 2015
@myronmarston myronmarston Stop using aruba’s removed `regexp`.
See cucumber/aruba#227 for background.
Commits on Jan 17, 2015
@JonRowe JonRowe Merge pull request #1850 from rspec/fix-for-aruba-0-6-2
Stop using aruba’s removed `regexp`.
@agx agx Escape rspec path
otherwise things like

   bundle exec rake spec

break in repos containing spaces in directory names
Commits on Jan 18, 2015
@myronmarston myronmarston Merge pull request #1845 from agx/escape-rspec_path
Escape rspec path
@myronmarston myronmarston Changelog for #1845.
[ci skip]
Commits on Jan 20, 2015
@myronmarston myronmarston Merge pull request #1749 from rspec/more-powerful-include
Apply module/shared context inclusion to individual examples
Commits on Jan 22, 2015
@durran durran Allow Regexp class to be described
Commits on Jan 23, 2015
@myronmarston myronmarston It should be `flatten(1)`.
We changed it to `flatten(1)` in cd52601
but then accidentally changed it to `flatten(2)` in
940b7ab. Not sure how...
@myronmarston myronmarston Merge pull request #1854 from rspec/flatten-1-not-2
It should be `flatten(1)`.
Commits on Jan 26, 2015
@mtsmfm mtsmfm accept semicolon separated -I
@myronmarston myronmarston Merge pull request #1855 from mtsmfm/comma-separated-option
accept colon separated -I like ruby
@myronmarston myronmarston Changelog for #1855.
Also, add a bit more detail to the spec doc string,
to mention this mirror’s Ruby’s -I behavior.
Commits on Jan 27, 2015
@durran durran Move spec with described_class specs for Regexp failure
@myronmarston myronmarston Merge pull request #1853 from durran/regexp-testing
Allow Regexp class to be described
@myronmarston myronmarston Add changelog entry for #1853.
[ci skip]
Commits on Jan 30, 2015
@maxlinc maxlinc Fixes #1856: make sure summary is last so it doesn't scroll off the s…
@JonRowe JonRowe Merge pull request #1857 from maxlinc/summary_profile_order
Change the profile/dump_summary order
@JonRowe JonRowe changelog for #1857
[skip ci]
Commits on Feb 03, 2015
@myronmarston myronmarston Update changelog.
[ci skip]
@myronmarston myronmarston Update changelog for v3.2.0 [ci skip] 41abbac
@myronmarston myronmarston Release 3.2.0
@myronmarston myronmarston Bump version to 3.3.0.pre
Raymond Sanchez Skip Core.path_to_executable for Windows OS only
Commits on Feb 04, 2015
@rsanchez79 rsanchez79 Update spec for Core.path_to_executable
This is to handle issue with File.executable? on Windows.
@myronmarston myronmarston Remove unnecessary temporary mocks scope.
@myronmarston myronmarston Merge pull request #1860 from rsanchez79/master
Update Core.path_to_executable spec for Windows
@myronmarston myronmarston Cleanup whitespace.
@JonRowe JonRowe Merge pull request #1862 from rspec/remove-unnecessary-mock-scope
Remove unnecessary temporary mocks scope.
Raymond Sanchez Update spec for format_backtrace
In Windows, we can use '/' for file separator. Let's keep one spec for
both Windows and non-windows systems.
Commits on Feb 05, 2015
@JonRowe JonRowe Merge pull request #1865 from rsanchez79/specForWindows
Update spec for format_backtrace
@JonRowe JonRowe expose the reporter from a running example 038a183
Commits on Feb 06, 2015
@JonRowe JonRowe make Reporter#message a public api 44b36c7
@JonRowe JonRowe changelog for #1866
[skip ci]
@JonRowe JonRowe switch NullReporter to not be an instance
@JonRowe JonRowe Merge pull request #1866 from rspec/expose_reporter_and_allow_message
Expose reporter to running examples
Commits on Feb 08, 2015
@JonRowe JonRowe allow the reporter to send custom events to registered formatters a7b1037
@JonRowe JonRowe enforce notify only sending internal notifications
@JonRowe JonRowe Merge pull request #1869 from rspec/allow_publishing_custom_events_vi…

Allow the reporter to send custom events to registered formatters
Commits on Feb 09, 2015
@bf4 bf4 Skip specs with non-mri-compatible backtrace.
@JonRowe JonRowe Merge pull request #1871 from bf4/only_test_backtrace_on_mri
Skip specs with non-mri-compatible backtrace.
@myronmarston myronmarston Add changelog entry for #1869.
[ci skip]
@JonRowe JonRowe ammend changelog for #1869
[skip ci]
Commits on Feb 11, 2015
@myronmarston myronmarston Remove unnecessary shift/unshift.
@JonRowe JonRowe Merge pull request #1875 from rspec/cleanup-args-shifting
Remove unnecessary shift/unshift.
Commits on Feb 14, 2015
@myronmarston myronmarston Beef up tests for when rspec-expectations is not available.
Specifically, in #1826, we changed the conditional for
whether or not to assign a generated description from
RSpec::Matchers for examples with no doc string. Before
#1826, the conditional was: 

  assign_generated_description if RSpec.configuration.expecting_with_rspec?

In #1826 it changed to:

  assign_generated_description if defined?(::RSpec::Matchers)

We didn’t update the spec meant for that case to match, but it continued
to pass (as a false positive) due to rspec/rspec-mocks#874. @samphippen’s
fix in rspec/rspec-mocks#884 surfaced the issue (as the spec now failed)
so I decided to improve the tests.

- The spec now simulates the `RSpec::Matchers` constant being undefined
  to simulate the correct condition. We also have to prevent it from
  being autoloaded.
- The cukes for minitest/test-unit did not sufficiently cover this case,
  because the aforementioned autoload would autoload RSpec::Matchers,
  so we have to simulate rspec-expectations being completely uninstalled.
  Then the cukes properly fail if we break the `if defined?(::RSpec::Matchers)`
Commits on Feb 15, 2015
@JonRowe JonRowe Merge pull request #1879 from rspec/better-avoid-generated-descriptio…

Beef up tests for when rspec-expectations is not available.
Commits on Feb 16, 2015
@JonRowe JonRowe Fix inconsistency in spec
@cbliard pointed out on ca3d7fe via
that these specs don't actually assert what they are meant to
so corrected
@esposito esposito notify seed before notifying start
Commits on Feb 17, 2015
@myronmarston myronmarston Cleanup whitespace. 2808ab1
@myronmarston myronmarston Remove unneeded require. ca3f0d0
@myronmarston myronmarston Update to new library-wide rspec-support checks.
@myronmarston myronmarston Update what we skip to account for recent changes.
@JonRowe JonRowe Merge pull request #1880 from rspec/allowed-stdlibs
Allowed stdlibs
Commits on Feb 18, 2015
@bf4 bf4 Address String#split failures by using EncodedString
Add spec for exception when failure_lines has a bad encoding
@bf4 bf4 Remove unnecessary conditional
"".split("\n")       # => []
nil.to_s.split("\n") # => []

If exception.message is nil, the inner block will
not be reached. If it is non-nil, then there's no need
to check for nil inside the block.
@esposito esposito test order of notifications
@mswinson mswinson add type and version information to json formatter
- add type to allow clients to detect file format
- add version to determine which version of rspec-core generated the
@JonRowe JonRowe Merge pull request #1760 from bf4/handle_non_utf8_exception_messages
Handle exception message with invalid UTF-8; For rbx
@JonRowe JonRowe changelog for #1760
[skip ci]
Commits on Feb 19, 2015
@JonRowe JonRowe remove usage of set from rspec-core and replace with an internal look…
…upset which uses a hash
@JonRowe JonRowe rename LookupSet to Set 44beede
@JonRowe JonRowe benchmark demonstrating that `#keys.each` performs marginally better …
…than `#each_key`
Commits on Feb 20, 2015
@JonRowe JonRowe Merge pull request #1870 from rspec/remove_set
Remove Set
@JonRowe JonRowe Changelog for #1870
[skip ci]
Commits on Feb 21, 2015
@esposito esposito cleanup specs
Commits on Feb 22, 2015
@myronmarston myronmarston Merge pull request #1881 from rspec/correct_spec
Fix inconsistency in spec
@myronmarston myronmarston Merge pull request #1882 from esposito/master
Notify seed before notifying start
@myronmarston myronmarston Changelog for #1882.
[ci skip]
@myronmarston myronmarston Remove excess period.
[ci skip]
Commits on Feb 23, 2015
@myronmarston myronmarston Remove duplicate spec.
This exact spec is duplicated on line 775.
I suspect this was written for the old `--line-number` CLI flag
and got updated to the `file_path:line_num` form when
we dropped support for `--line-number`, creating the duplication.
@myronmarston myronmarston Add ids to examples and groups.
This allows us to uniquely identify any example or group.
@myronmarston myronmarston Add support to filter based on example/group ids. 911601d
@myronmarston myronmarston Use id in rerun command when the location identifies multiple examples. ea3d536
@myronmarston myronmarston Add some missing keys to RESERVED_KEYS.
…and add a spec enforcing that it is always up-to-date.
@myronmarston myronmarston Name the regexp to make it more clear what it’s for. per @samphipppen’s request.
@myronmarston myronmarston Standardize on setting `line` before rather than after. per @samphippen’s review request.
Commits on Feb 24, 2015
@myronmarston myronmarston Quote example ids in rerun command unless we know it’s unneeded. 3177337
@myronmarston myronmarston Update `rspec --help` to include more detail about filtering.
- Clarify location filtering.
- Add info about id filtering.
@myronmarston myronmarston Add changelog entries.
@myronmarston myronmarston Forwardport 3.2.1 release notes.
[ci skip]
@myronmarston myronmarston Add fish to the list of shells that allow unquoted ids.
…according to @joshcheek’s comment:

#1884 (comment)
@myronmarston myronmarston Updated travis build scripts (from rspec-dev)
Commits on Feb 25, 2015
@myronmarston myronmarston Lower JRuby coverage threshold.
@myronmarston myronmarston Merge pull request #1886 from rspec/update-travis-build-scripts-2015-…

Updates from rspec-dev (2015-02-24)
@JonRowe JonRowe Merge pull request #1884 from rspec/example-ids
Example ids
Commits on Feb 26, 2015
@myronmarston myronmarston Fix rake task arg quoting on Windows.
@myronmarston myronmarston Merge pull request #1887 from rspec/fix-rake-task-windows-escaping
Fix rake task arg quoting on Windows.
@myronmarston myronmarston Add missing paren.
[ci skip]
Commits on Mar 03, 2015
@myronmarston myronmarston Fix example in README to be accurate.
[ci skip]
@JonRowe JonRowe simple readme fix
[skip ci]
@JonRowe JonRowe Merge pull request #1890 from rspec/fixup_readme
Simple readme fix
Commits on Mar 05, 2015
@myronmarston myronmarston Make diff coloring work properly in integration specs. 4ac3b66
@myronmarston myronmarston Triple quotes aren’t really a thing.
Ruby concatenates strings that are next to each
other, though, so it’s a blank string concatenated
with a longer multi-line string concatenated with
another blank string.
Commits on Mar 06, 2015
@myronmarston myronmarston Prefer capitalized section headings. 4dd013d
@myronmarston myronmarston Remove mention of removed feature.
README space is limited so why waste it mentioning
a feature we no longer support?
@myronmarston myronmarston Add rspec gem to list as well.
While it’s not normally needed (it has no code!),
some RSpec extensions depend directly on `rspec` and
in such situations you’ll need it to have the newer
version as well.
@myronmarston myronmarston Add spacing. 38b1601
@myronmarston myronmarston Add note explaining that nested groups are subclasses. de156c1
@myronmarston myronmarston Improve “Get Started” section of README.
It’s important that you see the expectation fail
(it’s how you “test the test”, so to speak, and
you can confirm it gives you a good failure message),
so let’s not skip that step.
@myronmarston myronmarston Add section describing scope.
After reading,
I realized we do a poor job documenting the way the scopes work so this will hopefully help.
@myronmarston myronmarston Clarify what an example is.
[ci skip]
@myronmarston myronmarston Remove use of helper method override w/o `super`.
@myronmarston myronmarston Add snippet showing how the examples would get run.
@myronmarston myronmarston Apply tag filters only to files not having an id or location filter.
Fixes #1889.
Commits on Mar 08, 2015
@JonRowe JonRowe Merge pull request #1897 from rspec/fix-filtering-regression
Fix filtering regression
@JonRowe JonRowe Merge pull request #1898 from rspec/add-scope-docs
README improvements
Commits on Mar 10, 2015
@myronmarston myronmarston Rename argument to reflect what it actually is.
In my first pass I passed in the index but later
changed to passing in an index provider and forgot
to update the argument name.
@myronmarston myronmarston Cleanup formatter support a bit.
- Stop memoizing `example`. It made it difficult to
  construct multiple different examples.
- Explicitly create the examples where they are needed.
@myronmarston myronmarston Use a real result object instead of a double.
The result object is really just a value object,
so why fake it out?
@myronmarston myronmarston Implement dumper/parser for example statuses. 0529b6e
@myronmarston myronmarston Implement merging algorithm. ec07ce8
@myronmarston myronmarston Implement ExampleStatusPersister. 6c9d438
@myronmarston myronmarston Fix parser to handle blank values properly. 597b9fd
@myronmarston myronmarston Add config option for example status persistence file path. ee490cc
@myronmarston myronmarston Add `:last_run_status` metadata to examples. 6215a7a
@myronmarston myronmarston Add `--only-failures` and `--next-failure` options. 951e083
@myronmarston myronmarston Combine `--fail-fast` and `--no-fail-fast` in help output. 67c48b3
@myronmarston myronmarston Add changelog entries for new features from this PR.
Commits on Mar 12, 2015
@myronmarston myronmarston Forward port 3.2.2 release notes.
[ci skip]
@myronmarston myronmarston Load only files with failures when using `rspec --only-failures`.
Loading ALL spec files when only a handful have failures is inefficient
and could make the run take significantly longer. Note that we only do
this if no file or directory arg is passed to `rspec`. If the user
passes anything, we load what they tell us to load.
@myronmarston myronmarston Move `only_failures` config specs into their own file.
`configuration_spec.rb` is too huge. The API needs to
remain large to support the configurability of RSpec,
but we don’t need to keep all the specs in one file.
I want to start breaking off different chunks into their
own files. This is a first step towards that.
@myronmarston myronmarston Ensure derived values are updated when the config setting updates.
It’s easier to make this work by moving the
`spec_files_with_failures` and the
`last_run_statuses` methods off of `world`
and over to `configuration.
@myronmarston myronmarston Stop stubbing the object under test.
It made more sense when these methods were on `world`
as they were before but now they are on config so we
want to avoid that.
@myronmarston myronmarston Use spec/examples.txt instead of examples.txt.
It’s more appropriate there.
Commits on Mar 15, 2015
@myronmarston myronmarston Always limit loaded files when `--only-failures` is used.
Before, we only did so when no file or directory arg was passed
to `rspec`, but it's better to take the intersection of files
matching the provided args and files with failures.
@myronmarston myronmarston Use "unknown" for :last_run_status when we don't have a value.
This ensures that the value is consistent — before for an unknown
case it could either be `nil` or `"unknown"`.

We've also moved the constant into configuration, so that we can
avoid the cost of loading `example_status_persister` (via constant
access since it is setup to be autoloaded) if the user hasn't
configured the feature.
@myronmarston myronmarston Fail fast when we can't support `--only-failures` due to lack of config. 43da674
@myronmarston myronmarston Provide friendly warnings when we can’t access status file. 3258466
@myronmarston myronmarston Add `example_status_persistence_file_path` generated spec_helper.rb 8ced287
@myronmarston myronmarston Add backtrace to appveyor build (will later port to rspec-dev).
Commits on Mar 16, 2015
@myronmarston myronmarston Merge pull request #1888 from rspec/rerun-failures
Add new --only-failures CLI option
@myronmarston myronmarston Updated travis build scripts (from rspec-dev)
@JonRowe JonRowe Merge pull request #1904 from rspec/update-travis-build-scripts-2015-…

Updates from rspec-dev (2015-03-15)
@fabn fabn Warn users when overriding methods (via let, def or define_method) in…
… the same example group.
@myronmarston myronmarston Merge pull request #1903 from fabn/warn-on-multiple-let
Emit a warning when let override a method defined in the same context
@myronmarston myronmarston Add changelog for #1903.
[ci skip]
Commits on Mar 18, 2015
@myronmarston myronmarston Rename `safely` to make it more clear what it’s for. 4a61665
@myronmarston myronmarston Fix `RSpec::Core::RakeTask#failure_message`.
`system` returns a boolean value to indicate success/failure,
but the use of `failure_message` was in a `rescue` block that
never got executed.  It appears this has been broken since
ea70e4e. Before that commit,
we used `Rake::FileUtilsExt#ruby`, which does indicate failure
by raising an error (and thus the `rescue` was correct). In
ea70e4e, we switched to using
`system` and the rescue was left in place but never got hit

The lack of test coverage here is why we never noticed, so I
addressed that as well.
@myronmarston myronmarston Remove unreachable code.
`RSpec::CallerFilter.first_non_rspec_line` either
returns the line or raises an error, so the branch
for when `line` is nil could never be reached.
@myronmarston myronmarston Exclude version/platform-specific code from simplecov. 76e6976
@myronmarston myronmarston Remove dead code. 74a286d
@myronmarston myronmarston Add specs covering uncovered code. 4dede48
@myronmarston myronmarston Enforce 100% coverage on ruby >= 2.1.0.
@myronmarston myronmarston Merge pull request #1905 from rspec/update-coverage
Update coverage
Commits on Mar 19, 2015
@myronmarston myronmarston Make `—order random` more deterministic.
When you’re troubleshooting an order dependent
failure, you want to get the repro case down to
a minimal run that loads and runs as few specs
as possible. With the old random ordering implementation,
that was hard to achieve because while rerunning with
a given seed produced the same order when the exact
same set of examples were loaded, the ordering would
be completely different when a subset was loaded.

By ordering by `hash(seed + example_id)` it ensures
that the ordering of any two examples should stay
consistently regardless of how many other examples are

Jenkins or MD5 is significantly slower than `shuffle`,
but I think the tradeoff is worth it here. This isn’t
a hot spot.
@myronmarston myronmarston Add changelog for #1908.
Alex Kwiatkowski and Ryan Ong Check if method belongs to singleton_class before removing it
Fixes #1906
@leoarnold leoarnold Corrected a typo in documentation
@myronmarston myronmarston Merge pull request #1907 from SchoolKeep/ak-ro-fix-idempotently_defin…

Check if method belongs to singleton_class before removing it
@myronmarston myronmarston Add changelog for #1907.
[ci skip]
@myronmarston myronmarston Correct author list for #1907.
[ci skip]
@myronmarston myronmarston Merge pull request #1909 from leoarnold/master
Corrected a typo in documentation
@myronmarston myronmarston Use parens to clarify order of operations.
(This doesn’t actually change the order).
Commits on Mar 20, 2015
@myronmarston myronmarston Assign example group constant earlier.
This ensures it is set as soon as possible, before
shared contexts included via metadata are evaluated,
so that if there’s an error, the example group class
name will be included in it.
@myronmarston myronmarston Merge pull request #1908 from rspec/stable-random-ordering
Make `—order random` more deterministic.
@myronmarston myronmarston Add changelog entry for #1749.
Somehow I forgot to add this before...

[ci skip]
@myronmarston myronmarston Make `let` work properly when shared context is applied to a single e…
Commits on Mar 21, 2015
@myronmarston myronmarston Revert "Warn users when overriding methods (via let, def or define_me…
…thod) in the same example group."

This reverts the lib and spec pieces of e072e53.

The warning is overzealous. After upgrading a project to RSpec HEAD, I
got spammed with tons of warnings of situations that weren't actually
problematic.  For example, it's common to define a `let` in a shared
context that provides a default value, and than to purposefully override
that in a host group where the shared context is included. We should'nt
warn in such a situation, but this did warn.

See #1903 for the original code this reverts.
@myronmarston myronmarston Merge pull request #1915 from rspec/revert-method-override-warning
Revert "Warn users when overriding methods (via let, def or define_method) in the same example group."
@JonRowe JonRowe Merge pull request #1911 from rspec/assign-group-name-sooner
Assign example group constant earlier.
@JonRowe JonRowe Merge pull request #1912 from rspec/fix-let-no-superclass-method-problem
Make `let` work properly when shared context is applied to a single example.
Commits on Mar 22, 2015
@myronmarston myronmarston Don't purge example groups when a `--fail-fast` failure is hit.
Doing so prevents us from persisting updates to example statuses,
interfering with `--next-failure` from working properly.

The purging was introduced in 6946d2d but has actually done nothing
since fde5955, when the runner switched
from doing ` { |g| }` to
`order(@world.example_groups).map { |g| }`. With the ordering
applied, purging the example group no longer had the intended "abort
the loop early" effect, since we were now mapping over a derived ordered
array. The purging isn't really needed anyway; each example group aborts
early if `wants_to_quit` is set, so we still don't run any more examples
or groups.

It might be nice to bring back the "abort the loop early" effect but
I can't think of an elegant way to do it and it doesn't seem worth
the complexity at this point.

Fixes #1914.
@myronmarston myronmarston Don't stomp the order the user has already specified.
Fixes #1910.
@JonRowe JonRowe changelog for #1911
[skip ci]
Commits on Mar 23, 2015
@JonRowe JonRowe Merge pull request #1916 from rspec/fix-next-failure
Fix next failure
Commits on Apr 03, 2015
@JoshCheek JoshCheek Make memoized helpers threadsafe
See #1858 for discussion.

The unsquashed version can be seen at
in case the intermediate state and thoughts have value.


When working in a truly threaded environment (e.g. Rbx and JRuby),
you can write a test like the one below, which should pass.
But, it will fail sometimes, because two threads request the uninitialized counter
concurrently. The first one to receive the value will then be
incrementing a counter, that is later overwritten when the second
thread's let block returns.

You can verify this by running the code sample below in Rubinius.
After some number of attempts, the value will be less than 10k.
If you then make the `let` block a `let!` block, it will memoize
before the threads are created, and the values will be correct again.
While this is a reasonable solution, it is incredibly confusing
when it arises (I spent a lot of hours trying to find the bug in my code),
and requires that the user understand it's something they need to
be aware of and guard against.

class Counter
  def initialize
    @mutex =
    @count = 0

  attr_reader :count

  def increment
    @mutex.synchronize { @count += 1 }

RSpec.describe Counter do
  let(:counter) { }

  it 'increments the count in a threadsafe manner' do
    threads = do { 1000.times { counter.increment } }
    threads.each &:join
    expect(counter.count).to eq 10_000

Relevant Changes

* Adds `--[no]-threadsafe` command-line option
* `RSpec::Core::Configuration#threadsafe{?,=}`
  (notation there is from bash expansion)
  setting, defaults to `true`
* Mamoized is a threadsafe object instead of a hash,
  so rename `RSpec::Core::MemoizedHelpers::ContextHookMemoizedHash`
  to        `RSpec::Core::MemoizedHelpers::ContextHookMemoized`

  Create an object because only #fetch was being called on the hash,
  and to make that threadsafe required adding a new method.
  At that point, there is no value in having it subclass Hash,
  having to support an entire API that nothing else uses.
  So just make it an object which wraps a hash and presents a memoized
  getter/setter. Also named the method in such a way as to make it
  very clear that it's not a hash, so a dev won't mistakenly think
  they are working with one when they aren't.
* Adds private class `RSpec::Core::ReentrantMutex`,
  which is basically just `Monitor` from the stdlib.
* `RSpec::Core::ExampleGroup#initialize` now calls super so that
  `RSpec::Core::MemoizedHelpers` can initialize the memoized helper
  when the example is instantiated, rather than when it is accessed,
  as this is not threadsafe.

Context and daydreams

* PR can be seen unsquashed at:
  This is my first "real" squash, and it wasn't super smooth. I think I
  got it right, in the end, but if you're looking at it going "wtf?", and
  want some more context into the squash itself, I documented it at:
  Also, while I'm pretty sold against anything that changes history,
  there's probably a way to do this that's better than what I did,
  so if you read that and have insights, shoot em my wya, I'd love to get better!
* This does not add any stedlib dependencies as they affect the test
  environment of all users.
* The threads need to be reentrant, which will allow a let block in a thread to
  access its parent let block. This can be achieved with Monitor from
  the stdlib. However, to avoid the dependency, the code was copied from
  and pasted/edited into `lib/rspec/core/reentrant_mutex.rb`
  This way the user's test environment is preserved, but we still get
  reentrant mutexes.
* Reentrant mutexes are built on top of normal mutexes. These are in
  core now, but for 1.8.7, were defined in the stdlib's thread.rb
  So, similarly, copy that code into `RSpec::Core::ReentrantMutex::MUTEX`
  (capitalization due to Rubocop rules),
  with a note stating that it should be deleted once 1.8 support is dropped.
  If there is a Mutex available already, though, as on 1.9.x+, it will use that.
* Adds a development dependency on a gem, thread_order, which I extracted out of this work.
  Its purpose was to ease the difficulty and opacity of specifying what should
  happen and when, with regards to getting the threads into situations to illustrate
  expected behaviour. It similarly works on 1.8.7 - 2.2, and on JRuby and Rbx,
  without dependencies on the stdlib.
* Add benchmark for threadsafe let block, here is a summary:

  MRI 2.2

  1 call to let -- each sets the value
    non-threadsafe (original):   830988.5 i/s
    non-threadsafe (config)  :   665661.9 i/s - 1.25x slower
    threadsafe               :   323574.9 i/s - 2.57x slower
  10 calls to let -- 9 will find memoized value
    non-threadsafe (original):   346302.0 i/s
    non-threadsafe (config)  :   309970.2 i/s - 1.12x slower
    threadsafe               :   208946.3 i/s - 1.66x slower
  1 call to let which invokes super
    non-threadsafe (original):   591906.3 i/s
    non-threadsafe (config)  :   511295.0 i/s - 1.16x slower
    threadsafe               :   246079.6 i/s - 2.41x slower
  10 calls to let which invokes super
    non-threadsafe (original):   297422.6 i/s
    non-threadsafe (config)  :   264045.8 i/s - 1.13x slower
    threadsafe               :   170853.1 i/s - 1.74x slower

  The threasafe let is 1.5 to 2.5 times slower than the original hash
  implementation. The hash alternative is 1.1 to 1.25 times slower.
  If this matters for you, you can configure which one you want to use.

  Either way, you can call the method defined by a let block hundreds of
  thousands of times a second.
@myronmarston myronmarston Merge pull request #1858 from JoshCheek/threadsafe-let-block
Make memoized helpers threadsafe
@myronmarston myronmarston Tweak a few things about the threadsafe let solution from #1858.
1). Remove `--threadsafe` CLI option.

In general, we don't expose every config option via the CLI.
We want to make it easy for users to run `rspec --help` and
find the options that they are commonly going to want to customize
for a particular CLI run. I don't think `--threadsafe` is one of
those -- it's more something that'll be turned off globally for the
project or not touched at all, and as such, it adds noise to
the `--help` output to include it.

2). Extract Mutex class into its own file.

- Remove need for use of `MUTEX` over `Mutex`.
- No reason to force Ruby to parse the code
  for 1.8.7 Mutex implementation on other Rubies.

3). Remove threadsafe scenario.

A note about threadsafey is sufficient for the docs. Having
a full threadsafety example spec in the scenario is more
detail than users are likely to want to read.
@myronmarston myronmarston Merge pull request #1919 from rspec/threadsafe-let-followups
Tweak a few things about the threadsafe let solution from #1858.
Commits on Apr 04, 2015
@myronmarston myronmarston Remove unnecessary `uniq!` call.
No code is faster than no code.

It appears that the `uniq!` comes from micronaut:


However, it’s clear that it’s not actually needed. It didn’t do
anything for 2 years due to being a `uniq` (not `uniq!`)
call with an ignored return value, beginning in this commit:


…until this one, 2 years later:


I don’t think there’s any way for there to be any duplicates to begin with, so it’s safe to remove.
@myronmarston myronmarston Remove unnecessary `dup`.
`filter_manager.prune` avoids mutating the input array,
like a good citizen, so there’s no need to dup it.
@myronmarston myronmarston Abort filtering early if the input array is empty.
Commits on Apr 05, 2015
@myronmarston myronmarston Make `describe_successfully` available for all specs. 68b634e
@myronmarston myronmarston Groups with `before(:all) { skip }` should pass.
Fixes #1925.
@myronmarston myronmarston Explicitly indicate that the example group failed.
Before we were relying upon the return value of
`for_filtered_examples`, which is a bad idea.
@myronmarston myronmarston Use `describe_successfully` in a few more places.
This helper makes the additional helpful assertion
about the return value of ``.
@myronmarston myronmarston Add changelog entry.
@JonRowe JonRowe Merge pull request #1923 from rspec/filtering-improvements
Filtering improvements
@JonRowe JonRowe Merge pull request #1926 from rspec/fix-skip-before-all
Fix skip before all
@JonRowe JonRowe Merge pull request #1883 from mswinson/develop
add type and version information to json formatter
@JonRowe JonRowe remove extraneous information 86a68b4
Commits on Apr 06, 2015
@JonRowe JonRowe changelog post #1883
@myronmarston myronmarston Merge pull request #1927 from rspec/cleanup_post_1883
Cleanup post #1883
@myronmarston myronmarston Remove unused instance variable. d48d07f
@myronmarston myronmarston Extract ShellEscape module. 65c341e
@myronmarston myronmarston Make option parsing simpler and more consistent.
- Do not mutate the provided args.
- Include `:files_or_directories_to_run` in the
  returned options hash. After all, it’s part of
  the parsed options.

This will help support the new `--bisect` option
by making it easy for us to split CLI args into options
(which get re-used throughout the bisect process) and
files_or_directories_to_run (which get replaced during
@myronmarston myronmarston Store original args as an attribute of the Parser.
This will make it easier to implement `--bisect`, where we
need access to the original CLI options.
@myronmarston myronmarston Add bisect formatter and server. ebc8615
@myronmarston myronmarston Add bisect runner. bdb75db
@myronmarston myronmarston Add a SubsetEnumerator for bisect. d1eafe4
@myronmarston myronmarston Add ExampleMinimizer. 670fd13
@myronmarston myronmarston Get `--bisect` to work end-to-end. 5981247
@myronmarston myronmarston Rename attribute.
The “in execution order” part isn’t actually important
for how we are using it, and makes the name unnecessarily
@myronmarston myronmarston When bisecting, exit each run as soon as possible.
- When an expected failure passes (or is pending)
  we don’t care about any other results.
- When the last expected failure finishes, we don’t
  care about any later examples.
@myronmarston myronmarston Rename `output` to `formatter_output`.
`output` conflicts with the `output` formatter.
@myronmarston myronmarston While bisecting, silence stdout/stderr when shelling out. 911458b
@myronmarston myronmarston Surface spec suite load-time problems during bisect. 5a8f7d5
@myronmarston myronmarston Get bisect runner to work properly on JRuby.
Unfortunately, on JRuby, `Open3.popen3` doesn’t
handle shell escaped args properly :(.
@myronmarston myronmarston Abort bisect if the ordering is inconsistent. 4ce24f0
@myronmarston myronmarston Indicate if the bisection was successful via the exit code. 0b6acf3
@myronmarston myronmarston Extract helper methods for options that do something and exit.
This addresses a rubocop cyclomatic complexity failure.
@myronmarston myronmarston Limit DRb access to only localhost for security reasons.
It would be nice to have a test for this but I’m not
sure how to simulate a request from a different host :(.
@myronmarston myronmarston Standardize bisect notifications on `bisect_` prefix. 4c74a6f
@myronmarston myronmarston Refactor bisect debug output.
- Move formatting logic into a formatter.
- Improve the formatting.
- Leverage notification events.
@myronmarston myronmarston Add spec demonstrating that ENV vars are propagated properly. 45ed50c
@myronmarston myronmarston Fix duration normalization.
- Handle "second" vs "seconds".
- Handle minutes, too.
@myronmarston myronmarston Gracefully handle SIGINT during bisect. e38fab7
@myronmarston myronmarston Abort early if there are no failures. d7c3125
@myronmarston myronmarston Fix bisect runner to handle `-fd` in addition to `-f d`. 04d3f5e
@myronmarston myronmarston Standardize bisect progress output on "failing" over "failed". cf48b93
@myronmarston myronmarston Ignore flapping examples that did not fail on original run.
We only care that all the failures from the original
run are still failing; additional failures can be
@myronmarston myronmarston Fix help text grammar. fc95978
@myronmarston myronmarston Add changelog entry. 0e916fb
@myronmarston myronmarston Skip specs that are failing on AppVeyor on Ruby 2.1.
I have no idea why these pass on 1.9.3 but not on 2.1 on
AppVeyor.  It would be nice to get them to pass but
I don’t have access to a windows box and lack to the time
fix it now.
@myronmarston myronmarston Forwardport 3.2.3 release notes.
Commits on Apr 07, 2015
@myronmarston myronmarston Fix oddly worded sentences.
@myronmarston myronmarston Prefer localhost over is ipv4, whereas localhost should work
for ipv4 and ipv6.
@myronmarston myronmarston Change how we whitelist open3.
This allows it to be loaded by the bisect runner but if
it’s loaded by other things it’ll notify by causing the
“minimizes stdlibs” spec to fail.
Commits on Apr 08, 2015
@myronmarston myronmarston Remove slow spec that's not needed.
I wasn't sure that ENV vars would be propagated to spawned
process properly, but no logic was required to make that work.
I tried backticks and `system` as well and those also do
the right thing.

Given that, there's no need to keep this slow spec around.

Revert "Add spec demonstrating that ENV vars are propagated properly."

This reverts commit 45ed50c.
Commits on Apr 09, 2015
@myronmarston myronmarston Move bisect integration tests into cucumber scenarios.
- This surfaces the output to the user so they know what
  to expect based on reading the relish docs.
- This greatly reduces the runtime of our spec suite, from
  ~11.8 seconds to ~6.9 seconds.
@myronmarston myronmarston Update test to ensure bisect coordinator closes stream. 1f11351
@myronmarston myronmarston Use the `--bisect` flag value rather than ENV var for verbose mode.
@myronmarston myronmarston Merge pull request #1917 from rspec/bisect
@myronmarston myronmarston Fix help text for bisect to make it clear it's `--bisect=verbose`
Commits on Apr 10, 2015
@JonRowe JonRowe Fix scenario demonstrating the default behaviour of expose_dsl_globally
@myronmarston myronmarston Merge pull request #1932 from rspec/fix-bisect-help-text
Fix help text for bisect to make it clear it's `--bisect=verbose`
Commits on Apr 12, 2015
@JonRowe JonRowe ensure the default configuration is loaded in rspec/autorun 33e41fc
@JonRowe JonRowe changelog for #1933
@JonRowe JonRowe Merge pull request #1933 from rspec/fix_enable_global_dsl
Fixing the default behaviour of `expose_dsl_globally`
Commits on Apr 13, 2015
@eugeneius eugeneius Apply helper modules to existing groups when added
When a helper module is configured, it is now applied to all existing
matching example groups. This means that the order in which example
groups are defined and helper modules are configured no longer matters.
Commits on Apr 14, 2015
@JonRowe JonRowe Merge pull request #1935 from eugeneius/configure_existing_example_gr…

Apply helper modules to existing groups when added
@JonRowe JonRowe changelog for #1935
@myronmarston myronmarston Make specs from #1935 more robust.
- Ensure the specified behavior applies to nested
  groups and not simply top-level groups. The existing
  specs would have passed if the implementation of
  `configure_existing_groups` wrongly used
  `` instead of
  ``. This guards against that.
- Ensure metadata-based `include`/`extend`/`prepend` applies
  only to matching example groups. The existing specs would pass
  even if the metadata check was removed from the implementation
  of `configure_existing_groups`.
@myronmarston myronmarston Update changelog for #1935.
That PR fixed a bug (already added to the Changelog
by @JonRowe) but it also is notable for this enhancement.
@JonRowe JonRowe Merge pull request #1938 from rspec/pr-1935-followups
Pr 1935 followups
Commits on Apr 18, 2015
@myronmarston myronmarston Tell users where the invalid options came from.
Addresses the confusion reported in rspec/rspec-rails#1356.
Commits on Apr 19, 2015
@JonRowe JonRowe Merge pull request #1940 from rspec/tell-users-where-invalid-option-c…

Tell users where the invalid options came from.