Module: Imagery::Faking::ClassMethods
- Defined in:
- lib/imagery/faking.rb
Instance Attribute Summary collapse
-
#mode ⇒ Object
Allows you to define the current mode.
Instance Method Summary collapse
-
#faked ⇒ Object
Switches the current mode to :fake.
-
#real ⇒ Object
Switches the current mode to nil.
Instance Attribute Details
#mode ⇒ Object
Allows you to define the current mode. The only special value here is :fake. If the mode is :fake, then Imagery::Model#save and Imagery::Model#delete will not actually run.
25 26 27 |
# File 'lib/imagery/faking.rb', line 25 def mode @mode end |
Instance Method Details
#faked ⇒ Object
Switches the current mode to :fake.
41 42 43 44 45 46 |
# File 'lib/imagery/faking.rb', line 41 def faked @omode, @mode = @mode, :fake yield ensure @mode = @omode end |
#real ⇒ Object
Switches the current mode to nil. Useful for forcing real saves in your test.
You should do this at least once in your project just to know that all your Imagery::Model#save and Imagery::Model#delete operations actually work.
66 67 68 69 70 71 |
# File 'lib/imagery/faking.rb', line 66 def real @omode, @mode = @mode, nil yield ensure @mode = @omode end |