Class: CBTRUBY::CbtClient::ScreenshotTest
- Inherits:
-
Object
- Object
- CBTRUBY::CbtClient::ScreenshotTest
- 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
- #begin ⇒ Object
-
#format_params ⇒ Object
Format parameters for passing on.
-
#initialize(client:, params:, block: true) ⇒ ScreenshotTest
constructor
Set up the screenshot test.
-
#wait_for_finish ⇒ Object
Block until test is finished.
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
#begin ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cbt_ruby/screenshot_test.rb', line 29 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 @info.request end |
#format_params ⇒ Object
Format parameters for passing on
21 22 23 24 25 26 27 |
# File 'lib/cbt_ruby/screenshot_test.rb', line 21 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_finish ⇒ Object
Block until test is finished
41 42 43 44 45 46 |
# File 'lib/cbt_ruby/screenshot_test.rb', line 41 def wait_for_finish while @running sleep 15 @running = @info.running end end |