rails_uri_validator 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -8,5 +8,7 @@ source "http://rubygems.org"
8
8
  group :development do
9
9
  gem "bundler", "~> 1.0.0"
10
10
  gem "jeweler", "~> 1.5.2"
11
- gem "cover_me"
11
+ gem 'simplecov', '>= 0.3.8', :require => false
12
+ gem "rspec", "~> 2.3.0"
13
+ gem "yard", "~> 0.6.0"
12
14
  end
@@ -7,20 +7,26 @@ GEM
7
7
  i18n (~> 0.4)
8
8
  activesupport (3.0.3)
9
9
  builder (2.1.2)
10
- configatron (2.6.4)
11
- yamler (>= 0.1.0)
12
- cover_me (1.0.0.rc5)
13
- configatron
14
- hashie
10
+ diff-lcs (1.1.2)
15
11
  git (1.2.5)
16
- hashie (0.4.0)
17
12
  i18n (0.5.0)
18
13
  jeweler (1.5.2)
19
14
  bundler (~> 1.0.0)
20
15
  git (>= 1.2.5)
21
16
  rake
22
17
  rake (0.8.7)
23
- yamler (0.1.0)
18
+ rspec (2.3.0)
19
+ rspec-core (~> 2.3.0)
20
+ rspec-expectations (~> 2.3.0)
21
+ rspec-mocks (~> 2.3.0)
22
+ rspec-core (2.3.1)
23
+ rspec-expectations (2.3.0)
24
+ diff-lcs (~> 1.1.2)
25
+ rspec-mocks (2.3.0)
26
+ simplecov (0.4.0)
27
+ simplecov-html (~> 0.4.0)
28
+ simplecov-html (0.4.3)
29
+ yard (0.6.4)
24
30
 
25
31
  PLATFORMS
26
32
  ruby
@@ -28,5 +34,7 @@ PLATFORMS
28
34
  DEPENDENCIES
29
35
  activemodel (>= 3.0.0)
30
36
  bundler (~> 1.0.0)
31
- cover_me
32
37
  jeweler (~> 1.5.2)
38
+ rspec (~> 2.3.0)
39
+ simplecov (>= 0.3.8)
40
+ yard (~> 0.6.0)
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ require 'jeweler'
13
13
  Jeweler::Tasks.new do |gem|
14
14
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
15
  gem.name = "rails_uri_validator"
16
- gem.homepage = "http://github.com/traxanos/rails_uri_validator"
16
+ gem.homepage = "http://github.com/phatworx/rails_uri_validator"
17
17
  gem.license = "MIT"
18
18
  gem.summary = %Q{an uri validator for rails}
19
19
  gem.description = %Q{a class to validate uris. it builded for rails}
@@ -21,37 +21,18 @@ Jeweler::Tasks.new do |gem|
21
21
  gem.authors = ["Marco Scholl"]
22
22
  # Include your dependencies below. Runtime dependencies are required when using your gem,
23
23
  # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
- gem.add_runtime_dependency 'activemodel', '>= 3.0.0'
25
- # gem.add_development_dependency 'rspec', '> 1.2.3'
24
+ # gem.add_runtime_dependency 'activemodel', '>= 3.0.0'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
26
  end
27
27
  Jeweler::RubygemsDotOrgTasks.new
28
28
 
29
- require 'rake/testtask'
30
- Rake::TestTask.new(:test) do |test|
31
- test.libs << 'lib' << 'test'
32
- test.pattern = 'test/**/test_*.rb'
33
- test.verbose = true
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
34
33
  end
35
34
 
36
- namespace :cover_me do
37
- task :report do
38
- require 'cover_me'
39
- CoverMe.complete!
40
- end
41
- end
42
-
43
- task :test do
44
- Rake::Task['cover_me:report'].invoke
45
- end
35
+ task :default => :spec
46
36
 
47
- task :default => :test
48
-
49
- require 'rake/rdoctask'
50
- Rake::RDocTask.new do |rdoc|
51
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
52
-
53
- rdoc.rdoc_dir = 'rdoc'
54
- rdoc.title = "rails_uri_validator #{version}"
55
- rdoc.rdoc_files.include('README*')
56
- rdoc.rdoc_files.include('lib/**/*.rb')
57
- end
37
+ require 'yard'
38
+ YARD::Rake::YardocTask.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails_uri_validator}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marco Scholl"]
12
- s.date = %q{2011-01-22}
12
+ s.date = %q{2011-02-13}
13
13
  s.description = %q{a class to validate uris. it builded for rails}
14
14
  s.email = %q{develop@marco-scholl.de}
15
15
  s.extra_rdoc_files = [
@@ -27,42 +27,44 @@ Gem::Specification.new do |s|
27
27
  "init.rb",
28
28
  "lib/rails_uri_validator.rb",
29
29
  "rails_uri_validator.gemspec",
30
- "test/helper.rb",
31
- "test/test_rails_uri_validator.rb"
30
+ "spec/rails_uri_validator_spec.rb",
31
+ "spec/spec_helper.rb"
32
32
  ]
33
- s.homepage = %q{http://github.com/traxanos/rails_uri_validator}
33
+ s.homepage = %q{http://github.com/phatworx/rails_uri_validator}
34
34
  s.licenses = ["MIT"]
35
35
  s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.3.7}
36
+ s.rubygems_version = %q{1.5.0}
37
37
  s.summary = %q{an uri validator for rails}
38
38
  s.test_files = [
39
- "test/helper.rb",
40
- "test/test_rails_uri_validator.rb"
39
+ "spec/rails_uri_validator_spec.rb",
40
+ "spec/spec_helper.rb"
41
41
  ]
42
42
 
43
43
  if s.respond_to? :specification_version then
44
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
44
  s.specification_version = 3
46
45
 
47
46
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
47
  s.add_runtime_dependency(%q<activemodel>, [">= 3.0.0"])
49
48
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
50
49
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
51
- s.add_development_dependency(%q<cover_me>, [">= 0"])
52
- s.add_runtime_dependency(%q<activemodel>, [">= 3.0.0"])
50
+ s.add_development_dependency(%q<simplecov>, [">= 0.3.8"])
51
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
52
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
53
53
  else
54
54
  s.add_dependency(%q<activemodel>, [">= 3.0.0"])
55
55
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
56
56
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
57
- s.add_dependency(%q<cover_me>, [">= 0"])
58
- s.add_dependency(%q<activemodel>, [">= 3.0.0"])
57
+ s.add_dependency(%q<simplecov>, [">= 0.3.8"])
58
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
59
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
59
60
  end
60
61
  else
61
62
  s.add_dependency(%q<activemodel>, [">= 3.0.0"])
62
63
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
63
64
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
64
- s.add_dependency(%q<cover_me>, [">= 0"])
65
- s.add_dependency(%q<activemodel>, [">= 3.0.0"])
65
+ s.add_dependency(%q<simplecov>, [">= 0.3.8"])
66
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
67
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
66
68
  end
67
69
  end
68
70
 
@@ -0,0 +1,195 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
5
+
6
+ describe UriValidator do
7
+ before do
8
+ class ValidateUri
9
+ include ActiveModel::Validations
10
+ attr_accessor :uri
11
+ end
12
+ end
13
+
14
+ describe "default uri validation" do
15
+ before do
16
+ class ValidateDefaultUri < ValidateUri
17
+ validates :uri, :uri => true
18
+ end
19
+ @object = ValidateDefaultUri.new
20
+ end
21
+
22
+
23
+ describe "uri validation with valid uris" do
24
+
25
+ it "should validate without errors" do
26
+ [
27
+ 'test',
28
+ "http://user:pass@www.web.de:80/directory/?querystring#anker",
29
+ "https://user:pass@www.web.de:80/directory/?querystring#anker",
30
+ "http://www.web.de:80/directory/?querystring#anker",
31
+ "https://www.web.de:80/directory/?querystring#anker",
32
+ "http://www.web.de/directory/?querystring#anker",
33
+ "https://www.web.de/directory/?querystring#anker",
34
+ "http://www.web.de/directory",
35
+ "https://www.web.de/directory",
36
+ "http://de.wikipedia.org/wiki/Uniform_Resource_Identifier",
37
+ "ftp://ftp.is.co.za/rfc/rfc1808.txt",
38
+ "file:///C:/Dokumente%20und%20Einstellungen/Benutzer/Desktop/Uniform%20Resource%20Identifier.html",
39
+ "geo:48.33,14.122;u=22.5",
40
+ "ldap://[2001:db8::7]/c=GB?objectClass?one",
41
+ "gopher://gopher.floodgap.com",
42
+ "mailto:John.Doe@example.com",
43
+ "sip:911@pbx.mycompany.com",
44
+ "news:comp.infosystems.www.servers.unix",
45
+ # "data:text/plain;charset=iso-8859-7,%be%fg%be", not supported
46
+ "tel:+1-816-555-1212",
47
+ "telnet://192.0.2.16:80/",
48
+ "urn:oasis:names:specification:docbook:dtd:xml:4.1.2"
49
+ ].each do |uri|
50
+ @object.uri = uri
51
+ @object.should be_valid
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+
58
+ describe "uri validation with invalid uris" do
59
+ it "should validate with errors" do
60
+ [
61
+ 1,
62
+ 2.2,
63
+ '##'
64
+ ].each do |uri|
65
+ @object.uri = uri
66
+ @object.should_not be_valid
67
+ end
68
+ end
69
+ end
70
+
71
+ end
72
+
73
+ describe "http uri validation" do
74
+ before do
75
+ class ValidateHttpUri < ValidateUri
76
+ validates :uri, :uri => {:schemes => [:http, :https]}
77
+ end
78
+ @object = ValidateHttpUri.new
79
+ end
80
+
81
+ describe "http uri validation with valid uris" do
82
+ it "should validate without errors" do
83
+ [
84
+ "http://user:pass@www.web.de:80/directory/?querystring#anker",
85
+ "https://user:pass@www.web.de:80/directory/?querystring#anker",
86
+ "http://www.web.de:80/directory/?querystring#anker",
87
+ "https://www.web.de:80/directory/?querystring#anker",
88
+ "http://www.web.de/directory/?querystring#anker",
89
+ "https://www.web.de/directory/?querystring#anker",
90
+ "http://www.web.de/directory",
91
+ "https://www.web.de/directory",
92
+ "http://de.wikipedia.org/wiki/Uniform_Resource_Identifier"
93
+ ].each do |uri|
94
+ @object.uri = uri
95
+ @object.should be_valid
96
+ end
97
+ end
98
+ end
99
+
100
+ describe "http uri validation with invalid uris" do
101
+ it "should validate with errors" do
102
+ [
103
+ "ftp://ftp.is.co.za/rfc/rfc1808.txt",
104
+ "file:///C:/Dokumente%20und%20Einstellungen/Benutzer/Desktop/Uniform%20Resource%20Identifier.html",
105
+ "geo:48.33,14.122;u=22.5",
106
+ "ldap://[2001:db8::7]/c=GB?objectClass?one",
107
+ "gopher://gopher.floodgap.com",
108
+ "mailto:John.Doe@example.com",
109
+ "sip:911@pbx.mycompany.com",
110
+ "news:comp.infosystems.www.servers.unix",
111
+ "tel:+1-816-555-1212",
112
+ "telnet://192.0.2.16:80/",
113
+ "urn:oasis:names:specification:docbook:dtd:xml:4.1.2"
114
+ ].each do |uri|
115
+ @object.uri = uri
116
+ @object.should_not be_valid
117
+ end
118
+ end
119
+ end
120
+ end
121
+
122
+ describe "mailto uri validation" do
123
+ before do
124
+ class ValidateMailtoUri < ValidateUri
125
+ validates :uri, :uri => {:schemes => :mailto}
126
+ end
127
+ @object = ValidateMailtoUri.new
128
+ end
129
+
130
+ describe "http uri validation with valid uris" do
131
+ it "should validate without errors" do
132
+ [
133
+ "mailto:test@example.net",
134
+ "mailto:test@example.net?subject=Test"
135
+ ].each do |uri|
136
+ @object.uri = uri
137
+ @object.should be_valid
138
+ end
139
+ end
140
+ end
141
+
142
+ describe "http uri validation with invalid uris" do
143
+ it "should validate with errors" do
144
+ [
145
+ "ftp://ftp.is.co.za/rfc/rfc1808.txt",
146
+ "file:///C:/Dokumente%20und%20Einstellungen/Benutzer/Desktop/Uniform%20Resource%20Identifier.html",
147
+ "geo:48.33,14.122;u=22.5",
148
+ "ldap://[2001:db8::7]/c=GB?objectClass?one",
149
+ "gopher://gopher.floodgap.com",
150
+ "sip:911@pbx.mycompany.com",
151
+ "news:comp.infosystems.www.servers.unix",
152
+ "tel:+1-816-555-1212",
153
+ "telnet://192.0.2.16:80/",
154
+ "urn:oasis:names:specification:docbook:dtd:xml:4.1.2"
155
+ ].each do |uri|
156
+ @object.uri = uri
157
+ @object.should_not be_valid
158
+ end
159
+ end
160
+ end
161
+ end
162
+
163
+ describe "custom uri validation" do
164
+ before do
165
+ class ValidateCustomUri < ValidateUri
166
+ validates :uri, :uri => {:schemes => [:http, :https], :custom => Proc.new { |uri| uri.userinfo == nil }}
167
+ end
168
+ @object = ValidateCustomUri.new
169
+ end
170
+
171
+ describe "custom uri validation with valid uris" do
172
+ it "should validate without errors" do
173
+ [
174
+ "http://example.net",
175
+ "http://example.net/test"
176
+ ].each do |uri|
177
+ @object.uri = uri
178
+ @object.should be_valid
179
+ end
180
+ end
181
+ end
182
+
183
+ describe "custom uri validation with invalid uris" do
184
+ it "should validate with errors" do
185
+ [
186
+ "http://test@example.net",
187
+ "http://test:test@example.net/test"
188
+ ].each do |uri|
189
+ @object.uri = uri
190
+ @object.should_not be_valid
191
+ end
192
+ end
193
+ end
194
+ end
195
+ end
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'simplecov'
4
+ SimpleCov.start 'rails'
5
+ require 'rspec'
6
+ require 'rails_uri_validator'
7
+
8
+ # Requires supporting files with custom matchers and macros, etc,
9
+ # in ./support/ and its subdirectories.
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
12
+ RSpec.configure do |config|
13
+
14
+ end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_uri_validator
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 1
9
- version: 0.1.1
4
+ prerelease:
5
+ version: 0.1.2
10
6
  platform: ruby
11
7
  authors:
12
8
  - Marco Scholl
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-01-22 00:00:00 +01:00
13
+ date: 2011-02-13 00:00:00 +01:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -24,10 +20,6 @@ dependencies:
24
20
  requirements:
25
21
  - - ">="
26
22
  - !ruby/object:Gem::Version
27
- segments:
28
- - 3
29
- - 0
30
- - 0
31
23
  version: 3.0.0
32
24
  type: :runtime
33
25
  prerelease: false
@@ -39,10 +31,6 @@ dependencies:
39
31
  requirements:
40
32
  - - ~>
41
33
  - !ruby/object:Gem::Version
42
- segments:
43
- - 1
44
- - 0
45
- - 0
46
34
  version: 1.0.0
47
35
  type: :development
48
36
  prerelease: false
@@ -54,42 +42,43 @@ dependencies:
54
42
  requirements:
55
43
  - - ~>
56
44
  - !ruby/object:Gem::Version
57
- segments:
58
- - 1
59
- - 5
60
- - 2
61
45
  version: 1.5.2
62
46
  type: :development
63
47
  prerelease: false
64
48
  version_requirements: *id003
65
49
  - !ruby/object:Gem::Dependency
66
- name: cover_me
50
+ name: simplecov
67
51
  requirement: &id004 !ruby/object:Gem::Requirement
68
52
  none: false
69
53
  requirements:
70
54
  - - ">="
71
55
  - !ruby/object:Gem::Version
72
- segments:
73
- - 0
74
- version: "0"
56
+ version: 0.3.8
75
57
  type: :development
76
58
  prerelease: false
77
59
  version_requirements: *id004
78
60
  - !ruby/object:Gem::Dependency
79
- name: activemodel
61
+ name: rspec
80
62
  requirement: &id005 !ruby/object:Gem::Requirement
81
63
  none: false
82
64
  requirements:
83
- - - ">="
65
+ - - ~>
84
66
  - !ruby/object:Gem::Version
85
- segments:
86
- - 3
87
- - 0
88
- - 0
89
- version: 3.0.0
90
- type: :runtime
67
+ version: 2.3.0
68
+ type: :development
91
69
  prerelease: false
92
70
  version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: yard
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 0.6.0
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: *id006
93
82
  description: a class to validate uris. it builded for rails
94
83
  email: develop@marco-scholl.de
95
84
  executables: []
@@ -110,10 +99,10 @@ files:
110
99
  - init.rb
111
100
  - lib/rails_uri_validator.rb
112
101
  - rails_uri_validator.gemspec
113
- - test/helper.rb
114
- - test/test_rails_uri_validator.rb
102
+ - spec/rails_uri_validator_spec.rb
103
+ - spec/spec_helper.rb
115
104
  has_rdoc: true
116
- homepage: http://github.com/traxanos/rails_uri_validator
105
+ homepage: http://github.com/phatworx/rails_uri_validator
117
106
  licenses:
118
107
  - MIT
119
108
  post_install_message:
@@ -126,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
115
  requirements:
127
116
  - - ">="
128
117
  - !ruby/object:Gem::Version
129
- hash: 3481741287608444591
118
+ hash: 212452618284600748
130
119
  segments:
131
120
  - 0
132
121
  version: "0"
@@ -135,16 +124,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
124
  requirements:
136
125
  - - ">="
137
126
  - !ruby/object:Gem::Version
138
- segments:
139
- - 0
140
127
  version: "0"
141
128
  requirements: []
142
129
 
143
130
  rubyforge_project:
144
- rubygems_version: 1.3.7
131
+ rubygems_version: 1.5.0
145
132
  signing_key:
146
133
  specification_version: 3
147
134
  summary: an uri validator for rails
148
135
  test_files:
149
- - test/helper.rb
150
- - test/test_rails_uri_validator.rb
136
+ - spec/rails_uri_validator_spec.rb
137
+ - spec/spec_helper.rb
@@ -1,21 +0,0 @@
1
- # encoding:utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'cover_me'
13
- require 'test/unit'
14
-
15
- $LOAD_PATH.unshift(File.dirname(__FILE__))
16
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
17
- require 'cover_me'
18
- require 'rails_uri_validator'
19
-
20
- class Test::Unit::TestCase
21
- end
@@ -1,149 +0,0 @@
1
- require 'helper'
2
-
3
- class ValidateUri
4
- include ActiveModel::Validations
5
- attr_accessor :uri
6
- end
7
-
8
- class ValidateDefaultUri < ValidateUri
9
- validates :uri, :uri => true
10
- end
11
-
12
- class ValidateHttpUri < ValidateUri
13
- validates :uri, :uri => {:schemes => [:http, :https]}
14
- end
15
-
16
- class ValidateMailtoUri < ValidateUri
17
- validates :uri, :uri => {:schemes => :mailto}
18
- end
19
-
20
- class ValidateCustomUri < ValidateUri
21
- validates :uri, :uri => {:schemes => [:http, :https], :custom => Proc.new { |uri| uri.userinfo == nil }}
22
- end
23
-
24
- class TestRailsUriValidator < Test::Unit::TestCase
25
- def test_valid_uri
26
- instance = ValidateDefaultUri.new
27
- [
28
- 'test',
29
- "http://user:pass@www.web.de:80/directory/?querystring#anker",
30
- "https://user:pass@www.web.de:80/directory/?querystring#anker",
31
- "http://www.web.de:80/directory/?querystring#anker",
32
- "https://www.web.de:80/directory/?querystring#anker",
33
- "http://www.web.de/directory/?querystring#anker",
34
- "https://www.web.de/directory/?querystring#anker",
35
- "http://www.web.de/directory",
36
- "https://www.web.de/directory",
37
- "http://de.wikipedia.org/wiki/Uniform_Resource_Identifier",
38
- "ftp://ftp.is.co.za/rfc/rfc1808.txt",
39
- "file:///C:/Dokumente%20und%20Einstellungen/Benutzer/Desktop/Uniform%20Resource%20Identifier.html",
40
- "geo:48.33,14.122;u=22.5",
41
- "ldap://[2001:db8::7]/c=GB?objectClass?one",
42
- "gopher://gopher.floodgap.com",
43
- "mailto:John.Doe@example.com",
44
- "sip:911@pbx.mycompany.com",
45
- "news:comp.infosystems.www.servers.unix",
46
- # "data:text/plain;charset=iso-8859-7,%be%fg%be", not supported
47
- "tel:+1-816-555-1212",
48
- "telnet://192.0.2.16:80/",
49
- "urn:oasis:names:specification:docbook:dtd:xml:4.1.2"
50
- ].each do |uri|
51
- instance.uri = uri
52
- assert instance.valid?, uri.to_s
53
- end
54
- end
55
-
56
- def test_http_and_https_only
57
- instance = ValidateHttpUri.new
58
- [
59
- "http://user:pass@www.web.de:80/directory/?querystring#anker",
60
- "https://user:pass@www.web.de:80/directory/?querystring#anker",
61
- "http://www.web.de:80/directory/?querystring#anker",
62
- "https://www.web.de:80/directory/?querystring#anker",
63
- "http://www.web.de/directory/?querystring#anker",
64
- "https://www.web.de/directory/?querystring#anker",
65
- "http://www.web.de/directory",
66
- "https://www.web.de/directory",
67
- "http://de.wikipedia.org/wiki/Uniform_Resource_Identifier"
68
- ].each do |uri|
69
- instance.uri = uri
70
- assert instance.valid?, uri.to_s
71
- end
72
-
73
- [
74
- "ftp://ftp.is.co.za/rfc/rfc1808.txt",
75
- "file:///C:/Dokumente%20und%20Einstellungen/Benutzer/Desktop/Uniform%20Resource%20Identifier.html",
76
- "geo:48.33,14.122;u=22.5",
77
- "ldap://[2001:db8::7]/c=GB?objectClass?one",
78
- "gopher://gopher.floodgap.com",
79
- "mailto:John.Doe@example.com",
80
- "sip:911@pbx.mycompany.com",
81
- "news:comp.infosystems.www.servers.unix",
82
- "tel:+1-816-555-1212",
83
- "telnet://192.0.2.16:80/",
84
- "urn:oasis:names:specification:docbook:dtd:xml:4.1.2"
85
- ].each do |uri|
86
- instance.uri = uri
87
- assert !instance.valid?, uri.to_s
88
- end
89
- end
90
-
91
- def test_mailto
92
- instance = ValidateMailtoUri.new
93
- [
94
- "mailto:test@example.net",
95
- "mailto:test@example.net?subject=Test"
96
- ].each do |uri|
97
- instance.uri = uri
98
- assert instance.valid?, uri.to_s
99
- end
100
-
101
- [
102
- "ftp://ftp.is.co.za/rfc/rfc1808.txt",
103
- "file:///C:/Dokumente%20und%20Einstellungen/Benutzer/Desktop/Uniform%20Resource%20Identifier.html",
104
- "geo:48.33,14.122;u=22.5",
105
- "ldap://[2001:db8::7]/c=GB?objectClass?one",
106
- "gopher://gopher.floodgap.com",
107
- "sip:911@pbx.mycompany.com",
108
- "news:comp.infosystems.www.servers.unix",
109
- "tel:+1-816-555-1212",
110
- "telnet://192.0.2.16:80/",
111
- "urn:oasis:names:specification:docbook:dtd:xml:4.1.2"
112
- ].each do |uri|
113
- instance.uri = uri
114
- assert !instance.valid?, uri.to_s
115
- end
116
- end
117
-
118
- def test_custom
119
- instance = ValidateCustomUri.new
120
- [
121
- "http://example.net",
122
- "http://example.net/test"
123
- ].each do |uri|
124
- instance.uri = uri
125
- assert instance.valid?, uri.to_s
126
- end
127
-
128
- [
129
- "http://test@example.net",
130
- "http://test:test@example.net/test"
131
- ].each do |uri|
132
- instance.uri = uri
133
- assert !instance.valid?, uri.to_s
134
- end
135
- end
136
-
137
- def test_invalid
138
- instance = ValidateDefaultUri.new
139
- [
140
- 1,
141
- 2.2,
142
- '##'
143
- ].each do |uri|
144
- instance.uri = uri
145
- assert !instance.valid?, uri.to_s
146
- end
147
- end
148
-
149
- end