validate_url 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.md +21 -0
- data/README.md +63 -0
- data/lib/validate_url.rb +7 -9
- metadata +57 -92
- data/README.markdown +0 -50
- data/spec/resources/user.rb +0 -7
- data/spec/resources/user_with_ar.rb +0 -5
- data/spec/resources/user_with_ar_legacy.rb +0 -5
- data/spec/resources/user_with_blank.rb +0 -9
- data/spec/resources/user_with_custom_scheme.rb +0 -7
- data/spec/resources/user_with_legacy_syntax.rb +0 -9
- data/spec/resources/user_with_nil.rb +0 -9
- data/spec/spec_helper.rb +0 -25
- data/spec/validate_url_spec.rb +0 -160
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 56176990e55020f229be5db2b22de43302d511b8
|
4
|
+
data.tar.gz: 9d64d0c5c462cb659877ac189810286893715ae9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7ddec38758e7ae1c64ce42d07fe23e12ce9eb35ba127b1f7649a5a89ca7af8ecca85b7ce935d1962070d6d1068c30897e706a98abe6555676cd6e1ebc9d4781c
|
7
|
+
data.tar.gz: 668a65dacd3ebce344b060b64cf9d7c0953c985120ed56bc57fd99d0a1c84a20b054aefadce2c778227ff3f610d4693263c865018bef371d4fc98e7d71ebfb56
|
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2010 [PerfectLine](http://www.perfectline.co), LLC
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Validates URL
|
2
|
+
|
3
|
+
This gem adds the capability of validating URLs to ActiveRecord and ActiveModel (Rails 3).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```
|
8
|
+
# add this to your Gemfile
|
9
|
+
gem "validate_url"
|
10
|
+
|
11
|
+
# and run
|
12
|
+
sudo gem install validate_url
|
13
|
+
```
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
### With ActiveRecord
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
class Pony < ActiveRecord::Base
|
21
|
+
# standard validation
|
22
|
+
validates :homepage, :url => true
|
23
|
+
|
24
|
+
# with allow_nil
|
25
|
+
validates :homepage, :url => {:allow_nil => true}
|
26
|
+
|
27
|
+
# with allow_blank
|
28
|
+
validates :homepage, :url => {:allow_blank => true}
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
### With ActiveModel
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
class Unicorn
|
36
|
+
include ActiveModel::Validations
|
37
|
+
|
38
|
+
attr_accessor :homepage
|
39
|
+
|
40
|
+
# with legacy syntax (the syntax above works also)
|
41
|
+
validates_url :homepage, :allow_blank => true
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
### I18n
|
46
|
+
|
47
|
+
The default error message `is not valid url`.
|
48
|
+
You can pass the `:message => "my custom error"` option to your validation to define your own, custom message.
|
49
|
+
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
|
54
|
+
Big thanks to Tanel Suurhans, Tarmo Lehtpuu, Steve Smith and all the [contributors](https://github.com/perfectline/validates_url/contributors)! We appreciate all your work on new features and bugfixes.
|
55
|
+
|
56
|
+
## Credits
|
57
|
+
|
58
|
+
Validates URL is created and maintained by [PerfectLine](http://www.perfectline.co), LLC.
|
59
|
+
|
60
|
+
## License
|
61
|
+
|
62
|
+
Validates URL is Copyright © 2010-2014 [PerfectLine](http://www.perfectline.co), LLC. It is free software, and may be
|
63
|
+
redistributed under the terms specified in the LICENSE file.
|
data/lib/validate_url.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'uri'
|
1
|
+
require 'addressable/uri'
|
2
2
|
require 'active_model'
|
3
3
|
|
4
4
|
module ActiveModel
|
@@ -13,14 +13,12 @@ module ActiveModel
|
|
13
13
|
|
14
14
|
def validate_each(record, attribute, value)
|
15
15
|
schemes = [*options.fetch(:schemes)].map(&:to_s)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
URI.parse(value)
|
20
|
-
rescue URI::InvalidURIError
|
16
|
+
begin
|
17
|
+
uri = Addressable::URI.parse(value)
|
18
|
+
unless uri && schemes.include?(uri.scheme)
|
21
19
|
record.errors.add(attribute, options.fetch(:message), :value => value)
|
22
20
|
end
|
23
|
-
|
21
|
+
rescue Addressable::URI::InvalidURIError
|
24
22
|
record.errors.add(attribute, options.fetch(:message), :value => value)
|
25
23
|
end
|
26
24
|
end
|
@@ -40,10 +38,10 @@ module ActiveModel
|
|
40
38
|
# * <tt>:allow_nil</tt> - If set to true, skips this validation if the attribute is +nil+ (default is +false+).
|
41
39
|
# * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+).
|
42
40
|
# * <tt>:schemes</tt> - Array of URI schemes to validate against. (default is +['http', 'https']+)
|
43
|
-
|
41
|
+
|
44
42
|
def validates_url(*attr_names)
|
45
43
|
validates_with UrlValidator, _merge_attributes(attr_names)
|
46
44
|
end
|
47
45
|
end
|
48
46
|
end
|
49
|
-
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,129 +1,94 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: validate_url
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 0
|
9
|
-
version: 0.2.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- Tanel Suurhans
|
13
8
|
- Tarmo Lehtpuu
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2014-06-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: activemodel
|
23
|
-
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
27
18
|
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 0
|
32
|
-
- 0
|
19
|
+
- !ruby/object:Gem::Version
|
33
20
|
version: 3.0.0
|
34
21
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: rspec
|
38
22
|
prerelease: false
|
39
|
-
|
40
|
-
|
41
|
-
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 3.0.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
42
32
|
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
- 0
|
46
|
-
version: "0"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
47
35
|
type: :development
|
48
|
-
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: diff-lcs
|
51
36
|
prerelease: false
|
52
|
-
|
53
|
-
|
54
|
-
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: diff-lcs
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
55
46
|
- - ">="
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
segments:
|
58
|
-
- 1
|
59
|
-
- 1
|
60
|
-
- 2
|
47
|
+
- !ruby/object:Gem::Version
|
61
48
|
version: 1.1.2
|
62
49
|
type: :development
|
63
|
-
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.1.2
|
64
56
|
description: Library for validating urls in Rails.
|
65
|
-
email:
|
57
|
+
email:
|
66
58
|
- tanel.suurhans@perfectline.ee
|
67
59
|
- tarmo.lehtpuu@perfectline.ee
|
68
60
|
executables: []
|
69
|
-
|
70
61
|
extensions: []
|
71
|
-
|
72
|
-
|
73
|
-
- README.
|
74
|
-
files:
|
75
|
-
-
|
62
|
+
extra_rdoc_files:
|
63
|
+
- LICENSE.md
|
64
|
+
- README.md
|
65
|
+
files:
|
66
|
+
- LICENSE.md
|
67
|
+
- README.md
|
76
68
|
- init.rb
|
77
69
|
- install.rb
|
78
70
|
- lib/validate_url.rb
|
79
|
-
- spec/resources/user.rb
|
80
|
-
- spec/resources/user_with_ar.rb
|
81
|
-
- spec/resources/user_with_ar_legacy.rb
|
82
|
-
- spec/resources/user_with_blank.rb
|
83
|
-
- spec/resources/user_with_custom_scheme.rb
|
84
|
-
- spec/resources/user_with_legacy_syntax.rb
|
85
|
-
- spec/resources/user_with_nil.rb
|
86
|
-
- spec/spec_helper.rb
|
87
|
-
- spec/validate_url_spec.rb
|
88
|
-
has_rdoc: true
|
89
71
|
homepage: http://github.com/perfectline/validates_url/tree/master
|
90
72
|
licenses: []
|
91
|
-
|
73
|
+
metadata: {}
|
92
74
|
post_install_message:
|
93
75
|
rdoc_options: []
|
94
|
-
|
95
|
-
require_paths:
|
76
|
+
require_paths:
|
96
77
|
- lib
|
97
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
-
|
99
|
-
requirements:
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
100
80
|
- - ">="
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
-
none: false
|
107
|
-
requirements:
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
108
85
|
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
|
111
|
-
- 0
|
112
|
-
version: "0"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
113
88
|
requirements: []
|
114
|
-
|
115
89
|
rubyforge_project:
|
116
|
-
rubygems_version:
|
90
|
+
rubygems_version: 2.2.2
|
117
91
|
signing_key:
|
118
|
-
specification_version:
|
92
|
+
specification_version: 4
|
119
93
|
summary: Library for validating urls in Rails.
|
120
|
-
test_files:
|
121
|
-
- spec/resources/user.rb
|
122
|
-
- spec/resources/user_with_ar.rb
|
123
|
-
- spec/resources/user_with_ar_legacy.rb
|
124
|
-
- spec/resources/user_with_blank.rb
|
125
|
-
- spec/resources/user_with_custom_scheme.rb
|
126
|
-
- spec/resources/user_with_legacy_syntax.rb
|
127
|
-
- spec/resources/user_with_nil.rb
|
128
|
-
- spec/spec_helper.rb
|
129
|
-
- spec/validate_url_spec.rb
|
94
|
+
test_files: []
|
data/README.markdown
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# ValidateUrl
|
2
|
-
|
3
|
-
This gem adds the capability of validating URLs to ActiveRecord and ActiveModel (Rails 3).
|
4
|
-
|
5
|
-
### Installation
|
6
|
-
# add this to your Gemfile
|
7
|
-
gem "validate_url"
|
8
|
-
|
9
|
-
# and run
|
10
|
-
sudo gem install validate_url
|
11
|
-
|
12
|
-
### Usage
|
13
|
-
|
14
|
-
#### With ActiveRecord
|
15
|
-
class Pony < ActiveRecord::Base
|
16
|
-
# standard validation
|
17
|
-
validates :homepage, :url => true
|
18
|
-
|
19
|
-
# with allow_nil
|
20
|
-
validates :homepage, :url => {:allow_nil => true}
|
21
|
-
|
22
|
-
# with allow_blank
|
23
|
-
validates :homepage, :url => {:allow_blank => true}
|
24
|
-
end
|
25
|
-
|
26
|
-
#### With ActiveModel
|
27
|
-
class Unicorn
|
28
|
-
include ActiveModel::Validations
|
29
|
-
|
30
|
-
attr_accessor :homepage
|
31
|
-
|
32
|
-
# with legacy syntax (the syntax above works also)
|
33
|
-
validates_url :homepage, :allow_blank => true
|
34
|
-
end
|
35
|
-
|
36
|
-
#### I18n
|
37
|
-
|
38
|
-
The default error message `is not valid url`.
|
39
|
-
You can pass the `:message => "my custom error"` option to your validation to define your own, custom message.
|
40
|
-
|
41
|
-
## Authors
|
42
|
-
|
43
|
-
**Tanel Suurhans** (<http://twitter.com/tanelsuurhans>)
|
44
|
-
**Tarmo Lehtpuu** (<http://twitter.com/tarmolehtpuu>)
|
45
|
-
|
46
|
-
## Contributions
|
47
|
-
Thanks to **Steve Smith** for making the validation process even simpler.
|
48
|
-
|
49
|
-
## License
|
50
|
-
Copyright 2010 by PerfectLine LLC (<http://www.perfectline.co.uk>) and is released under the MIT license.
|
data/spec/resources/user.rb
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/resources')
|
3
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
-
|
5
|
-
require 'rspec'
|
6
|
-
require 'sqlite3'
|
7
|
-
require 'active_record'
|
8
|
-
require 'active_record/base'
|
9
|
-
require 'active_record/migration'
|
10
|
-
|
11
|
-
ActiveRecord::Migration.verbose = false
|
12
|
-
ActiveRecord::Base.establish_connection(
|
13
|
-
"adapter" => "sqlite3",
|
14
|
-
"database" => ":memory:"
|
15
|
-
)
|
16
|
-
|
17
|
-
require File.join(File.dirname(__FILE__), '..', 'init')
|
18
|
-
|
19
|
-
autoload :User, 'resources/user'
|
20
|
-
autoload :UserWithNil, 'resources/user_with_nil'
|
21
|
-
autoload :UserWithBlank, 'resources/user_with_blank'
|
22
|
-
autoload :UserWithLegacySyntax, 'resources/user_with_legacy_syntax'
|
23
|
-
autoload :UserWithAr, 'resources/user_with_ar'
|
24
|
-
autoload :UserWithArLegacy, 'resources/user_with_ar_legacy'
|
25
|
-
autoload :UserWithCustomScheme, 'resources/user_with_custom_scheme'
|
data/spec/validate_url_spec.rb
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "URL validation" do
|
4
|
-
|
5
|
-
before(:all) do
|
6
|
-
ActiveRecord::Schema.define(:version => 1) do
|
7
|
-
|
8
|
-
create_table :users, :force => true do |t|
|
9
|
-
t.column :homepage, :string
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
after(:all) do
|
16
|
-
ActiveRecord::Base.connection.drop_table(:users)
|
17
|
-
end
|
18
|
-
|
19
|
-
context "with regular validator" do
|
20
|
-
before do
|
21
|
-
@user = User.new
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should not allow nil as url" do
|
25
|
-
@user.homepage = nil
|
26
|
-
@user.should_not be_valid
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should not allow blank as url" do
|
30
|
-
@user.homepage = ""
|
31
|
-
@user.should_not be_valid
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should not allow an url without scheme" do
|
35
|
-
@user.homepage = "www.example.com"
|
36
|
-
@user.should_not be_valid
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should allow an url with http" do
|
40
|
-
@user.homepage = "http://localhost"
|
41
|
-
@user.should be_valid
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should allow an url with https" do
|
45
|
-
@user.homepage = "https://localhost"
|
46
|
-
@user.should be_valid
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should not allow a url with an invalid scheme" do
|
50
|
-
@user.homepage = "ftp://localhost"
|
51
|
-
@user.should_not be_valid
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should not allow a url with only a scheme" do
|
55
|
-
@user.homepage = "http://"
|
56
|
-
@user.should_not be_valid
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context "with allow nil" do
|
61
|
-
before do
|
62
|
-
@user = UserWithNil.new
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should allow nil as url" do
|
66
|
-
@user.homepage = nil
|
67
|
-
@user.should be_valid
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should not allow blank as url" do
|
71
|
-
@user.homepage = ""
|
72
|
-
@user.should_not be_valid
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should allow a valid url" do
|
76
|
-
@user.homepage = "http://www.example.com"
|
77
|
-
@user.should be_valid
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "with allow blank" do
|
82
|
-
before do
|
83
|
-
@user = UserWithBlank.new
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should allow nil as url" do
|
87
|
-
@user.homepage = nil
|
88
|
-
@user.should be_valid
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should allow blank as url" do
|
92
|
-
@user.homepage = ""
|
93
|
-
@user.should be_valid
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should allow a valid url" do
|
97
|
-
@user.homepage = "http://www.example.com"
|
98
|
-
@user.should be_valid
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
context "with legacy syntax" do
|
103
|
-
before do
|
104
|
-
@user = UserWithLegacySyntax.new
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should allow nil as url" do
|
108
|
-
@user.homepage = nil
|
109
|
-
@user.should be_valid
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should allow blank as url" do
|
113
|
-
@user.homepage = ""
|
114
|
-
@user.should be_valid
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should allow a valid url" do
|
118
|
-
@user.homepage = "http://www.example.com"
|
119
|
-
@user.should be_valid
|
120
|
-
end
|
121
|
-
|
122
|
-
it "should not allow invalid url" do
|
123
|
-
@user.homepage = "random"
|
124
|
-
@user.should_not be_valid
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
context "with ActiveRecord" do
|
129
|
-
before do
|
130
|
-
@user = UserWithAr.new
|
131
|
-
end
|
132
|
-
|
133
|
-
it "should not allow invalid url" do
|
134
|
-
@user.homepage = "random"
|
135
|
-
@user.should_not be_valid
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
context "with ActiveRecord and legacy syntax" do
|
140
|
-
before do
|
141
|
-
@user = UserWithArLegacy.new
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should not allow invalid url" do
|
145
|
-
@user.homepage = "random"
|
146
|
-
@user.should_not be_valid
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context "with regular validator and custom scheme" do
|
151
|
-
before do
|
152
|
-
@user = UserWithCustomScheme.new
|
153
|
-
end
|
154
|
-
|
155
|
-
it "should allow alternative URI schemes" do
|
156
|
-
@user.homepage = "ftp://ftp.example.com"
|
157
|
-
@user.should be_valid
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|