Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Redefine rspec-mocks method to make our sandboxing work properly. #1274

Merged
merged 1 commit into from

3 participants

@myronmarston

This is an alternate fix to #1270. It fixes the build and prevents other mock scope warnings.

I think I like it a bit better than the fix in #1270 but I'm curious on your thoughts, @xaviershay.

@JonRowe
Owner

I like it...

@xaviershay
Collaborator

First reaction was I'd prefer to fix the specs that were broken, but second reaction is that there are plenty of others that aren't "broken" but are spewing deprecations. So in that case this is the better fix.

LGTM.

@JonRowe JonRowe merged commit 511cb7f into 2-99-maintenance
@JonRowe JonRowe deleted the fix-broken-2-99-build branch
@myronmarston

First reaction was I'd prefer to fix the specs that were broken,

FWIW, that was my initially reaction until I thought about it and realized the specs aren't really broken: it's just that the simplistic "are we outside an example" detection in rspec-mocks 2.99 doesn't understand the way we define and run examples from within examples in rspec-core, so it issues warnings when we are actually inside an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 0 deletions.
  1. +16 −0 spec/support/sandboxed_mock_space.rb
View
16 spec/support/sandboxed_mock_space.rb
@@ -1,6 +1,22 @@
require 'rspec/mocks'
module RSpec
+ module Mocks
+ Space.class_eval do
+ undef print_out_of_example_deprecation
+ def print_out_of_example_deprecation
+ # The simple "are you outside of an example" detection in rspec-mocks
+ # does not properly handle our dog fooding here in rspec core, where we define
+ # example groups and examples from within an example and run them.
+ # As a result, we get `SystemStackError` in a few specs that are mocking
+ # `RSpec.deprecate` and creating nested examples, but we don't care about
+ # this warning here in rspec-core.
+ #
+ # This redefintion silences it.
+ end
+ end
+ end
+
module Core
# Because rspec-core dog-foods itself, rspec-core's spec suite has
# examples that define example groups and examples and run them. The
Something went wrong with that request. Please try again.