Class: RoxClient::RSpec::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rox-client-rspec/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(server, options = {}) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rox-client-rspec/client.rb', line 6

def initialize server, options = {}

  @server = server
  @publish, @local_mode, @workspace = options[:publish], options[:local_mode], options[:workspace]
  @cache_payload, @print_payload, @save_payload = options[:cache_payload], options[:print_payload], options[:save_payload]
  
  cache_options = { workspace: @workspace }
  cache_options.merge! server_name: @server.name, project_api_id: @server.project_api_id if @server
  @cache = Cache.new cache_options

  @uid = UID.new workspace: @workspace
end

Instance Method Details

#process(test_run) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rox-client-rspec/client.rb', line 19

def process test_run

  return fail "No server to publish results to" if !@server

  test_run.uid = @uid.load_uid

  payload_options = @server.payload_options

  cache_enabled = @cache_payload && load_cache
  payload_options[:cache] = @cache if cache_enabled

  return false unless payload = build_payload(test_run, payload_options)

  published = if !@publish
    puts Paint["ROX - Publishing disabled", :yellow]
    false
  elsif publish_payload payload
    @cache.save test_run if cache_enabled
    true
  else
    false
  end

  save_payload payload if @save_payload
  print_payload payload if @print_payload

  puts

  published
end