Last active
December 21, 2015 00:59
-
-
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"...)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find spec -name '*.rb' | xargs sed -i '' -E 's/([^.]|^)stub([^_]|$)/\1double\2/g' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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