-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Would you be open to a PR to add verifying stub_const
? eg:
class User
OFFER_VALUE = 3
end
# spec tests ->
it "reads the value" do
stub_const_verifying("User::OFFER_VALUATION", 4)
# -> ArgumentError:
Cannot stub constant User::OFFER_VALUATION because it is not defined
end
Rational
We strongly favour a fail-fast startup in our apps.
eg, we use this to ensure our ENV is all correct before proceeding with app boot proper:
class User
OFFER_VALUE = `ENV.fetch("OFFER_VALUE")`
end
If we then want to test various different states of ENV, we need to stub const, but if the const name is mistyped, we get no feedback.
Adding this as a new method would be trivial. Would you like a PR for it?
Maybe there could be an rspec config which says "the standard stub_const
is now verifying, wherever used"
Any ideas or suggestions gratefully received!
Metadata
Metadata
Assignees
Labels
No labels