@@ -21,7 +21,7 @@ def check.request_url_once(url)
21
21
end
22
22
end
23
23
24
- def test_valid?
24
+ def test_valid_by_path
25
25
with_site do |site |
26
26
# Create check
27
27
check = Nanoc ::Extra ::Checking ::Checks ::ExternalLinks . new ( site )
@@ -36,6 +36,20 @@ def check.request_url_once(url)
36
36
end
37
37
end
38
38
39
+ def test_valid_by_query
40
+ with_site do |site |
41
+ # Create check
42
+ check = Nanoc ::Extra ::Checking ::Checks ::ExternalLinks . new ( site )
43
+ def check . request_url_once ( url )
44
+ Net ::HTTPResponse . new ( '1.1' , url . query == 'status=200' ? '200' : '404' , 'okay' )
45
+ end
46
+
47
+ # Test
48
+ assert_nil check . validate ( 'http://example.com/?status=200' )
49
+ refute_nil check . validate ( 'http://example.com/?status=404' )
50
+ end
51
+ end
52
+
39
53
def test_fallback_to_get_when_head_is_not_allowed
40
54
with_site do |site |
41
55
#Create check
@@ -50,4 +64,16 @@ def check.request_url_once(url, req_method = Net::HTTP::Head)
50
64
end
51
65
end
52
66
67
+ def test_path_for_url
68
+ with_site do |site |
69
+ check = Nanoc ::Extra ::Checking ::Checks ::ExternalLinks . new ( site )
70
+
71
+ assert_equal '/' , check . send ( :path_for_url , URI . parse ( 'http://example.com' ) )
72
+ assert_equal '/' , check . send ( :path_for_url , URI . parse ( 'http://example.com/' ) )
73
+ assert_equal '/?foo=bar' , check . send ( :path_for_url , URI . parse ( 'http://example.com?foo=bar' ) )
74
+ assert_equal '/?foo=bar' , check . send ( :path_for_url , URI . parse ( 'http://example.com/?foo=bar' ) )
75
+ assert_equal '/meow?foo=bar' , check . send ( :path_for_url , URI . parse ( 'http://example.com/meow?foo=bar' ) )
76
+ end
77
+ end
78
+
53
79
end
0 commit comments