Class: EventMachine::HttpTest::TestRunner
- Inherits:
-
Object
- Object
- EventMachine::HttpTest::TestRunner
- Includes:
- EM::Deferrable
- Defined in:
- lib/em-http-test/test-runner.rb
Instance Method Summary collapse
- #abort ⇒ Object
- #handleResponse(r) ⇒ Object
-
#initialize(f) ⇒ TestRunner
constructor
A new instance of TestRunner.
-
#process ⇒ Object
Run a step of the test by calling the test generated URL and submitting the results to be processed.
Constructor Details
#initialize(f) ⇒ TestRunner
Returns a new instance of TestRunner.
14 15 16 17 18 19 |
# File 'lib/em-http-test/test-runner.rb', line 14 def initialize(f) @fiber = f @testreq = @fiber.resume # first call, so no data to test @running = true process end |
Instance Method Details
#abort ⇒ Object
21 22 23 |
# File 'lib/em-http-test/test-runner.rb', line 21 def abort @running = false end |
#handleResponse(r) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/em-http-test/test-runner.rb', line 40 def handleResponse(r) if r.response_header.status >= 400 self.fail("HTTP error #{r.response_header.status} calling #{r.last_effective_url}") return end begin @testreq = @fiber.resume r case when @testreq.nil? self.succeed("Test is done") else self.process end rescue TestFailure => e self.fail(e.) end end |
#process ⇒ Object
Run a step of the test by calling the test generated URL and submitting the results to be processed
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/em-http-test/test-runner.rb', line 27 def process unless @fiber.alive? and @running # if the fiber has completed, then we succeeded self.succeed() return end # do another run request = @testreq.toRequest request.errback { |r| self.handleResponse(r) } request.callback { |r| self.handleResponse(r) } end |