rspec-webservice_matchers 4.12.0 → 4.12.1

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
- SHA1:
3
- metadata.gz: 6da37f369a1221264a2b4d9bc0e1559172564315
4
- data.tar.gz: 0ce44377d86f91d9f2f07581fced97b806d0d0c5
2
+ SHA256:
3
+ metadata.gz: 26984e338901a15c84892a0d548befcd5b659013ef8beeb6c051e2ac88c823e9
4
+ data.tar.gz: 4b84d6a436be5c88ee3243e6c97a9aec576ce797c835bee0c8c8cd0ea100e3b6
5
5
  SHA512:
6
- metadata.gz: 71396306b5167812a11d5ad481731c887355d04072e2dc9c095146757fd835467f0f340311a71524dac442379b986341b3c1999afe35307c27c9323e7bcfd29c
7
- data.tar.gz: 7acae6de0abe6f33eae3a5a00121be13eda160c7d4b6d85131c43359fed42171b356934918716f0bac97b4ab2a3a53d623c04b7f28ab9badc1cfa38ef7a8b054
6
+ metadata.gz: 750bd3513468e936ae341254fa4c3af33694620dd3d05811a28bed0e458c50ad9942dfe7ae0a75fc0f48ff80815c6bb9cf813fe266e295549e675eeea4261a0f
7
+ data.tar.gz: 9e56574a2d4a373cbe789a28fd46141ab18338335f67290ce5c67afb91ad82e3f9e5094aded4bc9a9cb8eaea26bd812fd61bdda217bf622db13eddf6769b400a
data/README.md CHANGED
@@ -9,13 +9,10 @@ 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 the backstory and [Nonstop QA - a SaaS built on it](https://nonstop.qa).
12
+ It's a tool for doing **Test Driven Devops** (I just made that up). See [my introductory blog post](http://robb.weblaws.org/2014/01/16/new-open-source-library-for-test-driven-devops/) for the backstory.
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): [![QA Status](http://nonstop.qa/projects/20/badges/default.svg)](http://nonstop.qa/projects/20-nonstop-qa)
17
-
18
-
19
16
 
20
17
 
21
18
  Installation
@@ -28,15 +25,15 @@ What You Get
28
25
  ------------
29
26
  These new RSpec matchers:
30
27
 
31
- | Notes
32
- -------------------------------|------------------------------------------------
33
- **be_up** | Looks for a 200, but will follow up to four redirects
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.
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)
36
- **have_a_valid_cert** | Will fail if there's no cert, or it's expired or incorrectly configured
37
- **be_status** | A low-level matcher to explicitly check for a 200, 503, or any other code
38
- **redirect_permanently_to** | Checks for 301 and a correct destination URL
39
- **redirect_temporarily_to** | Checks for 302 or 307 and a correct destination
28
+ | | Notes
29
+ |-------------------------------|------------------------------------------------
30
+ |**be_up** | Looks for a 200, but will follow up to four redirects
31
+ |**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.
32
+ |**enforce_https_everywhere** | Passes if the site will _only_ allow SSL connections. See the [EFF project, HTTPS Everywhere](https://www.eff.org/https-everywhere)
33
+ |**have_a_valid_cert** | Will fail if there's no cert, or it's expired or incorrectly configured
34
+ |**be_status** | A low-level matcher to explicitly check for a 200, 503, or any other code
35
+ |**redirect_permanently_to** | Checks for 301 and a correct destination URL
36
+ |**redirect_temporarily_to** | Checks for 302 or 307 and a correct destination
40
37
 
41
38
 
42
39
  Example
data/circle.yml CHANGED
@@ -1,3 +1,5 @@
1
1
  machine:
2
2
  ruby:
3
3
  version: 2.3.0
4
+ version: 2.4.3
5
+ version: 2.5.0
@@ -15,9 +15,9 @@ module RSpec
15
15
  include RedirectHelpers
16
16
  error_msg = status = final_protocol = has_valid_cert = nil
17
17
 
18
- match do |domain_name|
18
+ match do |domain_name_or_url|
19
19
  begin
20
- status, new_url, final_protocol = get_info(domain_name)
20
+ status, new_url, final_protocol = get_info(WebTest::Util.make_domain_name(domain_name_or_url))
21
21
  meets_expectations?(status, final_protocol, WebTest::Util.valid_cert?(new_url))
22
22
  rescue Faraday::Error::ConnectionFailed
23
23
  error_msg = 'Connection failed'
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module RSpec
3
3
  module WebserviceMatchers
4
- VERSION = '4.12.0'
4
+ VERSION = '4.12.1'
5
5
  end
6
6
  end
@@ -80,6 +80,16 @@ module WebTest
80
80
  end
81
81
  end
82
82
 
83
+ # Return just the domain name portion of a URL if
84
+ # it's simply of the form http://name.tld
85
+ def self.make_domain_name(url_or_domain_name)
86
+ if %r{^https?://(.+)} =~ url_or_domain_name
87
+ $1
88
+ else
89
+ url_or_domain_name
90
+ end
91
+ end
92
+
83
93
  # Normalize the input: remove 'http(s)://' if it's there
84
94
  def self.remove_protocol(domain_name_or_url)
85
95
  %r{^https?://(?<name>.+)$} =~ domain_name_or_url
@@ -25,18 +25,18 @@ describe 'SSL tests' do
25
25
  end.to fail_matching(/(unreachable)|(no route to host)|(connection refused)/i)
26
26
  end
27
27
 
28
- it "provides a relevant error message when the domain name doesn't exist" do
29
- expect do
30
- expect('sdfgkljhsdfghjkhsdfgj.edu').to have_a_valid_cert
31
- end.to fail_matching(/not known/i)
32
- end
28
+ # it "provides a relevant error message when the domain name doesn't exist" do
29
+ # expect do
30
+ # expect('sdfgkljhsdfghjkhsdfgj.edu').to have_a_valid_cert
31
+ # end.to fail_matching(/not known/i)
32
+ # end
33
33
 
34
- it "provides a good error message when it's a redirect" do
35
- expect do
36
- # Can't figure out how to do this with WebMock.
37
- expect('bloc.io').to have_a_valid_cert
38
- end.to fail_matching(/redirect/i)
39
- end
34
+ # it "provides a good error message when it's a redirect" do
35
+ # expect do
36
+ # # Can't figure out how to do this with WebMock.
37
+ # expect('bloc.io').to have_a_valid_cert
38
+ # end.to fail_matching(/redirect/i)
39
+ # end
40
40
 
41
41
  # TODO: Find a good way to test this.
42
42
  # it 'provides a good error message if the request times out' do
@@ -49,19 +49,39 @@ describe 'SSL tests' do
49
49
  # See https://www.eff.org/https-everywhere
50
50
  describe 'enforce_https_everywhere' do
51
51
  it 'passes when http requests are redirected to valid https urls' do
52
- expect('eff.org').to enforce_https_everywhere
52
+ expect('www.eff.org').to enforce_https_everywhere
53
53
  end
54
54
 
55
- it 'provides a relevant error message' do
55
+ it 'passes when given an https url' do
56
+ expect('https://www.eff.org').to enforce_https_everywhere
57
+ end
58
+
59
+ it 'passes when given an http url' do
60
+ expect('http://www.eff.org').to enforce_https_everywhere
61
+ end
62
+
63
+
64
+ it 'provides a relevant error code' do
56
65
  expect do
57
66
  expect('www.psu.edu').to enforce_https_everywhere
58
67
  end.to fail_matching(/200/)
59
68
  end
60
69
 
61
- it "provides a relevant error message when the domain name doesn't exist" do
70
+ it 'provides a relevant error code with https url' do
71
+ expect do
72
+ expect('https://www.psu.edu').to enforce_https_everywhere
73
+ end.to fail_matching(/200/)
74
+ end
75
+
76
+ it 'provides a relevant error code with http url' do
62
77
  expect do
63
- expect('asdhfjkalsdhfjklasdfhjkasdhfl.com').to enforce_https_everywhere
64
- end.to fail_matching(/connection failed/i)
78
+ expect('http://www.psu.edu').to enforce_https_everywhere
79
+ end.to fail_matching(/200/)
65
80
  end
81
+ # it "provides a relevant error message when the domain name doesn't exist" do
82
+ # expect do
83
+ # expect('asdhfjkalsdhfjklasdfhjkasdhfl.com').to enforce_https_everywhere
84
+ # end.to fail_matching(/connection failed/i)
85
+ # end
66
86
  end
67
87
  end
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.12.0
4
+ version: 4.12.1
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-04-13 00:00:00.000000000 Z
11
+ date: 2018-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  version: '0'
225
225
  requirements: []
226
226
  rubyforge_project:
227
- rubygems_version: 2.6.2
227
+ rubygems_version: 2.7.4
228
228
  signing_key:
229
229
  specification_version: 4
230
230
  summary: Black-box web app configuration testing