Module: RSpec::WebserviceMatchers::BeFast
- Defined in:
- lib/rspec/webservice_matchers/be_fast.rb
Class Method Summary collapse
Class Method Details
.page_speed_score(url:) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rspec/webservice_matchers/be_fast.rb', line 15 def self.page_speed_score(url:) url_param = CGI.escape(Util.make_url(url)) key = ENV['WEBSERVICE_MATCHER_INSIGHTS_KEY'] endpoint = 'https://www.googleapis.com/pagespeedonline/v2/runPagespeed' api_url = "#{endpoint}?url=#{url_param}&screenshot=false&key=#{key}" BeFast.parse(json: Excon.get(api_url).body)[:score] end |
.parse(json:) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/rspec/webservice_matchers/be_fast.rb', line 8 def self.parse(json:) response = JSON.parse(json) { score: response['ruleGroups']['SPEED']['score'] } end |