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 +4 -4
- data/HISTORY.md +4 -0
- data/README.md +5 -3
- data/lib/rspec/webservice_matchers/be_fast.rb +10 -7
- data/lib/rspec/webservice_matchers/util.rb +0 -1
- data/lib/rspec/webservice_matchers/version.rb +1 -1
- data/rspec-webservice_matchers.gemspec +0 -1
- data/spec/rspec/webservice_matchers/page_speed_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -6
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2c6cf504ff19bde93e91498bd7e392ef410b94c
|
4
|
+
data.tar.gz: c2803564cafe83bda06abc3a195e1723e6185d22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c6bd1e678ed71303bbc8e6a6396870268195b8a41889656f1a5f5c17088f6a11cd8ddc8daeb86e27d9c7446668d01704baff79abae46245432d06e666729ab8
|
7
|
+
data.tar.gz: 3a49f67bf48853a73b47b6f71d2f6e5eee6d43590caad741303e6dbc7216e0f7fdc7cdf591741808cc8e2dc76d7155febd0acc30b0c097d2b528ff66c27155f2
|
data/HISTORY.md
CHANGED
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
|
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 >=
|
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
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
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
|
@@ -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
|
20
|
-
expect('nonstop.qa').
|
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
|
-
|
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
|
+
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-
|
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
|