rspec-webservice_matchers 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -6
- data/lib/rspec/webservice_matchers.rb +9 -0
- data/lib/rspec/webservice_matchers/version.rb +1 -1
- data/spec/rspec/webservice_matchers/redirect_spec.rb +10 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48f108c7a2f1464a81fe94c53ceb24896a7f1283
|
4
|
+
data.tar.gz: 82582ce19e0c6dc81f43ff6fda48bc1460122d89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff3f75d6649f9bf135f354ea5d6e4c37fbd47587c42d119e3a5f0e6339c03307157d33d029fa8eb91bc8bcb3fa742b82fa9c553520ae19d0ae7844fe3d56706b
|
7
|
+
data.tar.gz: 081c289463249f98ec1ba04d1f44fa2eae0f68e262b3cf19e982953c3a5dc2dc818353922272c4e553bfcc4950372baee820a28ac4b693e718c177fadb0b9bd2
|
data/README.md
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
This [gem](https://rubygems.org/gems/rspec-webservice_matchers) enables you to black-box test a web app's server configuration. For example, whether its SSL certificate is correctly configured and not expired. It's a tool for doing **Test Driven Devops**. (I just made that up.)
|
4
4
|
|
5
|
-
This library takes a very minimalist approach:
|
6
|
-
you can use your own RSpec writing style; no new DSL to learn.
|
5
|
+
This library takes a very minimalist approach: it simply adds new RSpec matchers,
|
6
|
+
and so you can use your own RSpec writing style; there's no new DSL to learn.
|
7
7
|
|
8
8
|
Installation
|
9
9
|
------------
|
@@ -16,9 +16,14 @@ What You Get
|
|
16
16
|
These new RSpec matchers:
|
17
17
|
|
18
18
|
* `be_status`
|
19
|
-
* `have_a_valid_cert`
|
20
|
-
|
21
|
-
* `
|
19
|
+
* `have_a_valid_cert`
|
20
|
+
Uses lib-curl to test validity
|
21
|
+
* `enforce_https_everywhere`
|
22
|
+
See [EFF](https://www.eff.org/https-everywhere)
|
23
|
+
* `redirect_permanently_to`
|
24
|
+
Allows 301
|
25
|
+
* `redirect_temporarily_to`
|
26
|
+
Allows 302 or 307
|
22
27
|
|
23
28
|
|
24
29
|
Example
|
@@ -46,7 +51,7 @@ end
|
|
46
51
|
|
47
52
|
TODO
|
48
53
|
----
|
49
|
-
* Matchers for more high-level cases
|
54
|
+
* Matchers for more high-level cases
|
50
55
|
* Matchers for JSON schema
|
51
56
|
* More matchers refactored from [weblaws.org](http://www.weblaws.org/) code
|
52
57
|
|
@@ -40,6 +40,15 @@ module RSpec
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
# Pass successfully if we get a 302 or 307 to the place we intend.
|
44
|
+
RSpec::Matchers.define :redirect_temporarily_to do |expected|
|
45
|
+
match do |url|
|
46
|
+
result = Curl::Easy.http_head(url)
|
47
|
+
headers = RSpec::WebserviceMatchers.parse_response_headers(result)
|
48
|
+
[302, 307].include?(result.response_code) && headers['Location'] == expected
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
43
52
|
# This is a high level matcher which checks three things:
|
44
53
|
# 1. Permanent redirect
|
45
54
|
# 2. to an https url
|
@@ -1,9 +1,18 @@
|
|
1
1
|
require 'rspec/webservice_matchers'
|
2
2
|
|
3
|
+
#
|
4
|
+
# TODO: Set up a server for these. (Or a mock?)
|
5
|
+
#
|
3
6
|
describe 'redirect_permanently_to' do
|
4
7
|
it 'passes when receiving a 301 to the given URL' do
|
5
|
-
# TODO: Set up a server for this. (Or a mock?)
|
6
8
|
expect('http://weblaws.org').to redirect_permanently_to('http://www.weblaws.org/')
|
7
9
|
end
|
8
10
|
end
|
9
11
|
|
12
|
+
describe 'redirect_temporarily_to' do
|
13
|
+
it 'passes when it gets a 302' do
|
14
|
+
'http://www.oregonlaws.org/cms/about_us'.should redirect_temporarily_to 'http://www.weblaws.org/cms/about_us'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'passes when it gets a 307'
|
18
|
+
end
|