Class: RunscopeCi::RsTest

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/runscope_ci.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(run) ⇒ RsTest

expects parsed json ‘run’ block from Runscope API response like trigger bucket call



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/runscope_ci.rb', line 56

def initialize(run)
  @status           = run["status"]
  @environment_id   = run["environment_id"]
  @bucket_key       = run["bucket_key"]
  @variables        = run["variables"]
  @agent            = run["agent"]
  @test_name        = run["test_name"]
  @test_id          = run["test_id"]
  @url              = run["url"]
  @region           = run["region"]
  @environment_name = run["environment_name"]
  @test_url         = run["test_url"]
  @test_run_url     = run["test_run_url"]
  @test_run_id      = run["test_run_id"]
end

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def agent
  @agent
end

#assertions_definedObject (readonly)

Returns the value of attribute assertions_defined.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def assertions_defined
  @assertions_defined
end

#assertions_failedObject (readonly)

Returns the value of attribute assertions_failed.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def assertions_failed
  @assertions_failed
end

#assertions_passedObject (readonly)

Returns the value of attribute assertions_passed.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def assertions_passed
  @assertions_passed
end

#bucket_keyObject (readonly)

Returns the value of attribute bucket_key.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def bucket_key
  @bucket_key
end

#environment_idObject (readonly)

Returns the value of attribute environment_id.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def environment_id
  @environment_id
end

#environment_nameObject (readonly)

Returns the value of attribute environment_name.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def environment_name
  @environment_name
end

#finished_atObject (readonly)

Returns the value of attribute finished_at.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def finished_at
  @finished_at
end

#regionObject (readonly)

Returns the value of attribute region.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def region
  @region
end

#requestsObject (readonly)

Returns the value of attribute requests.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def requests
  @requests
end

#requests_executedObject (readonly)

Returns the value of attribute requests_executed.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def requests_executed
  @requests_executed
end

#resultObject

Returns the value of attribute result.



53
54
55
# File 'lib/runscope_ci.rb', line 53

def result
  @result
end

#scripts_definedObject (readonly)

Returns the value of attribute scripts_defined.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def scripts_defined
  @scripts_defined
end

#scripts_failedObject (readonly)

Returns the value of attribute scripts_failed.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def scripts_failed
  @scripts_failed
end

#scripts_passedObject (readonly)

Returns the value of attribute scripts_passed.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def scripts_passed
  @scripts_passed
end

#started_atObject (readonly)

Returns the value of attribute started_at.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def started_at
  @started_at
end

#statusObject (readonly)

Returns the value of attribute status.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def status
  @status
end

#test_idObject (readonly)

Returns the value of attribute test_id.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def test_id
  @test_id
end

#test_nameObject (readonly)

Returns the value of attribute test_name.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def test_name
  @test_name
end

#test_run_idObject (readonly)

Returns the value of attribute test_run_id.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def test_run_id
  @test_run_id
end

#test_run_urlObject (readonly)

Returns the value of attribute test_run_url.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def test_run_url
  @test_run_url
end

#test_urlObject (readonly)

Returns the value of attribute test_url.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def test_url
  @test_url
end

#urlObject (readonly)

Returns the value of attribute url.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def url
  @url
end

#variablesObject (readonly)

Returns the value of attribute variables.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def variables
  @variables
end

#variables_definedObject (readonly)

Returns the value of attribute variables_defined.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def variables_defined
  @variables_defined
end

#variables_failedObject (readonly)

Returns the value of attribute variables_failed.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def variables_failed
  @variables_failed
end

#variables_passedObject (readonly)

Returns the value of attribute variables_passed.



49
50
51
# File 'lib/runscope_ci.rb', line 49

def variables_passed
  @variables_passed
end

Instance Method Details

#result_detailObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/runscope_ci.rb', line 72

def result_detail
  res = self.class.get("/buckets/#{@bucket_key}/tests/#{@test_id}/results/#{@test_run_id}",
    headers: {"Authorization" => "Bearer #{access_token}"})
  raise "Received error #{res.code} #{res.message} #{res.body}" unless res.code == 200
  result = JSON.parse(res.body)["data"]
  
  @started_at         = result["started_at"]
  @finished_at        = result["finished_at"]
  @scripts_defined    = result["scripts_defined"]
  @assertions_failed  = result["assertions_failed"]
  @variables_failed   = result["variables_failed"]
  @variables_passed   = result["variables_passed"]
  @result             = result["result"]
  @requests_executed  = result["requests_executed"]
  @assertions_defined = result["assertions_defined"]
  @assertions_passed  = result["assertions_passed"]
  @scripts_passed     = result["scripts_passed"]
  @scripts_failed     = result["scripts_failed"]
  @variables_defined  = result["variables_defined"]
  @requests           = result["requests"]

  self
end