Sha256: 6e8d9393bcf2627e2536de5aaf4e22ec96b24f64ccdbde3943b962a62a314f7b

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

module JsTestCore
  module Resources
    class Session < ThinRest::Resource
      class Collection < ThinRest::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

3 entries across 3 versions & 3 rubygems

Version Path
js_spec-0.3.3 vendor/js-test-core/lib/js_test_core/resources/session.rb
js_test_core-0.2.0 lib/js_test_core/resources/session.rb
screw-unit-0.3.3 vendor/js-test-core/lib/js_test_core/resources/session.rb