Class: Belly::Client::HubProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/belly/client/hub_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ HubProxy

Returns a new instance of HubProxy.



7
8
9
# File 'lib/belly/client/hub_proxy.rb', line 7

def initialize(config)
  @config = config
end

Instance Method Details

#around_request(&block) ⇒ Object



30
31
32
# File 'lib/belly/client/hub_proxy.rb', line 30

def around_request(&block)
  @around_request_block = block
end

#get_failing_scenarios_for_project_named(project_name) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/belly/client/hub_proxy.rb', line 15

def get_failing_scenarios_for_project_named(project_name)
  project_id = get_project_id_by_name(project_name)
  rerun_statuses = [:pending, :undefined, :failed]
  status_querystring = rerun_statuses.map { |s| "status[]=#{s}"}.join("&")
  response = request(:get, "/projects/#{project_id}/cucumber_scenarios.json?#{status_querystring}")
  JSON.parse(response)["cucumber_scenarios"]
end

#get_project_id_by_name(project_name) ⇒ Object

Raises:



23
24
25
26
27
28
# File 'lib/belly/client/hub_proxy.rb', line 23

def get_project_id_by_name(project_name)
  response = request(:get, "/projects.json?name=#{project_name}")
  projects = JSON.parse(response)["projects"]
  raise NoSuchProjectError unless projects.any?
  projects.first["id"].to_i
end

#post_test_result(json_data) ⇒ Object



11
12
13
# File 'lib/belly/client/hub_proxy.rb', line 11

def post_test_result(json_data)
  request(:post, '/test_results', json_data, :content_type => :json)
end