Class: CBTRUBY::CbtClient::ScreenshotTest

Inherits:
Object
  • Object
show all
Defined in:
lib/cbt_ruby/screenshot_test.rb

Overview

Provides a simple interface to the CBT API for performing screenshot tests

Instance Method Summary collapse

Constructor Details

#initialize(client:, params:, block: true) ⇒ ScreenshotTest

Set up the screenshot test



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cbt_ruby/screenshot_test.rb', line 8

def initialize(client:, params:, block: true)
  @input_params = params
  # puts @input_params[:url]
  @params = @input_params
  format_params
  # puts @params[:browsers]
  @client = client
  @block = block

  self.begin
end

Instance Method Details

#beginObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/cbt_ruby/screenshot_test.rb', line 28

def begin
  @test = @client.basic_request(url: 'screenshots', reqMethod: POST, data: @params)
  puts @test
  @info = CBTRUBY::CbtClient::ScreenshotInfo.new(client: @client, session: @test['screenshot_test_id'])
  if @block
    @running = true
    wait_for_finish
  end
  return @info.request
end

#format_paramsObject



20
21
22
23
24
25
26
# File 'lib/cbt_ruby/screenshot_test.rb', line 20

def format_params
  @params[:browsers] = @params[:browsers].to_s if @params[:browsers]

  if @params[:email_list]
    @params[:email_list] = @params[:email_list].join(',')
  end
end

#wait_for_finishObject



39
40
41
42
43
44
# File 'lib/cbt_ruby/screenshot_test.rb', line 39

def wait_for_finish
  while @running
    sleep 15
    @running = @info.running
  end
end