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.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +62 -7
  3. data/Rakefile +8 -4
  4. data/app/models/test_track/analytics/mixpanel_client.rb +2 -5
  5. data/app/models/test_track/analytics/safe_wrapper.rb +4 -4
  6. data/app/models/test_track/config_updater.rb +2 -2
  7. data/app/models/test_track/fake/split_registry.rb +2 -2
  8. data/app/models/test_track/notify_assignment_job.rb +3 -4
  9. data/app/models/test_track/offline_session.rb +6 -4
  10. data/app/models/test_track/remote/split_registry.rb +2 -2
  11. data/app/models/test_track/remote/visitor.rb +2 -2
  12. data/app/models/test_track/session.rb +12 -73
  13. data/app/models/test_track/unsynced_assignments_notifier.rb +2 -4
  14. data/app/models/test_track/vary_dsl.rb +5 -1
  15. data/app/models/test_track/visitor.rb +0 -11
  16. data/lib/test_track_rails_client/version.rb +1 -1
  17. data/vendor/gems/fakeable_her/fakeable_her.gemspec +2 -3
  18. data/vendor/gems/her/her.gemspec +4 -5
  19. data/vendor/gems/her/lib/her/api.rb +1 -1
  20. data/vendor/gems/her/lib/her/model/associations/association_proxy.rb +1 -2
  21. data/vendor/gems/her/lib/her/model/orm.rb +41 -29
  22. data/vendor/gems/her/lib/her/model/parse.rb +1 -0
  23. data/vendor/gems/her/lib/her/model/relation.rb +21 -6
  24. data/vendor/gems/her/lib/her/version.rb +1 -1
  25. metadata +52 -139
  26. data/app/models/test_track/create_alias_job.rb +0 -18
  27. data/vendor/gems/her/CONTRIBUTING.md +0 -26
  28. data/vendor/gems/her/Gemfile +0 -10
  29. data/vendor/gems/her/README.md +0 -1023
  30. data/vendor/gems/her/Rakefile +0 -11
  31. data/vendor/gems/her/UPGRADE.md +0 -101
  32. data/vendor/gems/her/gemfiles/Gemfile.activemodel-3.2.x +0 -7
  33. data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.0 +0 -7
  34. data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.1 +0 -7
  35. data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.2 +0 -7
  36. data/vendor/gems/her/spec/api_spec.rb +0 -114
  37. data/vendor/gems/her/spec/collection_spec.rb +0 -26
  38. data/vendor/gems/her/spec/error_collection_spec.rb +0 -33
  39. data/vendor/gems/her/spec/json_api/model_spec.rb +0 -168
  40. data/vendor/gems/her/spec/middleware/accept_json_spec.rb +0 -10
  41. data/vendor/gems/her/spec/middleware/first_level_parse_json_spec.rb +0 -62
  42. data/vendor/gems/her/spec/middleware/json_api_parser_spec.rb +0 -32
  43. data/vendor/gems/her/spec/middleware/second_level_parse_json_spec.rb +0 -35
  44. data/vendor/gems/her/spec/model/associations/association_proxy_spec.rb +0 -31
  45. data/vendor/gems/her/spec/model/associations_spec.rb +0 -504
  46. data/vendor/gems/her/spec/model/attributes_spec.rb +0 -404
  47. data/vendor/gems/her/spec/model/callbacks_spec.rb +0 -145
  48. data/vendor/gems/her/spec/model/dirty_spec.rb +0 -110
  49. data/vendor/gems/her/spec/model/http_spec.rb +0 -165
  50. data/vendor/gems/her/spec/model/introspection_spec.rb +0 -76
  51. data/vendor/gems/her/spec/model/nested_attributes_spec.rb +0 -134
  52. data/vendor/gems/her/spec/model/orm_spec.rb +0 -791
  53. data/vendor/gems/her/spec/model/parse_spec.rb +0 -372
  54. data/vendor/gems/her/spec/model/paths_spec.rb +0 -347
  55. data/vendor/gems/her/spec/model/relation_spec.rb +0 -226
  56. data/vendor/gems/her/spec/model/validations_spec.rb +0 -42
  57. data/vendor/gems/her/spec/model_spec.rb +0 -31
  58. data/vendor/gems/her/spec/spec_helper.rb +0 -27
  59. data/vendor/gems/her/spec/support/extensions/array.rb +0 -5
  60. data/vendor/gems/her/spec/support/extensions/hash.rb +0 -5
  61. data/vendor/gems/her/spec/support/macros/her_macros.rb +0 -17
  62. data/vendor/gems/her/spec/support/macros/model_macros.rb +0 -36
  63. data/vendor/gems/her/spec/support/macros/request_macros.rb +0 -27
  64. data/vendor/gems/publicsuffix-ruby/CHANGELOG.md +0 -236
  65. data/vendor/gems/publicsuffix-ruby/Gemfile +0 -3
  66. data/vendor/gems/publicsuffix-ruby/LICENSE.txt +0 -22
  67. data/vendor/gems/publicsuffix-ruby/README.md +0 -151
  68. data/vendor/gems/publicsuffix-ruby/Rakefile +0 -109
  69. data/vendor/gems/publicsuffix-ruby/lib/definitions.txt +0 -11467
  70. data/vendor/gems/publicsuffix-ruby/lib/public_suffix/domain.rb +0 -387
  71. data/vendor/gems/publicsuffix-ruby/lib/public_suffix/errors.rb +0 -53
  72. data/vendor/gems/publicsuffix-ruby/lib/public_suffix/list.rb +0 -302
  73. data/vendor/gems/publicsuffix-ruby/lib/public_suffix/rule.rb +0 -373
  74. data/vendor/gems/publicsuffix-ruby/lib/public_suffix/version.rb +0 -23
  75. data/vendor/gems/publicsuffix-ruby/lib/public_suffix.rb +0 -131
  76. data/vendor/gems/publicsuffix-ruby/public_suffix.gemspec +0 -39
  77. data/vendor/gems/publicsuffix-ruby/test/acceptance_test.rb +0 -42
  78. data/vendor/gems/publicsuffix-ruby/test/test_helper.rb +0 -6
  79. data/vendor/gems/publicsuffix-ruby/test/unit/domain_test.rb +0 -170
  80. data/vendor/gems/publicsuffix-ruby/test/unit/errors_test.rb +0 -23
  81. data/vendor/gems/publicsuffix-ruby/test/unit/list_test.rb +0 -179
  82. data/vendor/gems/publicsuffix-ruby/test/unit/public_suffix_test.rb +0 -115
  83. data/vendor/gems/publicsuffix-ruby/test/unit/rule_test.rb +0 -307
  84. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/capybara_configuration.rb +0 -98
  85. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/matchers.rb +0 -151
  86. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rspec_configuration.rb +0 -34
  87. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/html_safe.rb +0 -15
  88. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/raw.rb +0 -15
  89. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/safe_concat.rb +0 -15
  90. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop.rb +0 -3
  91. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/shared_examples/betterment_application_examples.rb +0 -43
  92. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/shared_examples.rb +0 -1
  93. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/site_prism_configuration.rb +0 -42
  94. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/site_prism_dropdown.rb +0 -17
  95. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/version.rb +0 -3
  96. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/webmock_configuration.rb +0 -8
  97. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers.rb +0 -2
  98. data/vendor/gems/ruby_spec_helpers/ruby_spec_helpers.gemspec +0 -25
@@ -1,131 +0,0 @@
1
- #--
2
- # Public Suffix
3
- #
4
- # Domain name parser based on the Public Suffix List.
5
- #
6
- # Copyright (c) 2009-2014 Simone Carletti <weppos@weppos.net>
7
- #++
8
-
9
-
10
- require 'public_suffix/domain'
11
- require 'public_suffix/version'
12
- require 'public_suffix/errors'
13
- require 'public_suffix/rule'
14
- require 'public_suffix/list'
15
-
16
-
17
- module PublicSuffix
18
-
19
- NAME = "Public Suffix"
20
- GEM = "public_suffix"
21
- AUTHORS = ["Simone Carletti <weppos@weppos.net>"]
22
-
23
-
24
- # Parses +domain+ and returns the
25
- # {PublicSuffix::Domain} instance.
26
- #
27
- # @param [String, #to_s] domain
28
- # The domain name or fully qualified domain name to parse.
29
- # @param [PublicSuffix::List] list
30
- # The rule list to search, defaults to the default {PublicSuffix::List}
31
- #
32
- # @return [PublicSuffix::Domain]
33
- #
34
- # @example Parse a valid domain
35
- # PublicSuffix.parse("google.com")
36
- # # => #<PublicSuffix::Domain ...>
37
- #
38
- # @example Parse a valid subdomain
39
- # PublicSuffix.parse("www.google.com")
40
- # # => #<PublicSuffix::Domain ...>
41
- #
42
- # @example Parse a fully qualified domain
43
- # PublicSuffix.parse("google.com.")
44
- # # => #<PublicSuffix::Domain ...>
45
- #
46
- # @example Parse a fully qualified domain (subdomain)
47
- # PublicSuffix.parse("www.google.com.")
48
- # # => #<PublicSuffix::Domain ...>
49
- #
50
- # @example Parse an invalid domain
51
- # PublicSuffix.parse("x.yz")
52
- # # => PublicSuffix::DomainInvalid
53
- #
54
- # @example Parse an URL (not supported, only domains)
55
- # PublicSuffix.parse("http://www.google.com")
56
- # # => PublicSuffix::DomainInvalid
57
- #
58
- # @raise [PublicSuffix::Error]
59
- # If domain is not a valid domain.
60
- # @raise [PublicSuffix::DomainNotAllowed]
61
- # If a rule for +domain+ is found, but the rule
62
- # doesn't allow +domain+.
63
- #
64
- def self.parse(domain, list = List.default)
65
- rule = list.find(domain)
66
-
67
- if rule.nil?
68
- raise DomainInvalid, "`#{domain}' is not a valid domain"
69
- end
70
- if !rule.allow?(domain)
71
- raise DomainNotAllowed, "`#{domain}' is not allowed according to Registry policy"
72
- end
73
-
74
- left, right = rule.decompose(domain)
75
-
76
- parts = left.split(".")
77
- # If we have 0 parts left, there is just a tld and no domain or subdomain
78
- # If we have 1 part left, there is just a tld, domain and not subdomain
79
- # If we have 2 parts left, the last part is the domain, the other parts (combined) are the subdomain
80
- tld = right
81
- sld = parts.empty? ? nil : parts.pop
82
- trd = parts.empty? ? nil : parts.join(".")
83
-
84
- Domain.new(tld, sld, trd)
85
- end
86
-
87
- # Checks whether +domain+ is assigned and allowed,
88
- # without actually parsing it.
89
- #
90
- # This method doesn't care whether domain is a domain or subdomain.
91
- # The validation is performed using the default {PublicSuffix::List}.
92
- #
93
- # @param [String, #to_s] domain
94
- # The domain name or fully qualified domain name to validate.
95
- #
96
- # @return [Boolean]
97
- #
98
- # @example Validate a valid domain
99
- # PublicSuffix.valid?("example.com")
100
- # # => true
101
- #
102
- # @example Validate a valid subdomain
103
- # PublicSuffix.valid?("www.example.com")
104
- # # => true
105
- #
106
- # @example Validate a not-assigned domain
107
- # PublicSuffix.valid?("example.qqq")
108
- # # => false
109
- #
110
- # @example Validate a not-allowed domain
111
- # PublicSuffix.valid?("example.do")
112
- # # => false
113
- # PublicSuffix.valid?("www.example.do")
114
- # # => true
115
- #
116
- # @example Validate a fully qualified domain
117
- # PublicSuffix.valid?("google.com.")
118
- # # => true
119
- # PublicSuffix.valid?("www.google.com.")
120
- # # => true
121
- #
122
- # @example Check an URL (which is not a valid domain)
123
- # PublicSuffix.valid?("http://www.example.com")
124
- # # => false
125
- #
126
- def self.valid?(domain)
127
- rule = List.default.find(domain)
128
- !rule.nil? && rule.allow?(domain)
129
- end
130
-
131
- end
@@ -1,39 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- # stub: public_suffix 1.4.6.1-betterment ruby lib
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "public_suffix"
6
- s.version = "1.4.6.1.betterment"
7
-
8
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
- s.require_paths = ["lib"]
10
- s.authors = ["Simone Carletti"]
11
- s.date = "2014-09-10"
12
- s.description = "PublicSuffix can parse and decompose a domain name into top level domain, domain and subdomains."
13
- s.email = "weppos@weppos.net"
14
- s.files = [".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG.md", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "lib/definitions.txt", "lib/public_suffix.rb", "lib/public_suffix/domain.rb", "lib/public_suffix/errors.rb", "lib/public_suffix/list.rb", "lib/public_suffix/rule.rb", "lib/public_suffix/version.rb", "public_suffix.gemspec", "test/acceptance_test.rb", "test/test_helper.rb", "test/unit/domain_test.rb", "test/unit/errors_test.rb", "test/unit/list_test.rb", "test/unit/public_suffix_test.rb", "test/unit/rule_test.rb"]
15
- s.homepage = "http://simonecarletti.com/code/publicsuffix"
16
- s.licenses = ["MIT"]
17
- s.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
18
- s.rubygems_version = "2.2.2"
19
- s.summary = "Domain name parser based on the Public Suffix List."
20
- s.test_files = ["test/acceptance_test.rb", "test/test_helper.rb", "test/unit/domain_test.rb", "test/unit/errors_test.rb", "test/unit/list_test.rb", "test/unit/public_suffix_test.rb", "test/unit/rule_test.rb"]
21
-
22
- if s.respond_to? :specification_version then
23
- s.specification_version = 4
24
-
25
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_development_dependency(%q<rake>, [">= 0"])
27
- s.add_development_dependency(%q<mocha>, [">= 0"])
28
- s.add_development_dependency(%q<yard>, [">= 0"])
29
- else
30
- s.add_dependency(%q<rake>, [">= 0"])
31
- s.add_dependency(%q<mocha>, [">= 0"])
32
- s.add_dependency(%q<yard>, [">= 0"])
33
- end
34
- else
35
- s.add_dependency(%q<rake>, [">= 0"])
36
- s.add_dependency(%q<mocha>, [">= 0"])
37
- s.add_dependency(%q<yard>, [">= 0"])
38
- end
39
- end
@@ -1,42 +0,0 @@
1
- require 'test_helper'
2
-
3
- class AcceptanceTest < Test::Unit::TestCase
4
-
5
- ValidCases = {
6
- "google.com" => [nil, "google", "com"],
7
- "foo.google.com" => ["foo", "google", "com"],
8
-
9
- "verybritish.co.uk" => [nil, "verybritish", "co.uk"],
10
- "foo.verybritish.co.uk" => ["foo", "verybritish", "co.uk"],
11
-
12
- "parliament.uk" => [nil, "parliament", "uk"],
13
- "foo.parliament.uk" => ["foo", "parliament", "uk"],
14
- }
15
-
16
- def test_valid
17
- ValidCases.each do |name, results|
18
- domain = PublicSuffix.parse(name)
19
- trd, sld, tld = results
20
- assert_equal tld, domain.tld, "Invalid tld for '#{name}'"
21
- assert_equal sld, domain.sld, "Invalid sld for '#{name}'"
22
- assert_equal trd, domain.trd, "Invalid trd for '#{name}'"
23
- assert PublicSuffix.valid?(name)
24
- end
25
- end
26
-
27
- InvalidCases = [
28
- ["nic.ke", PublicSuffix::DomainNotAllowed],
29
- ["http://www.google.com", PublicSuffix::DomainInvalid],
30
- [nil, PublicSuffix::DomainInvalid],
31
- ["", PublicSuffix::DomainInvalid],
32
- [" ", PublicSuffix::DomainInvalid],
33
- ]
34
-
35
- def test_invalid
36
- InvalidCases.each do |(name, error)|
37
- assert_raise(error) { PublicSuffix.parse(name) }
38
- assert !PublicSuffix.valid?(name)
39
- end
40
- end
41
-
42
- end
@@ -1,6 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'mocha/setup'
4
-
5
- $:.unshift File.expand_path('../../lib', __FILE__)
6
- require 'public_suffix'
@@ -1,170 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PublicSuffix::DomainTest < Test::Unit::TestCase
4
-
5
- def setup
6
- @klass = PublicSuffix::Domain
7
- end
8
-
9
- # Tokenizes given input into labels.
10
- def test_self_domain_to_labels
11
- assert_equal %w( com live spaces someone ),
12
- PublicSuffix::Domain.domain_to_labels("someone.spaces.live.com")
13
- assert_equal %w( com zoho wiki leontina23samiko ),
14
- PublicSuffix::Domain.domain_to_labels("leontina23samiko.wiki.zoho.com")
15
- end
16
-
17
- # Converts input into String.
18
- def test_self_domain_to_labels_converts_input_to_string
19
- assert_equal %w( com live spaces someone ),
20
- PublicSuffix::Domain.domain_to_labels(:"someone.spaces.live.com")
21
- end
22
-
23
- # Ignores trailing .
24
- def test_self_domain_to_labels_ignores_trailing_dot
25
- assert_equal %w( com live spaces someone ),
26
- PublicSuffix::Domain.domain_to_labels("someone.spaces.live.com")
27
- assert_equal %w( com live spaces someone ),
28
- PublicSuffix::Domain.domain_to_labels(:"someone.spaces.live.com")
29
- end
30
-
31
-
32
- def test_initialize_with_tld
33
- domain = @klass.new("com")
34
- assert_equal "com", domain.tld
35
- assert_equal nil, domain.sld
36
- assert_equal nil, domain.trd
37
- end
38
-
39
- def test_initialize_with_tld_and_sld
40
- domain = @klass.new("com", "google")
41
- assert_equal "com", domain.tld
42
- assert_equal "google", domain.sld
43
- assert_equal nil, domain.trd
44
- end
45
-
46
- def test_initialize_with_tld_and_sld_and_trd
47
- domain = @klass.new("com", "google", "www")
48
- assert_equal "com", domain.tld
49
- assert_equal "google", domain.sld
50
- assert_equal "www", domain.trd
51
- end
52
-
53
-
54
- def test_to_s
55
- assert_equal "com", @klass.new("com").to_s
56
- assert_equal "google.com", @klass.new("com", "google").to_s
57
- assert_equal "www.google.com", @klass.new("com", "google", "www").to_s
58
- end
59
-
60
- def test_to_a
61
- assert_equal [nil, nil, "com"], @klass.new("com").to_a
62
- assert_equal [nil, "google", "com"], @klass.new("com", "google").to_a
63
- assert_equal ["www", "google", "com"], @klass.new("com", "google", "www").to_a
64
- end
65
-
66
-
67
- def test_tld
68
- assert_equal "com", @klass.new("com", "google", "www").tld
69
- end
70
-
71
- def test_sld
72
- assert_equal "google", @klass.new("com", "google", "www").sld
73
- end
74
-
75
- def test_trd
76
- assert_equal "www", @klass.new("com", "google", "www").trd
77
- end
78
-
79
-
80
- def test_name
81
- assert_equal "com", @klass.new("com").name
82
- assert_equal "google.com", @klass.new("com", "google").name
83
- assert_equal "www.google.com", @klass.new("com", "google", "www").name
84
- end
85
-
86
- def test_domain
87
- assert_equal nil, @klass.new("com").domain
88
- assert_equal nil, @klass.new("qqq").domain
89
- assert_equal "google.com", @klass.new("com", "google").domain
90
- assert_equal "google.qqq", @klass.new("qqq", "google").domain
91
- assert_equal "google.com", @klass.new("com", "google", "www").domain
92
- assert_equal "google.qqq", @klass.new("qqq", "google", "www").domain
93
- end
94
-
95
- def test_subdomain
96
- assert_equal nil, @klass.new("com").subdomain
97
- assert_equal nil, @klass.new("qqq").subdomain
98
- assert_equal nil, @klass.new("com", "google").subdomain
99
- assert_equal nil, @klass.new("qqq", "google").subdomain
100
- assert_equal "www.google.com", @klass.new("com", "google", "www").subdomain
101
- assert_equal "www.google.qqq", @klass.new("qqq", "google", "www").subdomain
102
- end
103
-
104
- def test_rule
105
- assert_equal nil, @klass.new("qqq").rule
106
- assert_equal PublicSuffix::Rule.factory("com"), @klass.new("com").rule
107
- assert_equal PublicSuffix::Rule.factory("com"), @klass.new("com", "google").rule
108
- assert_equal PublicSuffix::Rule.factory("com"), @klass.new("com", "google", "www").rule
109
- end
110
-
111
-
112
- def test_domain_question
113
- assert @klass.new("com", "google").domain?
114
- assert @klass.new("qqq", "google").domain?
115
- assert @klass.new("com", "google", "www").domain?
116
- assert !@klass.new("com").domain?
117
- end
118
-
119
- def test_subdomain_question
120
- assert @klass.new("com", "google", "www").subdomain?
121
- assert @klass.new("qqq", "google", "www").subdomain?
122
- assert !@klass.new("com").subdomain?
123
- assert !@klass.new("com", "google").subdomain?
124
- end
125
-
126
- def test_is_a_domain_question
127
- assert @klass.new("com", "google").is_a_domain?
128
- assert @klass.new("qqq", "google").is_a_domain?
129
- assert !@klass.new("com", "google", "www").is_a_domain?
130
- assert !@klass.new("com").is_a_domain?
131
- end
132
-
133
- def test_is_a_subdomain_question
134
- assert @klass.new("com", "google", "www").is_a_subdomain?
135
- assert @klass.new("qqq", "google", "www").is_a_subdomain?
136
- assert !@klass.new("com").is_a_subdomain?
137
- assert !@klass.new("com", "google").is_a_subdomain?
138
- end
139
-
140
- def test_valid_question
141
- assert !@klass.new("com").valid?
142
- assert @klass.new("com", "example").valid?
143
- assert @klass.new("com", "example", "www").valid?
144
-
145
- # not-assigned
146
- assert !@klass.new("qqq").valid?
147
- assert !@klass.new("qqq", "example").valid?
148
- assert !@klass.new("qqq", "example", "www").valid?
149
-
150
- # not-allowed
151
- assert !@klass.new("ke").valid?
152
- assert !@klass.new("ke", "example").valid?
153
- assert @klass.new("ke", "example", "www").valid?
154
- end
155
-
156
- def test_valid_domain_question
157
- assert @klass.new("com", "google").valid_domain?
158
- assert !@klass.new("qqq", "google").valid_domain?
159
- assert @klass.new("com", "google", "www").valid_domain?
160
- assert !@klass.new("com").valid_domain?
161
- end
162
-
163
- def test_valid_subdomain_question
164
- assert @klass.new("com", "google", "www").valid_subdomain?
165
- assert !@klass.new("qqq", "google", "www").valid_subdomain?
166
- assert !@klass.new("com").valid_subdomain?
167
- assert !@klass.new("com", "google").valid_subdomain?
168
- end
169
-
170
- end
@@ -1,23 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ErrorsTest < Test::Unit::TestCase
4
-
5
- # Inherits from StandardError
6
- def test_error_inheritance
7
- assert_kind_of StandardError,
8
- PublicSuffix::Error.new
9
- end
10
-
11
- # Inherits from PublicSuffix::Error
12
- def test_domain_invalid_inheritance
13
- assert_kind_of PublicSuffix::Error,
14
- PublicSuffix::DomainInvalid.new
15
- end
16
-
17
- # Inherits from PublicSuffix::DomainInvalid
18
- def test_domain_not_allowed_inheritance
19
- assert_kind_of PublicSuffix::DomainInvalid,
20
- PublicSuffix::DomainNotAllowed.new
21
- end
22
-
23
- end
@@ -1,179 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PublicSuffix::ListTest < Test::Unit::TestCase
4
-
5
- def setup
6
- @list = PublicSuffix::List.new
7
- end
8
-
9
- def teardown
10
- PublicSuffix::List.clear
11
- end
12
-
13
-
14
- def test_initialize
15
- assert_instance_of PublicSuffix::List, @list
16
- assert_equal 0, @list.length
17
- end
18
-
19
- def test_initialize_create_index_when_empty
20
- assert_equal({}, @list.indexes)
21
- end
22
-
23
- def test_indexes
24
- assert !list.indexes.empty?
25
- assert_equal [1,2,3,4], list.indexes.delete('uk')
26
- assert_equal [0], list.indexes.delete('com')
27
- assert list.indexes.empty?
28
- end
29
-
30
-
31
- def test_equality_with_self
32
- list = PublicSuffix::List.new
33
- assert_equal list, list
34
- end
35
-
36
- def test_equality_with_internals
37
- rule = PublicSuffix::Rule.factory("com")
38
- assert_equal PublicSuffix::List.new.add(rule), PublicSuffix::List.new.add(rule)
39
- end
40
-
41
- def test_add
42
- assert_equal @list, @list.add(PublicSuffix::Rule.factory(""))
43
- assert_equal @list, @list << PublicSuffix::Rule.factory("")
44
- assert_equal 2, @list.length
45
- end
46
-
47
- def test_add_should_recreate_index
48
- @list = PublicSuffix::List.parse("com")
49
- assert_equal PublicSuffix::Rule.factory("com"), @list.find("google.com")
50
- assert_equal nil, @list.find("google.net")
51
-
52
- @list << PublicSuffix::Rule.factory("net")
53
- assert_equal PublicSuffix::Rule.factory("com"), @list.find("google.com")
54
- assert_equal PublicSuffix::Rule.factory("net"), @list.find("google.net")
55
- end
56
-
57
- def test_empty?
58
- assert @list.empty?
59
- @list.add(PublicSuffix::Rule.factory(""))
60
- assert !@list.empty?
61
- end
62
-
63
- def test_size
64
- assert_equal 0, @list.length
65
- assert_equal @list, @list.add(PublicSuffix::Rule.factory(""))
66
- assert_equal 1, @list.length
67
- end
68
-
69
- def test_clear
70
- assert_equal 0, @list.length
71
- assert_equal @list, @list.add(PublicSuffix::Rule.factory(""))
72
- assert_equal 1, @list.length
73
- assert_equal @list, @list.clear
74
- assert_equal 0, @list.length
75
- end
76
-
77
-
78
- def test_find
79
- assert_equal PublicSuffix::Rule.factory("com"), list.find("google.com")
80
- assert_equal PublicSuffix::Rule.factory("com"), list.find("foo.google.com")
81
- assert_equal PublicSuffix::Rule.factory("*.uk"), list.find("google.uk")
82
- assert_equal PublicSuffix::Rule.factory("*.uk"), list.find("google.co.uk")
83
- assert_equal PublicSuffix::Rule.factory("*.uk"), list.find("foo.google.co.uk")
84
- assert_equal PublicSuffix::Rule.factory("!british-library.uk"), list.find("british-library.uk")
85
- assert_equal PublicSuffix::Rule.factory("!british-library.uk"), list.find("foo.british-library.uk")
86
- end
87
-
88
- def test_select
89
- assert_equal 2, list.select("british-library.uk").size
90
- end
91
-
92
- def test_select_returns_empty_when_domain_has_scheme
93
- assert_equal [], list.select("http://google.com")
94
- assert_not_equal [], list.select("google.com")
95
- end
96
-
97
- def test_select_returns_empty_when_domain_is_nil
98
- assert_equal [], list.select(nil)
99
- end
100
-
101
- def test_select_returns_empty_when_domain_is_blank
102
- assert_equal [], list.select("")
103
- assert_equal [], list.select(" ")
104
- end
105
-
106
-
107
- def test_self_default_getter
108
- assert_equal nil, PublicSuffix::List.class_eval { @default }
109
- PublicSuffix::List.default
110
- assert_not_equal nil, PublicSuffix::List.class_eval { @default }
111
- end
112
-
113
- def test_self_default_setter
114
- PublicSuffix::List.default
115
- assert_not_equal nil, PublicSuffix::List.class_eval { @default }
116
- PublicSuffix::List.default = nil
117
- assert_equal nil, PublicSuffix::List.class_eval { @default }
118
- end
119
-
120
- def test_self_clear
121
- PublicSuffix::List.default
122
- assert_not_equal nil, PublicSuffix::List.class_eval { @default }
123
- PublicSuffix::List.clear
124
- assert_equal nil, PublicSuffix::List.class_eval { @default }
125
- end
126
-
127
- def test_self_reload
128
- PublicSuffix::List.default
129
- PublicSuffix::List.expects(:default_definition).returns("")
130
-
131
- PublicSuffix::List.reload
132
- assert_equal PublicSuffix::List.new, PublicSuffix::List.default
133
- end
134
-
135
- def test_self_parse
136
- list = PublicSuffix::List.parse(<<EOS)
137
- // ***** BEGIN LICENSE BLOCK *****
138
- // Version: MPL 1.1/GPL 2.0/LGPL 2.1
139
- //
140
- // ***** END LICENSE BLOCK *****
141
-
142
- // ac : http://en.wikipedia.org/wiki/.ac
143
- ac
144
- com.ac
145
-
146
- // ad : http://en.wikipedia.org/wiki/.ad
147
- ad
148
-
149
- // ar : http://en.wikipedia.org/wiki/.ar
150
- *.ar
151
- !congresodelalengua3.ar
152
- EOS
153
-
154
- assert_instance_of PublicSuffix::List, list
155
- assert_equal 5, list.length
156
- assert_equal %w(ac com.ac ad *.ar !congresodelalengua3.ar).map { |name| PublicSuffix::Rule.factory(name) }, list.to_a
157
- end
158
-
159
- def test_self_parse_should_create_cache
160
- assert_equal PublicSuffix::Rule.factory("com"), list.find("google.com")
161
- end
162
-
163
-
164
- private
165
-
166
- def list
167
- @_list ||= PublicSuffix::List.parse(<<EOS)
168
- // com : http://en.wikipedia.org/wiki/.com
169
- com
170
-
171
- // uk : http://en.wikipedia.org/wiki/.uk
172
- *.uk
173
- *.sch.uk
174
- !bl.uk
175
- !british-library.uk
176
- EOS
177
- end
178
-
179
- end