Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds additional documentation for mutating constants

  • Loading branch information...
commit 0a9316ffba6d6f0771605fe1d038967b39574156 1 parent 33bf2a9
@alindeman alindeman authored
View
3  features/.nav
@@ -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
View
22 features/stubbing_constants/README.md → features/mutating_constants/README.md
@@ -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")
+```
View
0  ...tubbing_constants/hiding_defined_constant.feature → ...utating_constants/hiding_defined_constant.feature
File renamed without changes
View
0  .../stubbing_constants/stub_defined_constant.feature → .../mutating_constants/stub_defined_constant.feature
File renamed without changes
View
0  ...tubbing_constants/stub_undefined_constant.feature → ...utating_constants/stub_undefined_constant.feature
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.