Sha256: ef1e213d8c1e71ea2f20b29437bfb4eee1b6b92637ba672d774dd389c5f43148

Contents?: true

Size: 963 Bytes

Versions: 3

Compression:

Stored size: 963 Bytes

Contents

require 'net/https'
require 'json'

module Capistrano
  module Ghostinspector
    def self.executeApi(type, test, gi_api_key, domain, rollback)

    	# Determine if we should get results to 
    	# check for any failed tests
		if (rollback == false)
			immediate = "&immediate=1"
		else
			immediate = ""
			puts "* * * Gathering results. This could take a few minutes. * * *"
		end
		
		# Default all tests pass
		passing = true

		# execute the Ghost Inspector API call
		uri = URI("https://api.ghostinspector.com/v1/#{type}/#{test}/execute/?apiKey=#{gi_api_key}&startUrl=http://#{domain}/#{immediate}")
		data = Net::HTTP.get(uri)

		# Check the data returned for failed tests
		if (rollback == true) 
			results = JSON.parse(data)

			if (type == "suite")
				results['data'].each do |testItem|                  
				  passing = testItem['passing']
				end
			else 
				passing = results['data']['passing']
			end

		end

		return passing
		
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capistrano-ghostinspector-0.1.2 lib/capistrano/ghostinspector/api.rb
capistrano-ghostinspector-0.1.1 lib/capistrano/ghostinspector/api.rb
capistrano-ghostinspector-0.1.0 lib/capistrano/ghostinspector/api.rb