Class: Funktor::Testing
- Inherits:
-
Object
- Object
- Funktor::Testing
- Defined in:
- lib/funktor/testing.rb
Class Attribute Summary collapse
-
.mode ⇒ Object
Returns the value of attribute mode.
Class Method Summary collapse
- .disable! ⇒ Object
- .fake!(&block) ⇒ Object
- .fake? ⇒ Boolean
- .inline!(&block) ⇒ Object
- .inline? ⇒ Boolean
- .set_mode(new_mode, &block) ⇒ Object
Class Attribute Details
.mode ⇒ Object
Returns the value of attribute mode.
33 34 35 |
# File 'lib/funktor/testing.rb', line 33 def mode @mode end |
Class Method Details
.disable! ⇒ Object
54 55 56 |
# File 'lib/funktor/testing.rb', line 54 def disable! set_mode(:disabled) end |
.fake!(&block) ⇒ Object
50 51 52 |
# File 'lib/funktor/testing.rb', line 50 def fake!(&block) set_mode(:fake, &block) end |
.fake? ⇒ Boolean
39 40 41 |
# File 'lib/funktor/testing.rb', line 39 def fake? mode == :fake end |
.inline!(&block) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/funktor/testing.rb', line 43 def inline!(&block) unless block_given? raise "Funktor inline testing mode can only be called in block form." end set_mode(:inline, &block) end |
.inline? ⇒ Boolean
35 36 37 |
# File 'lib/funktor/testing.rb', line 35 def inline? mode == :inline end |
.set_mode(new_mode, &block) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/funktor/testing.rb', line 58 def set_mode(new_mode, &block) if block_given? original_mode = mode self.mode = new_mode begin yield ensure self.mode = original_mode end else self.mode = new_mode end end |