Permalink
Browse files

Adds additional documentation for mutating constants

  • Loading branch information...
alindeman committed Oct 21, 2012
1 parent 33bf2a9 commit 0a9316ffba6d6f0771605fe1d038967b39574156
View
@@ -18,9 +18,10 @@
- explicit.feature
- general_matchers.feature
- type_matchers.feature
-- stubbing_constants:
+- mutating_constants:
- stub_defined_constant.feature
- stub_undefined_constant.feature
+ - hiding_defined_constant.feature
- outside_rspec:
- configuration.feature
- standalone.feature
@@ -1,4 +1,6 @@
-## Stubbing Constants
+## Mutating Constants
+
+### Stubbing
Support is provided for stubbing constants. Like with method stubs, the
stubbed constants will be restored to their original state when an
@@ -60,3 +62,21 @@ CardDeck::SUITS # => [:Spades, :Diamonds, :Clubs, :Hearts]
CardDeck::NUM_CARDS # => raises uninitialized constant error
```
+### Hiding
+
+Support is also provided for hiding constants. Hiding a constant temporarily
+removes it; it is restored to its original value after the test completes.
+
+```ruby
+FOO = 42
+hide_const("FOO")
+FOO => NameError: uninitialized constant FOO
+```
+
+Like stubbed constants, names must be fully qualified.
+
+Hiding constants that are already undefined has no effect.
+
+```ruby
+hide_const("NO_OP")
+```

0 comments on commit 0a9316f

Please sign in to comment.