Skip to content

Instantly share code, notes, and snippets.

@markprzepiora
Last active December 21, 2015 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markprzepiora/6223998 to your computer and use it in GitHub Desktop.
Save markprzepiora/6223998 to your computer and use it in GitHub Desktop.
One-liner for switching over to using "double" instead of "stub" to create test double, the latter of which is deprecated in RSpec 3. This should not touch actual stubbing (e.g. something.stub(awesome: true)), or stubbing of constants for example (e.g., stub_const "MyArray"...)
find spec -name '*.rb' | xargs sed -i '' -E 's/([^.]|^)stub([^_]|$)/\1double\2/g'
diff --git a/spec/sample.rb b/spec/sample.rb
index 72fb490..5eed42f 100644
--- a/spec/sample.rb
+++ b/spec/sample.rb
@@ -1,4 +1,4 @@
-my_object = stub
-my_objects = [stub, stub]
+my_object = double
+my_objects = [double, double]
some_real_object.stub :saved => true
stub_const "MyClass"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment