rspec-webservice_matchers 1.2.2 → 1.3.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/.travis.yml +2 -1
- data/lib/rspec/webservice_matchers.rb +13 -5
- data/lib/rspec/webservice_matchers/version.rb +1 -1
- data/spec/rspec/webservice_matchers/redirect_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10271047f0647b3f8bf5aeafbe665214615807f3
|
4
|
+
data.tar.gz: 8ad50cfcf15f9b85b528301fe04daf34e0f29b58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 920c4cf683f0c68f552ad8b4cc3d03eb6ad9253d44c97e094f0e8047b313906bd61b254f5e69730199a01f2e327c50f01ee618a96b39643a112dc89b380b3bf3
|
7
|
+
data.tar.gz: 23e9d8e71ed8c1915071cc37e9061ec9627f372917eb06de06fdc149ff60fc72d30ab52cf7910232512a1cab2f7cc9ee6d7f02274becb64fe5c3968af8a57cdb
|
data/.travis.yml
CHANGED
@@ -39,17 +39,25 @@ module RSpec
|
|
39
39
|
|
40
40
|
# Pass successfully if we get a 301 to the place we intend.
|
41
41
|
RSpec::Matchers.define :redirect_permanently_to do |expected|
|
42
|
-
match do |
|
43
|
-
response = RSpec::WebserviceMatchers.connection.head(
|
44
|
-
|
42
|
+
match do |url_or_domain_name|
|
43
|
+
response = RSpec::WebserviceMatchers.connection.head(RSpec::WebserviceMatchers.make_url url_or_domain_name)
|
44
|
+
expected = RSpec::WebserviceMatchers.make_url(expected)
|
45
|
+
actual = response.headers['location']
|
46
|
+
status = response.status
|
47
|
+
|
48
|
+
(status == 301) && (%r|#{expected}/?| === actual)
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
48
52
|
# Pass successfully if we get a 302 or 307 to the place we intend.
|
49
53
|
RSpec::Matchers.define :redirect_temporarily_to do |expected|
|
50
54
|
match do |url|
|
51
|
-
response = RSpec::WebserviceMatchers.connection.head(url)
|
52
|
-
|
55
|
+
response = RSpec::WebserviceMatchers.connection.head(RSpec::WebserviceMatchers.make_url(url))
|
56
|
+
expected = RSpec::WebserviceMatchers.make_url(expected)
|
57
|
+
actual = response.headers['location']
|
58
|
+
status = response.status
|
59
|
+
|
60
|
+
[302, 307].include?(status) && (%r|#{expected}/?| === actual)
|
53
61
|
end
|
54
62
|
end
|
55
63
|
|
@@ -10,12 +10,23 @@ describe 'redirect_permanently_to' do
|
|
10
10
|
expect('http://weblaws.org').to redirect_permanently_to('http://www.weblaws.org/')
|
11
11
|
expect('http://www.getquisitive.com/press-kit/').to redirect_permanently_to 'http://getquisitive.com/press-kit/'
|
12
12
|
end
|
13
|
+
|
14
|
+
it 'handles domain names gracefully' do
|
15
|
+
expect('weblaws.org').to redirect_permanently_to('www.weblaws.org/')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'handles missing final slash' do
|
19
|
+
expect('weblaws.org').to redirect_permanently_to('www.weblaws.org')
|
20
|
+
end
|
13
21
|
end
|
14
22
|
|
23
|
+
|
15
24
|
describe 'redirect_temporarily_to' do
|
16
25
|
it 'passes when it gets a 302' do
|
17
26
|
'http://www.oregonlaws.org/cms/about_us'.should redirect_temporarily_to 'http://www.weblaws.org/cms/about_us'
|
18
27
|
end
|
19
28
|
|
29
|
+
# TODO: Set up the mock server and test these
|
30
|
+
it 'handles domain names gracefully'
|
20
31
|
it 'passes when it gets a 307'
|
21
32
|
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: 1.
|
4
|
+
version: 1.3.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: 2014-
|
11
|
+
date: 2014-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|