rspec-webservice_matchers 4.4.3 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10922f68985209c2dfb8f08ff3a6269ce8724b4c
4
- data.tar.gz: 4cca8e7182f75db36d5a3acb005cf203a39dc1df
3
+ metadata.gz: a2c6cf504ff19bde93e91498bd7e392ef410b94c
4
+ data.tar.gz: c2803564cafe83bda06abc3a195e1723e6185d22
5
5
  SHA512:
6
- metadata.gz: e3752edb32f97200ab11577f196986c732f96987652d93dd4b2e29ad96e931d31e5e8f0cf81781f0bb9c6311c4cc91f0f4b7c067256c6852d6d265ab3649526a
7
- data.tar.gz: be33eefe6233553fd30fec273a086b1aea04d798d9e01b60004f42a905cc30204682ac988ef88476f678c584c0fed2c063403de3c816c7581f94daf3bf0e11af
6
+ metadata.gz: 1c6bd1e678ed71303bbc8e6a6396870268195b8a41889656f1a5f5c17088f6a11cd8ddc8daeb86e27d9c7446668d01704baff79abae46245432d06e666729ab8
7
+ data.tar.gz: 3a49f67bf48853a73b47b6f71d2f6e5eee6d43590caad741303e6dbc7216e0f7fdc7cdf591741808cc8e2dc76d7155febd0acc30b0c097d2b528ff66c27155f2
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ 4.5.0
2
+ -----
3
+ Removed the Excon dependency entirely.
4
+
1
5
  4.4.3
2
6
  -----
3
7
  Changed the Google PageSpeed Insights threshold to 85, the value for
data/README.md CHANGED
@@ -9,11 +9,13 @@ A [gem](https://rubygems.org/gems/rspec-webservice_matchers) to black-box test a
9
9
  expect('github.com').to have_a_valid_cert
10
10
  ```
11
11
 
12
- It's a tool for doing **Test Driven Devops** (I just made that up). See [the introductory blog post](http://robb.weblaws.org/2014/01/16/new-open-source-library-for-test-driven-devops/) for more about my motivations.
12
+ It's a tool for doing **Test Driven Devops** (I just made that up). See [the introductory blog post](http://robb.weblaws.org/2014/01/16/new-open-source-library-for-test-driven-devops/) for the backstory and [Nonstop QA - a SaaS built on it](https://nonstop.qa).
13
13
 
14
14
  This library takes a minimalist approach: it simply adds new RSpec matchers. Therefore, you can use your own RSpec writing style; there's no new DSL to learn.
15
15
 
16
- If you're too busy to install this and code the tests by hand, you can try the [new hosted service which runs these RSpec matchers in the cloud](http://nonstop.qa).
16
+ If you're too busy to install this and code the tests by hand, you can try the [new hosted service which runs these RSpec matchers in the cloud](http://nonstop.qa): [![QA Status](http://nonstop.qa/projects/20/badges/default.svg)](http://nonstop.qa/projects/20-nonstop-qa)
17
+
18
+
17
19
 
18
20
 
19
21
  Installation
@@ -29,7 +31,7 @@ These new RSpec matchers:
29
31
  | Notes
30
32
  -------------------------------|------------------------------------------------
31
33
  **be_up** | Looks for a 200, but will follow up to four redirects
32
- **be_fast** | Checks for Google [PageSpeed](https://developers.google.com/speed/pagespeed/insights/) score >= 90. Expects the environment variable `WEBSERVICE_MATCHER_INSIGHTS_KEY` to contain a [Google "server" API key](https://developers.google.com/speed/docs/insights/v2/getting-started) with PageSpeed Insights API enabled.
34
+ **be_fast** | Checks for Google [PageSpeed](https://developers.google.com/speed/pagespeed/insights/) score >= 85. Expects the environment variable `WEBSERVICE_MATCHER_INSIGHTS_KEY` to contain a [Google "server" API key](https://developers.google.com/speed/docs/insights/v2/getting-started) with PageSpeed Insights API enabled.
33
35
  **enforce_https_everywhere** | Passes if the site will _only_ allow SSL connections. See the [EFF project, HTTPS Everywhere](https://www.eff.org/https-everywhere)
34
36
  **have_a_valid_cert** | Will fail if there's no cert, or it's expired or incorrectly configured
35
37
  **be_status** | A low-level matcher to explicitly check for a 200, 503, or any other code
@@ -7,22 +7,25 @@ module RSpec
7
7
  module BeFast
8
8
  def self.parse(json:)
9
9
  response = JSON.parse(json)
10
- {
11
- score: response['ruleGroups']['SPEED']['score']
12
- }
10
+ unless response.key?('ruleGroups')
11
+ raise "Couldn't parse the PageSpeed response: #{response.inspect}"
12
+ end
13
+ score = response.fetch('ruleGroups').fetch('SPEED').fetch('score')
14
+ { score: score }
13
15
  end
14
16
 
15
17
  def self.page_speed_score(url:)
16
18
  url_param = CGI.escape(Util.make_url(url))
17
19
  key = ENV['WEBSERVICE_MATCHER_INSIGHTS_KEY']
18
20
  if key.nil?
19
- fail 'be_fast requires the WEBSERVICE_MATCHER_INSIGHTS_KEY '\
20
- 'environment variable to be set to a Google PageSpeed '\
21
- 'Insights API key.'
21
+ raise 'be_fast requires the WEBSERVICE_MATCHER_INSIGHTS_KEY '\
22
+ 'environment variable to be set to a Google PageSpeed '\
23
+ 'Insights API key.'
22
24
  end
23
25
  endpoint = 'https://www.googleapis.com/pagespeedonline/v2/runPagespeed'
24
26
  api_url = "#{endpoint}?url=#{url_param}&screenshot=false&key=#{key}"
25
- BeFast.parse(json: Excon.get(api_url).body)[:score]
27
+ response = Faraday.get(api_url)
28
+ BeFast.parse(json: response.body).fetch(:score)
26
29
  end
27
30
 
28
31
  RSpec::Matchers.define :be_fast do
@@ -1,4 +1,3 @@
1
- require 'excon'
2
1
  require 'faraday'
3
2
  require 'faraday_middleware'
4
3
 
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module WebserviceMatchers
3
- VERSION = '4.4.3'
3
+ VERSION = '4.5.0'
4
4
  end
5
5
  end
@@ -25,7 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'webmock'
26
26
 
27
27
  spec.add_runtime_dependency 'rspec', '~> 3.0'
28
- spec.add_runtime_dependency 'excon'
29
28
  spec.add_runtime_dependency 'faraday'
30
29
  spec.add_runtime_dependency 'faraday_middleware'
31
30
  end
@@ -16,8 +16,8 @@ describe RSpec::WebserviceMatchers::BeFast do
16
16
  end
17
17
 
18
18
  describe '#be_fast' do
19
- it 'performs a Google PageSpeed Insights API query on a slow site' do
20
- expect('nonstop.qa').not_to be_fast
19
+ it 'performs a Google PageSpeed Insights API query on a fast site' do
20
+ expect('nonstop.qa').to be_fast
21
21
  end
22
22
 
23
23
  it 'raises a friendly error if the api key has not been set' do
data/spec/spec_helper.rb CHANGED
@@ -26,12 +26,8 @@ RSpec.configure do |config|
26
26
 
27
27
  # Insights API
28
28
  key = ENV['WEBSERVICE_MATCHER_INSIGHTS_KEY']
29
- WebMock.stub_request(:get, "https://www.googleapis.com/pagespeedonline/v2/runPagespeed?key=#{key}&screenshot=false&url=http://nonstop.qa")
30
- .with(headers:
31
- {
32
- 'Host' => 'www.googleapis.com:443',
33
- 'User-Agent' => 'excon/0.45.4'
34
- })
29
+ WebMock.stub_request(:get, "https://www.googleapis.com/pagespeedonline/v2/runPagespeed?key=#{key}&screenshot=false&url=http://nonstop.qa").
30
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.2'})
35
31
  .to_return(
36
32
  status: 200,
37
33
  body: IO.read('spec/fixtures/pagespeed.json'),
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-webservice_matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.3
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-01 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
- - !ruby/object:Gem::Dependency
84
- name: excon
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: faraday
99
85
  requirement: !ruby/object:Gem::Requirement