test_track_rails_client 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +62 -7
- data/Rakefile +8 -4
- data/app/models/test_track/analytics/mixpanel_client.rb +2 -5
- data/app/models/test_track/analytics/safe_wrapper.rb +4 -4
- data/app/models/test_track/config_updater.rb +2 -2
- data/app/models/test_track/fake/split_registry.rb +2 -2
- data/app/models/test_track/notify_assignment_job.rb +3 -4
- data/app/models/test_track/offline_session.rb +6 -4
- data/app/models/test_track/remote/split_registry.rb +2 -2
- data/app/models/test_track/remote/visitor.rb +2 -2
- data/app/models/test_track/session.rb +12 -73
- data/app/models/test_track/unsynced_assignments_notifier.rb +2 -4
- data/app/models/test_track/vary_dsl.rb +5 -1
- data/app/models/test_track/visitor.rb +0 -11
- data/lib/test_track_rails_client/version.rb +1 -1
- data/vendor/gems/fakeable_her/fakeable_her.gemspec +2 -3
- data/vendor/gems/her/her.gemspec +4 -5
- data/vendor/gems/her/lib/her/api.rb +1 -1
- data/vendor/gems/her/lib/her/model/associations/association_proxy.rb +1 -2
- data/vendor/gems/her/lib/her/model/orm.rb +41 -29
- data/vendor/gems/her/lib/her/model/parse.rb +1 -0
- data/vendor/gems/her/lib/her/model/relation.rb +21 -6
- data/vendor/gems/her/lib/her/version.rb +1 -1
- metadata +52 -139
- data/app/models/test_track/create_alias_job.rb +0 -18
- data/vendor/gems/her/CONTRIBUTING.md +0 -26
- data/vendor/gems/her/Gemfile +0 -10
- data/vendor/gems/her/README.md +0 -1023
- data/vendor/gems/her/Rakefile +0 -11
- data/vendor/gems/her/UPGRADE.md +0 -101
- data/vendor/gems/her/gemfiles/Gemfile.activemodel-3.2.x +0 -7
- data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.0 +0 -7
- data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.1 +0 -7
- data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.2 +0 -7
- data/vendor/gems/her/spec/api_spec.rb +0 -114
- data/vendor/gems/her/spec/collection_spec.rb +0 -26
- data/vendor/gems/her/spec/error_collection_spec.rb +0 -33
- data/vendor/gems/her/spec/json_api/model_spec.rb +0 -168
- data/vendor/gems/her/spec/middleware/accept_json_spec.rb +0 -10
- data/vendor/gems/her/spec/middleware/first_level_parse_json_spec.rb +0 -62
- data/vendor/gems/her/spec/middleware/json_api_parser_spec.rb +0 -32
- data/vendor/gems/her/spec/middleware/second_level_parse_json_spec.rb +0 -35
- data/vendor/gems/her/spec/model/associations/association_proxy_spec.rb +0 -31
- data/vendor/gems/her/spec/model/associations_spec.rb +0 -504
- data/vendor/gems/her/spec/model/attributes_spec.rb +0 -404
- data/vendor/gems/her/spec/model/callbacks_spec.rb +0 -145
- data/vendor/gems/her/spec/model/dirty_spec.rb +0 -110
- data/vendor/gems/her/spec/model/http_spec.rb +0 -165
- data/vendor/gems/her/spec/model/introspection_spec.rb +0 -76
- data/vendor/gems/her/spec/model/nested_attributes_spec.rb +0 -134
- data/vendor/gems/her/spec/model/orm_spec.rb +0 -791
- data/vendor/gems/her/spec/model/parse_spec.rb +0 -372
- data/vendor/gems/her/spec/model/paths_spec.rb +0 -347
- data/vendor/gems/her/spec/model/relation_spec.rb +0 -226
- data/vendor/gems/her/spec/model/validations_spec.rb +0 -42
- data/vendor/gems/her/spec/model_spec.rb +0 -31
- data/vendor/gems/her/spec/spec_helper.rb +0 -27
- data/vendor/gems/her/spec/support/extensions/array.rb +0 -5
- data/vendor/gems/her/spec/support/extensions/hash.rb +0 -5
- data/vendor/gems/her/spec/support/macros/her_macros.rb +0 -17
- data/vendor/gems/her/spec/support/macros/model_macros.rb +0 -36
- data/vendor/gems/her/spec/support/macros/request_macros.rb +0 -27
- data/vendor/gems/publicsuffix-ruby/CHANGELOG.md +0 -236
- data/vendor/gems/publicsuffix-ruby/Gemfile +0 -3
- data/vendor/gems/publicsuffix-ruby/LICENSE.txt +0 -22
- data/vendor/gems/publicsuffix-ruby/README.md +0 -151
- data/vendor/gems/publicsuffix-ruby/Rakefile +0 -109
- data/vendor/gems/publicsuffix-ruby/lib/definitions.txt +0 -11467
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/domain.rb +0 -387
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/errors.rb +0 -53
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/list.rb +0 -302
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/rule.rb +0 -373
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/version.rb +0 -23
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix.rb +0 -131
- data/vendor/gems/publicsuffix-ruby/public_suffix.gemspec +0 -39
- data/vendor/gems/publicsuffix-ruby/test/acceptance_test.rb +0 -42
- data/vendor/gems/publicsuffix-ruby/test/test_helper.rb +0 -6
- data/vendor/gems/publicsuffix-ruby/test/unit/domain_test.rb +0 -170
- data/vendor/gems/publicsuffix-ruby/test/unit/errors_test.rb +0 -23
- data/vendor/gems/publicsuffix-ruby/test/unit/list_test.rb +0 -179
- data/vendor/gems/publicsuffix-ruby/test/unit/public_suffix_test.rb +0 -115
- data/vendor/gems/publicsuffix-ruby/test/unit/rule_test.rb +0 -307
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/capybara_configuration.rb +0 -98
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/matchers.rb +0 -151
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rspec_configuration.rb +0 -34
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/html_safe.rb +0 -15
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/raw.rb +0 -15
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/safe_concat.rb +0 -15
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop.rb +0 -3
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/shared_examples/betterment_application_examples.rb +0 -43
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/shared_examples.rb +0 -1
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/site_prism_configuration.rb +0 -42
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/site_prism_dropdown.rb +0 -17
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/version.rb +0 -3
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/webmock_configuration.rb +0 -8
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers.rb +0 -2
- data/vendor/gems/ruby_spec_helpers/ruby_spec_helpers.gemspec +0 -25
@@ -1,115 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class PublicSuffixTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_self_parse_a_domain_with_tld_and_sld
|
6
|
-
domain = PublicSuffix.parse("example.com")
|
7
|
-
assert_instance_of PublicSuffix::Domain, domain
|
8
|
-
assert_equal "com", domain.tld
|
9
|
-
assert_equal "example", domain.sld
|
10
|
-
assert_equal nil, domain.trd
|
11
|
-
|
12
|
-
domain = PublicSuffix.parse("example.co.uk")
|
13
|
-
assert_instance_of PublicSuffix::Domain, domain
|
14
|
-
assert_equal "co.uk", domain.tld
|
15
|
-
assert_equal "example", domain.sld
|
16
|
-
assert_equal nil, domain.trd
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_self_parse_a_domain_with_tld_and_sld_and_trd
|
20
|
-
domain = PublicSuffix.parse("alpha.example.com")
|
21
|
-
assert_instance_of PublicSuffix::Domain, domain
|
22
|
-
assert_equal "com", domain.tld
|
23
|
-
assert_equal "example", domain.sld
|
24
|
-
assert_equal "alpha", domain.trd
|
25
|
-
|
26
|
-
domain = PublicSuffix.parse("alpha.example.co.uk")
|
27
|
-
assert_instance_of PublicSuffix::Domain, domain
|
28
|
-
assert_equal "co.uk", domain.tld
|
29
|
-
assert_equal "example", domain.sld
|
30
|
-
assert_equal "alpha", domain.trd
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_self_parse_a_domain_with_tld_and_sld_and_4rd
|
34
|
-
domain = PublicSuffix.parse("one.two.example.com")
|
35
|
-
assert_instance_of PublicSuffix::Domain, domain
|
36
|
-
assert_equal "com", domain.tld
|
37
|
-
assert_equal "example", domain.sld
|
38
|
-
assert_equal "one.two", domain.trd
|
39
|
-
|
40
|
-
domain = PublicSuffix.parse("one.two.example.co.uk")
|
41
|
-
assert_instance_of PublicSuffix::Domain, domain
|
42
|
-
assert_equal "co.uk", domain.tld
|
43
|
-
assert_equal "example", domain.sld
|
44
|
-
assert_equal "one.two", domain.trd
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_self_parse_a_fully_qualified_domain_name
|
48
|
-
domain = PublicSuffix.parse("www.example.com.")
|
49
|
-
assert_instance_of PublicSuffix::Domain, domain
|
50
|
-
assert_equal "com", domain.tld
|
51
|
-
assert_equal "example", domain.sld
|
52
|
-
assert_equal "www", domain.trd
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_private_domains_are_enabled_by_default
|
56
|
-
domain = PublicSuffix.parse("www.example.blogspot.com")
|
57
|
-
assert_equal "blogspot.com", domain.tld
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_disable_support_for_private_domains
|
61
|
-
begin
|
62
|
-
PublicSuffix::List.private_domains = false
|
63
|
-
domain = PublicSuffix.parse("www.example.blogspot.com")
|
64
|
-
assert_equal "com", domain.tld
|
65
|
-
ensure
|
66
|
-
PublicSuffix::List.private_domains = true
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_self_parse_a_domain_with_custom_list
|
71
|
-
list = PublicSuffix::List.new
|
72
|
-
list << PublicSuffix::Rule.factory("test")
|
73
|
-
|
74
|
-
domain = PublicSuffix.parse("www.example.test", list)
|
75
|
-
assert_equal "test", domain.tld
|
76
|
-
assert_equal "example", domain.sld
|
77
|
-
assert_equal "www", domain.trd
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_self_parse_raises_with_invalid_domain
|
81
|
-
error = assert_raise(PublicSuffix::DomainInvalid) { PublicSuffix.parse("example.qqq") }
|
82
|
-
assert_match %r{example\.qqq}, error.message
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_self_parse_raises_with_unallowed_domain
|
86
|
-
error = assert_raise(PublicSuffix::DomainNotAllowed) { PublicSuffix.parse("example.ke") }
|
87
|
-
assert_match %r{example\.ke}, error.message
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_self_raises_with_uri
|
91
|
-
error = assert_raise(PublicSuffix::DomainInvalid) { PublicSuffix.parse("http://google.com") }
|
92
|
-
assert_match %r{http://google\.com}, error.message
|
93
|
-
end
|
94
|
-
|
95
|
-
|
96
|
-
def test_self_valid
|
97
|
-
assert PublicSuffix.valid?("google.com")
|
98
|
-
assert PublicSuffix.valid?("www.google.com")
|
99
|
-
assert PublicSuffix.valid?("google.co.uk")
|
100
|
-
assert PublicSuffix.valid?("www.google.co.uk")
|
101
|
-
end
|
102
|
-
|
103
|
-
# Returns false when domain has an invalid TLD
|
104
|
-
def test_self_valid_with_invalid_tld
|
105
|
-
assert !PublicSuffix.valid?("google.qqq")
|
106
|
-
assert !PublicSuffix.valid?("www.google.qqq")
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_self_valid_with_fully_qualified_domain_name
|
110
|
-
assert PublicSuffix.valid?("google.com.")
|
111
|
-
assert PublicSuffix.valid?("google.co.uk.")
|
112
|
-
assert !PublicSuffix.valid?("google.qqq.")
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
@@ -1,307 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class PublicSuffix::RuleTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_factory_should_return_rule_normal
|
6
|
-
rule = PublicSuffix::Rule.factory("com")
|
7
|
-
assert_instance_of PublicSuffix::Rule::Normal, rule
|
8
|
-
|
9
|
-
rule = PublicSuffix::Rule.factory("verona.it")
|
10
|
-
assert_instance_of PublicSuffix::Rule::Normal, rule
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_factory_should_return_rule_exception
|
14
|
-
rule = PublicSuffix::Rule.factory("!british-library.uk")
|
15
|
-
assert_instance_of PublicSuffix::Rule::Exception, rule
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_factory_should_return_rule_wildcard
|
19
|
-
rule = PublicSuffix::Rule.factory("*.do")
|
20
|
-
assert_instance_of PublicSuffix::Rule::Wildcard, rule
|
21
|
-
|
22
|
-
rule = PublicSuffix::Rule.factory("*.sch.uk")
|
23
|
-
assert_instance_of PublicSuffix::Rule::Wildcard, rule
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
class PublicSuffix::RuleBaseTest < Test::Unit::TestCase
|
30
|
-
|
31
|
-
class ::PublicSuffix::Rule::Test < ::PublicSuffix::Rule::Base
|
32
|
-
end
|
33
|
-
|
34
|
-
def setup
|
35
|
-
@klass = PublicSuffix::Rule::Base
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
def test_initialize
|
40
|
-
rule = @klass.new("verona.it")
|
41
|
-
assert_instance_of @klass, rule
|
42
|
-
|
43
|
-
assert_equal :base, rule.type
|
44
|
-
assert_equal "verona.it", rule.name
|
45
|
-
assert_equal "verona.it", rule.value
|
46
|
-
assert_equal %w(verona it).reverse, rule.labels
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_equality_with_self
|
50
|
-
rule = PublicSuffix::Rule::Base.new("foo")
|
51
|
-
assert_equal rule, rule
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_equality_with_internals
|
55
|
-
assert_equal @klass.new("foo"), @klass.new("foo")
|
56
|
-
assert_not_equal @klass.new("foo"), @klass.new("bar")
|
57
|
-
assert_not_equal @klass.new("foo"), PublicSuffix::Rule::Test.new("bar")
|
58
|
-
assert_not_equal @klass.new("foo"), Class.new { def name; foo; end }.new
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
def test_match
|
63
|
-
assert @klass.new("uk").match?("example.uk")
|
64
|
-
assert !@klass.new("gk").match?("example.uk")
|
65
|
-
assert !@klass.new("example").match?("example.uk")
|
66
|
-
|
67
|
-
assert @klass.new("uk").match?("example.co.uk")
|
68
|
-
assert !@klass.new("gk").match?("example.co.uk")
|
69
|
-
assert !@klass.new("co").match?("example.co.uk")
|
70
|
-
|
71
|
-
assert @klass.new("co.uk").match?("example.co.uk")
|
72
|
-
assert !@klass.new("uk.co").match?("example.co.uk")
|
73
|
-
assert !@klass.new("go.uk").match?("example.co.uk")
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_length
|
77
|
-
assert_raise(NotImplementedError) { @klass.new("com").length }
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_parts
|
81
|
-
assert_raise(NotImplementedError) { @klass.new("com").parts }
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_decompose
|
85
|
-
assert_raise(NotImplementedError) { @klass.new("com").decompose("google.com") }
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
class PublicSuffix::RuleNormalTest < Test::Unit::TestCase
|
92
|
-
|
93
|
-
def setup
|
94
|
-
@klass = PublicSuffix::Rule::Normal
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
def test_initialize
|
99
|
-
rule = @klass.new("verona.it")
|
100
|
-
assert_instance_of @klass, rule
|
101
|
-
assert_equal :normal, rule.type
|
102
|
-
assert_equal "verona.it", rule.name
|
103
|
-
assert_equal "verona.it", rule.value
|
104
|
-
assert_equal %w(verona it).reverse, rule.labels
|
105
|
-
end
|
106
|
-
|
107
|
-
|
108
|
-
def test_match
|
109
|
-
assert @klass.new("uk").match?("example.uk")
|
110
|
-
assert !@klass.new("gk").match?("example.uk")
|
111
|
-
assert !@klass.new("example").match?("example.uk")
|
112
|
-
|
113
|
-
assert @klass.new("uk").match?("example.co.uk")
|
114
|
-
assert !@klass.new("gk").match?("example.co.uk")
|
115
|
-
assert !@klass.new("co").match?("example.co.uk")
|
116
|
-
|
117
|
-
assert @klass.new("co.uk").match?("example.co.uk")
|
118
|
-
assert !@klass.new("uk.co").match?("example.co.uk")
|
119
|
-
assert !@klass.new("go.uk").match?("example.co.uk")
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_match_with_fully_qualified_domain_name
|
123
|
-
assert @klass.new("com").match?("com.")
|
124
|
-
assert @klass.new("com").match?("example.com.")
|
125
|
-
assert @klass.new("com").match?("www.example.com.")
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_allow
|
129
|
-
assert !@klass.new("com").allow?("com")
|
130
|
-
assert @klass.new("com").allow?("example.com")
|
131
|
-
assert @klass.new("com").allow?("www.example.com")
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_allow_with_fully_qualified_domain_name
|
135
|
-
assert !@klass.new("com").allow?("com.")
|
136
|
-
assert @klass.new("com").allow?("example.com.")
|
137
|
-
assert @klass.new("com").allow?("www.example.com.")
|
138
|
-
end
|
139
|
-
|
140
|
-
|
141
|
-
def test_length
|
142
|
-
assert_equal 1, @klass.new("com").length
|
143
|
-
assert_equal 2, @klass.new("co.com").length
|
144
|
-
assert_equal 3, @klass.new("mx.co.com").length
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_parts
|
148
|
-
assert_equal %w(com), @klass.new("com").parts
|
149
|
-
assert_equal %w(co com), @klass.new("co.com").parts
|
150
|
-
assert_equal %w(mx co com), @klass.new("mx.co.com").parts
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_decompose
|
154
|
-
assert_equal [nil, nil], @klass.new("com").decompose("com")
|
155
|
-
assert_equal %w( example com ), @klass.new("com").decompose("example.com")
|
156
|
-
assert_equal %w( foo.example com ), @klass.new("com").decompose("foo.example.com")
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_decompose_with_fully_qualified_domain_name
|
160
|
-
assert_equal [nil, nil], @klass.new("com").decompose("com.")
|
161
|
-
assert_equal %w( example com ), @klass.new("com").decompose("example.com.")
|
162
|
-
assert_equal %w( foo.example com ), @klass.new("com").decompose("foo.example.com.")
|
163
|
-
end
|
164
|
-
|
165
|
-
end
|
166
|
-
|
167
|
-
|
168
|
-
class PublicSuffix::RuleExceptionTest < Test::Unit::TestCase
|
169
|
-
|
170
|
-
def setup
|
171
|
-
@klass = PublicSuffix::Rule::Exception
|
172
|
-
end
|
173
|
-
|
174
|
-
|
175
|
-
def test_initialize
|
176
|
-
rule = @klass.new("!british-library.uk")
|
177
|
-
assert_instance_of @klass, rule
|
178
|
-
assert_equal :exception, rule.type
|
179
|
-
assert_equal "!british-library.uk", rule.name
|
180
|
-
assert_equal "british-library.uk", rule.value
|
181
|
-
assert_equal %w(british-library uk).reverse, rule.labels
|
182
|
-
end
|
183
|
-
|
184
|
-
|
185
|
-
def test_match
|
186
|
-
assert @klass.new("!uk").match?("example.co.uk")
|
187
|
-
assert !@klass.new("!gk").match?("example.co.uk")
|
188
|
-
assert @klass.new("!co.uk").match?("example.co.uk")
|
189
|
-
assert !@klass.new("!go.uk").match?("example.co.uk")
|
190
|
-
assert @klass.new("!british-library.uk").match?("british-library.uk")
|
191
|
-
assert !@klass.new("!british-library.uk").match?("example.co.uk")
|
192
|
-
end
|
193
|
-
|
194
|
-
def test_match_with_fully_qualified_domain_name
|
195
|
-
assert @klass.new("!uk").match?("uk.")
|
196
|
-
assert @klass.new("!uk").match?("co.uk.")
|
197
|
-
assert @klass.new("!uk").match?("example.co.uk.")
|
198
|
-
assert @klass.new("!uk").match?("www.example.co.uk.")
|
199
|
-
end
|
200
|
-
|
201
|
-
def test_allow
|
202
|
-
assert !@klass.new("!british-library.uk").allow?("uk")
|
203
|
-
assert @klass.new("!british-library.uk").allow?("british-library.uk")
|
204
|
-
assert @klass.new("!british-library.uk").allow?("www.british-library.uk")
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_allow_with_fully_qualified_domain_name
|
208
|
-
assert !@klass.new("!british-library.uk").allow?("uk.")
|
209
|
-
assert @klass.new("!british-library.uk").allow?("british-library.uk.")
|
210
|
-
assert @klass.new("!british-library.uk").allow?("www.british-library.uk.")
|
211
|
-
end
|
212
|
-
|
213
|
-
|
214
|
-
def test_length
|
215
|
-
assert_equal 1, @klass.new("!british-library.uk").length
|
216
|
-
assert_equal 2, @klass.new("!foo.british-library.uk").length
|
217
|
-
end
|
218
|
-
|
219
|
-
def test_parts
|
220
|
-
assert_equal %w( uk ), @klass.new("!british-library.uk").parts
|
221
|
-
assert_equal %w( tokyo jp ), @klass.new("!metro.tokyo.jp").parts
|
222
|
-
end
|
223
|
-
|
224
|
-
def test_decompose
|
225
|
-
assert_equal [nil, nil], @klass.new("!british-library.uk").decompose("uk")
|
226
|
-
assert_equal %w( british-library uk ), @klass.new("!british-library.uk").decompose("british-library.uk")
|
227
|
-
assert_equal %w( foo.british-library uk ), @klass.new("!british-library.uk").decompose("foo.british-library.uk")
|
228
|
-
end
|
229
|
-
|
230
|
-
def test_decompose_with_fully_qualified_domain_name
|
231
|
-
assert_equal [nil, nil], @klass.new("!british-library.uk").decompose("uk.")
|
232
|
-
assert_equal %w( british-library uk ), @klass.new("!british-library.uk").decompose("british-library.uk.")
|
233
|
-
assert_equal %w( foo.british-library uk ), @klass.new("!british-library.uk").decompose("foo.british-library.uk.")
|
234
|
-
end
|
235
|
-
|
236
|
-
end
|
237
|
-
|
238
|
-
|
239
|
-
class PublicSuffix::RuleWildcardTest < Test::Unit::TestCase
|
240
|
-
|
241
|
-
def setup
|
242
|
-
@klass = PublicSuffix::Rule::Wildcard
|
243
|
-
end
|
244
|
-
|
245
|
-
|
246
|
-
def test_initialize
|
247
|
-
rule = @klass.new("*.aichi.jp")
|
248
|
-
assert_instance_of @klass, rule
|
249
|
-
assert_equal :wildcard, rule.type
|
250
|
-
assert_equal "*.aichi.jp", rule.name
|
251
|
-
assert_equal "aichi.jp", rule.value
|
252
|
-
assert_equal %w(aichi jp).reverse, rule.labels
|
253
|
-
end
|
254
|
-
|
255
|
-
|
256
|
-
def test_match
|
257
|
-
assert @klass.new("*.uk").match?("example.uk")
|
258
|
-
assert @klass.new("*.uk").match?("example.co.uk")
|
259
|
-
assert @klass.new("*.co.uk").match?("example.co.uk")
|
260
|
-
assert !@klass.new("*.go.uk").match?("example.co.uk")
|
261
|
-
end
|
262
|
-
|
263
|
-
def test_match_with_fully_qualified_domain_name
|
264
|
-
assert @klass.new("*.uk").match?("uk.")
|
265
|
-
assert @klass.new("*.uk").match?("co.uk.")
|
266
|
-
assert @klass.new("*.uk").match?("example.co.uk.")
|
267
|
-
assert @klass.new("*.uk").match?("www.example.co.uk.")
|
268
|
-
end
|
269
|
-
|
270
|
-
def test_allow
|
271
|
-
assert !@klass.new("*.uk").allow?("uk")
|
272
|
-
assert !@klass.new("*.uk").allow?("co.uk")
|
273
|
-
assert @klass.new("*.uk").allow?("example.co.uk")
|
274
|
-
assert @klass.new("*.uk").allow?("www.example.co.uk")
|
275
|
-
end
|
276
|
-
|
277
|
-
def test_allow_with_fully_qualified_domain_name
|
278
|
-
assert !@klass.new("*.uk").allow?("uk.")
|
279
|
-
assert !@klass.new("*.uk").allow?("co.uk.")
|
280
|
-
assert @klass.new("*.uk").allow?("example.co.uk.")
|
281
|
-
assert @klass.new("*.uk").allow?("www.example.co.uk.")
|
282
|
-
end
|
283
|
-
|
284
|
-
|
285
|
-
def test_length
|
286
|
-
assert_equal 2, @klass.new("*.uk").length
|
287
|
-
assert_equal 3, @klass.new("*.co.uk").length
|
288
|
-
end
|
289
|
-
|
290
|
-
def test_parts
|
291
|
-
assert_equal %w( uk ), @klass.new("*.uk").parts
|
292
|
-
assert_equal %w( co uk ), @klass.new("*.co.uk").parts
|
293
|
-
end
|
294
|
-
|
295
|
-
def test_decompose
|
296
|
-
assert_equal [nil, nil], @klass.new("*.do").decompose("nic.do")
|
297
|
-
assert_equal %w( google co.uk ), @klass.new("*.uk").decompose("google.co.uk")
|
298
|
-
assert_equal %w( foo.google co.uk ), @klass.new("*.uk").decompose("foo.google.co.uk")
|
299
|
-
end
|
300
|
-
|
301
|
-
def test_decompose_with_fully_qualified_domain_name
|
302
|
-
assert_equal [nil, nil], @klass.new("*.do").decompose("nic.do.")
|
303
|
-
assert_equal %w( google co.uk ), @klass.new("*.uk").decompose("google.co.uk.")
|
304
|
-
assert_equal %w( foo.google co.uk ), @klass.new("*.uk").decompose("foo.google.co.uk.")
|
305
|
-
end
|
306
|
-
|
307
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
require 'capybara/rails'
|
2
|
-
require 'capybara/rspec'
|
3
|
-
require 'selenium-webdriver'
|
4
|
-
require 'fileutils'
|
5
|
-
|
6
|
-
ENV["SCREENSHOT_DIR"] ||= Time.now.to_i.to_s
|
7
|
-
capybara_wait_time = (ENV['CAPYBARA_WAIT_TIME'] || 10).to_i
|
8
|
-
driver = (ENV["DRIVER"] || "webkit").to_sym
|
9
|
-
webkit_debug = (!ENV["WEBKIT_DEBUG"].nil? && ENV["WEBKIT_DEBUG"] == "true") ? true : false
|
10
|
-
|
11
|
-
case driver
|
12
|
-
when :webkit
|
13
|
-
Capybara.register_driver :webkit do |app|
|
14
|
-
browser = Capybara::Webkit::Browser.new(Capybara::Webkit::Connection.new).tap do |browser|
|
15
|
-
browser.ignore_ssl_errors
|
16
|
-
end
|
17
|
-
driver = Capybara::Webkit::Driver.new(app, browser: browser)
|
18
|
-
driver.enable_logging if webkit_debug
|
19
|
-
driver
|
20
|
-
end
|
21
|
-
when :poltergeist
|
22
|
-
require 'capybara/poltergeist'
|
23
|
-
Capybara.register_driver :poltergeist do |app|
|
24
|
-
driver = Capybara::Poltergeist::Driver.new(app, js_errors: false, phantomjs_logger: Logger.new('/dev/null'))
|
25
|
-
driver
|
26
|
-
end
|
27
|
-
else
|
28
|
-
Capybara.register_driver driver do |app|
|
29
|
-
Capybara::Selenium::Driver.new(app, browser: driver)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Capybara.configure do |config|
|
34
|
-
config.match = :one
|
35
|
-
config.exact_options = true
|
36
|
-
config.ignore_hidden_elements = true
|
37
|
-
config.visible_text_only = true
|
38
|
-
config.default_wait_time = capybara_wait_time
|
39
|
-
config.default_driver = driver
|
40
|
-
config.javascript_driver = driver
|
41
|
-
end
|
42
|
-
|
43
|
-
module CapybaraScreenshotHelpers
|
44
|
-
def screenshot(filename)
|
45
|
-
options = {}
|
46
|
-
case Capybara.current_driver
|
47
|
-
when :webkit
|
48
|
-
options[:width] = page.driver.evaluate_script("document.documentElement.clientWidth")
|
49
|
-
options[:height] = page.driver.evaluate_script("document.documentElement.clientHeight")
|
50
|
-
when :poltergeist
|
51
|
-
options[:full] = true
|
52
|
-
end
|
53
|
-
page.save_screenshot "#{filename}", options
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def screenshot_name(example)
|
59
|
-
"#{example.metadata[:full_description]}.png".gsub(/\ /, "_")
|
60
|
-
end
|
61
|
-
|
62
|
-
def screenshot_on_error(example)
|
63
|
-
if !example.exception.nil?
|
64
|
-
dirname = "spec/error_screenshots/#{ENV["SCREENSHOT_DIR"]}"
|
65
|
-
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
|
66
|
-
screenshot "#{dirname}/#{screenshot_name(example)}"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def print_console_messages
|
71
|
-
if page.driver.respond_to?(:errors_messages)
|
72
|
-
p page.driver.error_messages unless page.driver.error_messages.empty?
|
73
|
-
# uncomment for ALL console messages, not just console.error
|
74
|
-
# p page.driver.console_messages unless page.driver.console_messages.empty?
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
RSpec.configure do |config|
|
80
|
-
config.include CapybaraScreenshotHelpers, type: :feature
|
81
|
-
|
82
|
-
config.after(:each, type: :feature) do |example|
|
83
|
-
if example.exception && page.driver.respond_to?(:console_messages)
|
84
|
-
puts page.driver.console_messages.find_all { |message| !message.to_s.include? 'mixpanel' }
|
85
|
-
puts page.driver.error_messages.find_all { |message| !message.to_s.include? 'mixpanel' }
|
86
|
-
end
|
87
|
-
screenshot_on_error example
|
88
|
-
Capybara.reset_sessions!
|
89
|
-
end
|
90
|
-
|
91
|
-
config.after(:suite) do
|
92
|
-
error_screenshot_directory = "spec/error_screenshots/#{ENV["SCREENSHOT_DIR"]}"
|
93
|
-
puts "\nError screenshots saved to: #{error_screenshot_directory}" if File.directory?("#{error_screenshot_directory}")
|
94
|
-
|
95
|
-
# remove any paperclip attachments
|
96
|
-
FileUtils.rm_rf(Dir["#{Rails.root}/spec/test_files/"])
|
97
|
-
end
|
98
|
-
end
|
@@ -1,151 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'open3'
|
3
|
-
require 'timeout'
|
4
|
-
|
5
|
-
RSpec::Matchers.define :become_true do |expected|
|
6
|
-
|
7
|
-
match do |block|
|
8
|
-
end_time = Time.now + Capybara.default_wait_time.seconds
|
9
|
-
loop do
|
10
|
-
break if Time.now > end_time
|
11
|
-
value = block.call
|
12
|
-
return true if value
|
13
|
-
end
|
14
|
-
false
|
15
|
-
end
|
16
|
-
|
17
|
-
def supports_block_expectations?
|
18
|
-
true
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
SnapshotInfo = Struct.new(:name, :variation, :file)
|
24
|
-
|
25
|
-
class RSpec::Core::ExampleGroup
|
26
|
-
|
27
|
-
def snapshot(name = :default, variation = :desktop)
|
28
|
-
tmp = Tempfile.new([variation, '.png'])
|
29
|
-
tmp.close
|
30
|
-
|
31
|
-
document_width = page.driver.evaluate_script("document.documentElement.clientWidth")
|
32
|
-
document_height = page.driver.evaluate_script("document.documentElement.clientHeight")
|
33
|
-
page.save_screenshot "#{tmp.path}", width: document_width, height: document_height
|
34
|
-
|
35
|
-
SnapshotInfo.new(name, variation, tmp)
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
RSpec.configure do |config|
|
41
|
-
config.after(:example) do |example|
|
42
|
-
msg = example.metadata[:new_snapshot_paths].inject('') do |msg, path|
|
43
|
-
<<-COMMANDS #{msg}
|
44
|
-
Show new screenshot:
|
45
|
-
$ open #{dirname}/NEW_#{path}
|
46
|
-
|
47
|
-
Approve new screenshot:
|
48
|
-
$ mv #{dirname}/NEW_#{path} #{dirname}/#{path}
|
49
|
-
COMMANDS
|
50
|
-
end unless example.metadata[:new_snapshot_paths].nil?
|
51
|
-
|
52
|
-
raise RSpec::Expectations::ExpectationNotMetError, msg, example.metadata[:snapshot_first_caller] unless msg.blank?
|
53
|
-
end
|
54
|
-
|
55
|
-
def dirname
|
56
|
-
'spec/support/expected_snapshots'
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
RSpec::Matchers.define :look_correct do
|
62
|
-
match do |snapshot_info|
|
63
|
-
|
64
|
-
next true if ENV['SKIP_SCREENSHOT_DIFF']
|
65
|
-
|
66
|
-
path = snapshot_path(snapshot_info)
|
67
|
-
|
68
|
-
existing_path = "#{dirname}/#{path}"
|
69
|
-
new_path = snapshot_info.file.path
|
70
|
-
|
71
|
-
existing_height = height_of(existing_path)
|
72
|
-
new_height = height_of(new_path)
|
73
|
-
|
74
|
-
tmpfile_path = Tempfile.new(['scaled','.png']).path if existing_height != new_height
|
75
|
-
|
76
|
-
if existing_height < new_height
|
77
|
-
`convert #{existing_path} -resize 1650x#{new_height} -background black -compose Copy -gravity north -extent 1650x#{new_height} #{tmpfile_path}`
|
78
|
-
existing_path = tmpfile_path
|
79
|
-
end
|
80
|
-
|
81
|
-
if new_height < existing_height
|
82
|
-
`convert #{new_path} -resize 1650x#{existing_height} -background black -compose Copy -gravity north -extent 1650x#{existing_height} #{tmpfile_path}`
|
83
|
-
new_path = tmpfile_path
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
if File.exists?(existing_path)
|
88
|
-
prog = 'compare'
|
89
|
-
args = '-verbose -metric RMSE -highlight-color Red'
|
90
|
-
diff_path = "#{dirname}/DIFF_#{path}"
|
91
|
-
|
92
|
-
# do image comparison
|
93
|
-
cmd = "#{prog} #{args} \"#{existing_path}\" \"#{new_path}\" \"#{diff_path}\""
|
94
|
-
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
95
|
-
thr_status = wait_thr.value
|
96
|
-
|
97
|
-
case thr_status.exitstatus
|
98
|
-
when 0
|
99
|
-
# remove the diff image since the images match
|
100
|
-
FileUtils.rm(diff_path)
|
101
|
-
when 1
|
102
|
-
# images are different
|
103
|
-
FileUtils.mv(snapshot_info.file.path, "#{dirname}/CHANGED_#{path}")
|
104
|
-
false
|
105
|
-
else
|
106
|
-
puts stdout.read
|
107
|
-
puts stderr.read
|
108
|
-
raise "Diff command failed #{cmd} : (#{thr_status.exitstatus})"
|
109
|
-
end
|
110
|
-
end
|
111
|
-
else
|
112
|
-
|
113
|
-
# this is a new screenshot, so move it in place
|
114
|
-
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
|
115
|
-
FileUtils.mv(snapshot_info.file.path, "#{dirname}/NEW_#{path}")
|
116
|
-
|
117
|
-
example.metadata[:snapshot_first_caller] = caller unless example.metadata[:snapshot_first_caller]
|
118
|
-
(example.metadata[:new_snapshot_paths] ||= []) << path
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
failure_message do |snapshot_info|
|
123
|
-
path = snapshot_path(snapshot_info)
|
124
|
-
|
125
|
-
<<-COMMANDS
|
126
|
-
expected that '#{snapshot_info.name}' screenshot for #{snapshot_info.variation} would look correct
|
127
|
-
|
128
|
-
Show screenshot diffs:
|
129
|
-
$ open #{dirname}/DIFF_#{path} #{dirname}/CHANGED_#{path} #{dirname}/#{path}
|
130
|
-
|
131
|
-
Approve changed screenshot:
|
132
|
-
$ mv #{dirname}/CHANGED_#{path} #{dirname}/#{path}
|
133
|
-
COMMANDS
|
134
|
-
end
|
135
|
-
|
136
|
-
def dirname
|
137
|
-
'spec/support/expected_snapshots'
|
138
|
-
end
|
139
|
-
|
140
|
-
def snapshot_path(snapshot_info)
|
141
|
-
"#{[example.metadata[:full_description].parameterize('-'), snapshot_info.name, snapshot_info.variation].join('_')}.png"
|
142
|
-
end
|
143
|
-
|
144
|
-
def height_of(path)
|
145
|
-
`identify -format "%h" #{path}`.chomp.to_i
|
146
|
-
end
|
147
|
-
|
148
|
-
def example
|
149
|
-
RSpec.current_example
|
150
|
-
end
|
151
|
-
end
|