Class: Savon::SpecHelper::Interface
- Inherits:
-
Object
- Object
- Savon::SpecHelper::Interface
- Defined in:
- lib/savon/mock/spec_helper.rb
Instance Method Summary collapse
- #expectations ⇒ Object
- #expects(operation_name) ⇒ Object
- #mock! ⇒ Object
- #notify(operation_name, builder, globals, locals) ⇒ Object
- #unmock! ⇒ Object
- #verify! ⇒ Object
Instance Method Details
#expectations ⇒ Object
22 23 24 |
# File 'lib/savon/mock/spec_helper.rb', line 22 def expectations @expectations ||= [] end |
#expects(operation_name) ⇒ Object
16 17 18 19 20 |
# File 'lib/savon/mock/spec_helper.rb', line 16 def expects(operation_name) expectation = MockExpectation.new(operation_name) expectations << expectation expectation end |
#mock! ⇒ Object
8 9 10 |
# File 'lib/savon/mock/spec_helper.rb', line 8 def mock! Savon.observers << self end |
#notify(operation_name, builder, globals, locals) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/savon/mock/spec_helper.rb', line 26 def notify(operation_name, builder, globals, locals) expectation = expectations.shift if expectation expectation.actual(operation_name, builder, globals, locals) expectation.verify! expectation.response! else raise ExpectationError, "Unexpected request to the #{operation_name.inspect} operation." end rescue ExpectationError @expectations.clear raise end |
#unmock! ⇒ Object
12 13 14 |
# File 'lib/savon/mock/spec_helper.rb', line 12 def unmock! Savon.observers.clear end |
#verify! ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/savon/mock/spec_helper.rb', line 42 def verify! return if expectations.empty? expectations.each(&:verify!) rescue ExpectationError @expectations.clear raise end |