Sha256: d570a4a6ab647c10edf1eb6b1e1da8f70a447e7fb6af52a6465e31426e038c8e

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

module JsTestCore
  module Resources
    class Session < Resources::Resource
      class Collection < Resources::Resource
        route ANY do |env, id|
          Session.new(env.merge(:id => id))
        end
      end

      RUNNING = 'running'
      SUCCESSFUL_COMPLETION = 'success'
      FAILURE_COMPLETION = 'failure'

      property :id

      def get
        runner = Runner.find(id)
        if runner
          connection.send_head
          if runner.running?
            connection.send_body("status=#{RUNNING}")
          else
            if runner.successful?
              connection.send_body("status=#{SUCCESSFUL_COMPLETION}")
            else
              connection.send_body("status=#{FAILURE_COMPLETION}&reason=#{runner.session_run_result}")
            end
          end
        else
          connection.send_head(404)
          connection.send_body("")
        end
      end

      route 'finish' do |env, name|
        SessionFinish.new(env.merge(:session => self))
      end

      def associated_with_a_runner?
        id.to_s != ""
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pivotal-screw-unit-0.4.0 vendor/js-test-core/lib/js_test_core/resources/session.rb
pivotal-screw-unit-0.4.1 vendor/js-test-core/lib/js_test_core/resources/session.rb
pivotal-screw-unit-0.4.2 vendor/js-test-core/lib/js_test_core/resources/session.rb
pivotal-screw-unit-0.4.3 vendor/js-test-core/lib/js_test_core/resources/session.rb