Class: Fakettp::Simulator
- Inherits:
-
Object
- Object
- Fakettp::Simulator
- Defined in:
- lib/fakettp/simulator.rb
Class Method Summary collapse
- .<<(expectation) ⇒ Object
- .handle_request(binding) ⇒ Object
- .list_errors ⇒ Object
- .reset ⇒ Object
- .verify ⇒ Object
Class Method Details
.<<(expectation) ⇒ Object
16 17 18 |
# File 'lib/fakettp/simulator.rb', line 16 def self.<< expectation Expectation.create! :contents => expectation end |
.handle_request(binding) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fakettp/simulator.rb', line 20 def self.handle_request binding expectation = Expectation.next if expectation begin expectation.execute binding rescue Fakettp::Expectation::Error => e expectation.errors.create :message => e., :line_number => e.line_number raise e end else Error.create! :message => 'Received unexpected request' raise Expectation::Error.new('Received unexpected request') end end |
.list_errors ⇒ Object
35 36 37 |
# File 'lib/fakettp/simulator.rb', line 35 def self.list_errors Error.list end |
.reset ⇒ Object
6 7 8 9 |
# File 'lib/fakettp/simulator.rb', line 6 def self.reset Expectation.delete_all Error.delete_all end |
.verify ⇒ Object
11 12 13 14 |
# File 'lib/fakettp/simulator.rb', line 11 def self.verify Error.create!(:message => 'Expected request not received') unless Expectation.all_received? return !Error.exists? end |