Module: Twi::Mocking
- Included in:
- Twi
- Defined in:
- lib/twi/mocking.rb
Instance Method Summary collapse
- #conversation ⇒ Object
- #create_message ⇒ Object
- #create_phone ⇒ Object
- #event ⇒ Object
- #message ⇒ Object
- #mock ⇒ Object
- #phone ⇒ Object
-
#reset_mock ⇒ Object
Forgets every answer arranged so far and starts mocking again from nothing.
Instance Method Details
#conversation ⇒ Object
22 23 24 |
# File 'lib/twi/mocking.rb', line 22 def conversation(...) (@mock ? Mock::Conversation : Conversation).new(...) end |
#create_message ⇒ Object
18 19 20 |
# File 'lib/twi/mocking.rb', line 18 def (...) (...).tap &:create end |
#create_phone ⇒ Object
14 15 16 |
# File 'lib/twi/mocking.rb', line 14 def create_phone(...) phone(...).tap &:create end |
#event ⇒ Object
26 27 28 |
# File 'lib/twi/mocking.rb', line 26 def event(...) (@mock ? Mock::Event : Event).new(...) end |
#message ⇒ Object
34 35 36 |
# File 'lib/twi/mocking.rb', line 34 def (...) (@mock ? Mock::Message : Message).new(...) end |
#phone ⇒ Object
30 31 32 |
# File 'lib/twi/mocking.rb', line 30 def phone(...) (@mock ? Mock::Phone : Phone).new(...) end |
#reset_mock ⇒ Object
Forgets every answer arranged so far and starts mocking again from nothing. A test suite calls this before each test: the mock lives on the module, so without it one test answers for the next.
10 11 12 |
# File 'lib/twi/mocking.rb', line 10 def reset_mock @mock = Twi::Mock.new end |