rspec-webservice_matchers 0.2.0 → 1.0.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: f213b57f745129ca27f161fafab51468beec886c
4
- data.tar.gz: 8e9a30715b9de34263e66db6f4776caed4fd6418
3
+ metadata.gz: 48f108c7a2f1464a81fe94c53ceb24896a7f1283
4
+ data.tar.gz: 82582ce19e0c6dc81f43ff6fda48bc1460122d89
5
5
  SHA512:
6
- metadata.gz: dc69ca69ee807788b27af421a90088f6b0f3c4cd14126a215e58c2bd6bb66d7882225d1b7c3399e54d8e8cf720070f24f7fd7e63371dc6b477a32eac6695fddd
7
- data.tar.gz: 17301939ab8f4cc7ffacd7b53cfd55880074285c56663f90eb0d4b97a4308b155159dd26d85119a3d9a64afa51d915f8b1b87c419581d79aaf3442353f53e821
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: by simply adding new RSpec matchers,
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
- * `enforce_https_everywhere` (See [EFF](https://www.eff.org/https-everywhere))
21
- * `redirect_permanently_to`
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, such as the two kinds of temp. redirect
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,5 +1,5 @@
1
1
  module RSpec
2
2
  module WebserviceMatchers
3
- VERSION = "0.2.0"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-webservice_matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter