@@ -14,117 +14,117 @@ def cname_packet(domain)
14
14
15
15
it "knows old IP addresses" do
16
16
%w[ 204.232.175.78 207.97.227.245 ] . each do |ip_address |
17
- health_check . stub ( :dns ) { [ a_packet ( ip_address ) ] }
18
- expect ( health_check . old_ip_address? ) . to be_true
17
+ allow ( health_check ) . to receive ( :dns ) { [ a_packet ( ip_address ) ] }
18
+ expect ( health_check . old_ip_address? ) . to be ( true )
19
19
end
20
20
21
- health_check . stub ( :dns ) { [ a_packet ( "1.2.3.4" ) ] }
22
- expect ( health_check . old_ip_address? ) . to be_false
21
+ allow ( health_check ) . to receive ( :dns ) { [ a_packet ( "1.2.3.4" ) ] }
22
+ expect ( health_check . old_ip_address? ) . to be ( false )
23
23
end
24
24
25
25
it "knows when a domain is an A record" do
26
- health_check . stub ( :dns ) { [ a_packet ( "1.2.3.4" ) ] }
27
- expect ( health_check . a_record? ) . to be_true
28
- expect ( health_check . cname_record? ) . to be_false
26
+ allow ( health_check ) . to receive ( :dns ) { [ a_packet ( "1.2.3.4" ) ] }
27
+ expect ( health_check . a_record? ) . to be ( true )
28
+ expect ( health_check . cname_record? ) . to be ( false )
29
29
end
30
30
31
31
it "known when a domain is a CNAME record" do
32
- health_check . stub ( :dns ) { [ cname_packet ( "pages.github.com" ) ] }
33
- expect ( health_check . cname_record? ) . to be_true
34
- expect ( health_check . a_record? ) . to be_false
32
+ allow ( health_check ) . to receive ( :dns ) { [ cname_packet ( "pages.github.com" ) ] }
33
+ expect ( health_check . cname_record? ) . to be ( true )
34
+ expect ( health_check . a_record? ) . to be ( false )
35
35
end
36
36
37
37
it "knows what an apex domain is" do
38
- health_check . stub ( :domain ) { "parkermoore.de" }
39
- expect ( health_check . apex_domain? ) . to be_true
38
+ allow ( health_check ) . to receive ( :domain ) { "parkermoore.de" }
39
+ expect ( health_check . apex_domain? ) . to be ( true )
40
40
41
- health_check . stub ( :domain ) { "bbc.co.uk" }
42
- expect ( health_check . apex_domain? ) . to be_true
41
+ allow ( health_check ) . to receive ( :domain ) { "bbc.co.uk" }
42
+ expect ( health_check . apex_domain? ) . to be ( true )
43
43
end
44
44
45
45
it "knows when the domain is on cloudflare" do
46
- health_check . stub ( :dns ) { [ a_packet ( "108.162.196.20" ) ] }
47
- expect ( health_check . cloudflare_ip? ) . to be_true
46
+ allow ( health_check ) . to receive ( :dns ) { [ a_packet ( "108.162.196.20" ) ] }
47
+ expect ( health_check . cloudflare_ip? ) . to be ( true )
48
48
49
- health_check . stub ( :dns ) { [ a_packet ( "1.1.1.1" ) ] }
50
- expect ( health_check . cloudflare_ip? ) . to be_false
49
+ allow ( health_check ) . to receive ( :dns ) { [ a_packet ( "1.1.1.1" ) ] }
50
+ expect ( health_check . cloudflare_ip? ) . to be ( false )
51
51
end
52
52
53
53
it "knows a subdomain is not an apex domain" do
54
- health_check . stub ( :domain ) { "blog.parkermoore.de" }
55
- expect ( health_check . apex_domain? ) . to be_false
54
+ allow ( health_check ) . to receive ( :domain ) { "blog.parkermoore.de" }
55
+ expect ( health_check . apex_domain? ) . to be ( false )
56
56
57
- health_check . stub ( :domain ) { "www.bbc.co.uk" }
58
- expect ( health_check . apex_domain? ) . to be_false
57
+ allow ( health_check ) . to receive ( :domain ) { "www.bbc.co.uk" }
58
+ expect ( health_check . apex_domain? ) . to be ( false )
59
59
end
60
60
61
61
it "knows what should be an apex record" do
62
- health_check . stub ( :domain ) { "parkermoore.de" }
63
- expect ( health_check . should_be_a_record? ) . to be_true
62
+ allow ( health_check ) . to receive ( :domain ) { "parkermoore.de" }
63
+ expect ( health_check . should_be_a_record? ) . to be ( true )
64
64
65
- health_check . stub ( :domain ) { "bbc.co.uk" }
66
- expect ( health_check . should_be_a_record? ) . to be_true
65
+ allow ( health_check ) . to receive ( :domain ) { "bbc.co.uk" }
66
+ expect ( health_check . should_be_a_record? ) . to be ( true )
67
67
68
- health_check . stub ( :domain ) { "blog.parkermoore.de" }
69
- expect ( health_check . should_be_a_record? ) . to be_false
68
+ allow ( health_check ) . to receive ( :domain ) { "blog.parkermoore.de" }
69
+ expect ( health_check . should_be_a_record? ) . to be ( false )
70
70
71
- health_check . stub ( :domain ) { "www.bbc.co.uk" }
72
- expect ( health_check . should_be_a_record? ) . to be_false
71
+ allow ( health_check ) . to receive ( :domain ) { "www.bbc.co.uk" }
72
+ expect ( health_check . should_be_a_record? ) . to be ( false )
73
73
74
- health_check . stub ( :domain ) { "foo.github.io" }
75
- expect ( health_check . should_be_a_record? ) . to be_false
74
+ allow ( health_check ) . to receive ( :domain ) { "foo.github.io" }
75
+ expect ( health_check . should_be_a_record? ) . to be ( false )
76
76
77
- health_check . stub ( :domain ) { "pages.github.com" }
78
- expect ( health_check . should_be_a_record? ) . to be_false
77
+ allow ( health_check ) . to receive ( :domain ) { "pages.github.com" }
78
+ expect ( health_check . should_be_a_record? ) . to be ( false )
79
79
end
80
80
81
81
it "can determine a valid GitHub Pages CNAME value" do
82
82
[ "parkr.github.io" , "mattr-.github.com" ] . each do |domain |
83
- health_check . stub ( :dns ) { [ cname_packet ( domain ) ] }
84
- expect ( health_check . pointed_to_github_user_domain? ) . to be_true
83
+ allow ( health_check ) . to receive ( :dns ) { [ cname_packet ( domain ) ] }
84
+ expect ( health_check . pointed_to_github_user_domain? ) . to be ( true )
85
85
end
86
86
[ "github.com" , "ben.balter.com" ] . each do |domain |
87
- health_check . stub ( :dns ) { [ cname_packet ( domain ) ] }
88
- expect ( health_check . pointed_to_github_user_domain? ) . to be_false
87
+ allow ( health_check ) . to receive ( :dns ) { [ cname_packet ( domain ) ] }
88
+ expect ( health_check . pointed_to_github_user_domain? ) . to be ( false )
89
89
end
90
90
end
91
91
92
92
it "retrieves a site's dns record" do
93
- health_check . stub ( :domain ) { "pages.github.com" }
93
+ allow ( health_check ) . to receive ( :domain ) { "pages.github.com" }
94
94
expect ( health_check . dns . first . class ) . to eql ( Net ::DNS ::RR ::CNAME )
95
95
end
96
96
97
97
it "can detect pages domains" do
98
- health_check . stub ( :domain ) { "pages.github.com" }
99
- expect ( health_check . pages_domain? ) . to be_true
98
+ allow ( health_check ) . to receive ( :domain ) { "pages.github.com" }
99
+ expect ( health_check . pages_domain? ) . to be ( true )
100
100
101
- health_check . stub ( :domain ) { "pages.github.io" }
102
- expect ( health_check . pages_domain? ) . to be_true
101
+ allow ( health_check ) . to receive ( :domain ) { "pages.github.io" }
102
+ expect ( health_check . pages_domain? ) . to be ( true )
103
103
104
- health_check . stub ( :domain ) { "pages.github.io." }
105
- expect ( health_check . pages_domain? ) . to be_true
104
+ allow ( health_check ) . to receive ( :domain ) { "pages.github.io." }
105
+ expect ( health_check . pages_domain? ) . to be ( true )
106
106
end
107
107
108
108
it "doesn't detect non-pages domains as a pages domain" do
109
- health_check . stub ( :domain ) { "github.com" }
110
- expect ( health_check . pages_domain? ) . to be_false
109
+ allow ( health_check ) . to receive ( :domain ) { "github.com" }
110
+ expect ( health_check . pages_domain? ) . to be ( false )
111
111
112
- health_check . stub ( :domain ) { "google.co.uk" }
113
- expect ( health_check . pages_domain? ) . to be_false
112
+ allow ( health_check ) . to receive ( :domain ) { "google.co.uk" }
113
+ expect ( health_check . pages_domain? ) . to be ( false )
114
114
end
115
115
116
116
it "detects invalid doimains" do
117
- health_check . stub ( :domain ) { "github.com" }
118
- expect ( health_check . valid_domain? ) . to be_true
117
+ allow ( health_check ) . to receive ( :domain ) { "github.com" }
118
+ expect ( health_check . valid_domain? ) . to be ( true )
119
119
120
- health_check . stub ( :domain ) { "github.invalid" }
121
- expect ( health_check . valid_domain? ) . to be_false
120
+ allow ( health_check ) . to receive ( :domain ) { "github.invalid" }
121
+ expect ( health_check . valid_domain? ) . to be ( false )
122
122
end
123
123
124
124
it "returns valid json" do
125
125
data = JSON . parse GitHubPages ::HealthCheck . new ( "benbalter.com" ) . to_json
126
126
expect ( data . length ) . to eql ( 10 )
127
- data . each { |key , value | expect ( [ true , false ] . include? ( value ) ) . should eql ( true ) }
127
+ data . each { |key , value | expect ( [ true , false ] . include? ( value ) ) . to eql ( true ) }
128
128
end
129
129
130
130
end
0 commit comments