check_http_response 0.0.1 → 0.0.2
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.
- data/ChangeLog.markdown +7 -0
- data/README.md +1 -1
- data/lib/check_http_response/request.rb +5 -4
- data/lib/check_http_response/version.rb +1 -1
- metadata +7 -6
data/ChangeLog.markdown
ADDED
data/README.md
CHANGED
@@ -10,4 +10,4 @@
|
|
10
10
|
response.redirects_to?("http://www.mydomain.com/page1") #=> true
|
11
11
|
|
12
12
|
response.redirects_to?("http://nowhere.com/page2") #=> false
|
13
|
-
response.errors #=> { :redirect => "Wrong location" }
|
13
|
+
response.errors #=> { :redirect => "Wrong location! Got: http://www.mydomain.com/page1 , expected: "http://nowhere.com/page2" }
|
@@ -27,7 +27,7 @@ module CheckHttpResponse
|
|
27
27
|
# response.redirects_to?('http://www.mydomain.com/page/1/index.html') #=> true
|
28
28
|
#
|
29
29
|
# response.redirects_to?('http://nowhere.com/') #=> false
|
30
|
-
# response.errors #=> { :redirect => "Wrong location" }
|
30
|
+
# response.errors #=> { :redirect => "Wrong location! Got: http://www.mydomain.com/page/1/index.html , expected: http://nowhere.com/" }
|
31
31
|
#
|
32
32
|
# ==== Options
|
33
33
|
# <tt>:permanent</tt> Specifies whether the redirect should be 'permanent', default: true
|
@@ -46,7 +46,8 @@ module CheckHttpResponse
|
|
46
46
|
|
47
47
|
@errors[:base] = "No redirect initiated"
|
48
48
|
rescue HTTParty::RedirectionTooDeep => e
|
49
|
-
|
49
|
+
redirected_location = e.response['location']
|
50
|
+
is_correct_location = location == redirected_location
|
50
51
|
|
51
52
|
is_correct_redirect = if check_permanent
|
52
53
|
e.response.class == Net::HTTPMovedPermanently
|
@@ -55,8 +56,8 @@ module CheckHttpResponse
|
|
55
56
|
end
|
56
57
|
|
57
58
|
redirected = is_correct_location && is_correct_redirect
|
58
|
-
@errors[:redirect] = "Wrong redirect type" if not is_correct_redirect
|
59
|
-
@errors[:redirect] = "Wrong location" if not is_correct_location
|
59
|
+
@errors[:redirect] = "Wrong redirect type!" if not is_correct_redirect
|
60
|
+
@errors[:redirect] = "Wrong location! Got: #{redirected_location} , expected: #{location}" if not is_correct_location
|
60
61
|
end
|
61
62
|
|
62
63
|
return redirected
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: check_http_response
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &70240458853860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 0.8.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70240458853860
|
25
25
|
description:
|
26
26
|
email:
|
27
27
|
- gogolok@gmail.com
|
@@ -30,6 +30,7 @@ extensions: []
|
|
30
30
|
extra_rdoc_files: []
|
31
31
|
files:
|
32
32
|
- .gitignore
|
33
|
+
- ChangeLog.markdown
|
33
34
|
- Gemfile
|
34
35
|
- LICENSE
|
35
36
|
- README.md
|
@@ -52,7 +53,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
53
|
version: '0'
|
53
54
|
segments:
|
54
55
|
- 0
|
55
|
-
hash:
|
56
|
+
hash: 961593578884603697
|
56
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
58
|
none: false
|
58
59
|
requirements:
|
@@ -61,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
62
|
version: '0'
|
62
63
|
segments:
|
63
64
|
- 0
|
64
|
-
hash:
|
65
|
+
hash: 961593578884603697
|
65
66
|
requirements: []
|
66
67
|
rubyforge_project:
|
67
68
|
rubygems_version: 1.8.10
|