url_attributes 1.0.0 → 1.1.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 +10 -0
- data/lib/url_attributes.rb +1 -5
- data/lib/url_attributes/rspec/have_url_attribute.rb +19 -0
- data/lib/url_attributes/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36462a136b54957f0ccfee104306510bd2b6cfe9
|
4
|
+
data.tar.gz: 2ca35b51e07f1b7d1fd4adb641f1a7c9ee96edd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3c644c91403528b321401785db681a5fc5d6e63f1a33547ea1a7ebc51d287d54d9c7a941c2b68b4c674f618a0e5ad49751dce730600541471641f420bac9134
|
7
|
+
data.tar.gz: 389a2569cd9731c54631b438462ff42a0db27f67b59ebd2ccd975f96a31536921b5ef8a4edc8722ca428cc8bff65271b85d415cbd3620daff97893ee08ed266f
|
data/README.md
CHANGED
@@ -27,6 +27,16 @@ This does two things:
|
|
27
27
|
2. Before save, it strips trailing whitespace from the link and adds `"http://"` to the beginning
|
28
28
|
if it (or `"https://"`) is not already there.
|
29
29
|
|
30
|
+
## Matcher
|
31
|
+
|
32
|
+
The gem also comes with an RSpec matcher. You can use it like this:
|
33
|
+
|
34
|
+
describe MyAwesomeModel do
|
35
|
+
|
36
|
+
it { is_expected.to have_url_attribute :link }
|
37
|
+
|
38
|
+
end
|
39
|
+
|
30
40
|
## Contributing
|
31
41
|
|
32
42
|
Want to contribute to this gem? You're more than welcome! Just clone the repo from GitHub,
|
data/lib/url_attributes.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
RSpec::Matchers.define :have_url_attribute do |attribute_name|
|
2
|
+
# This matcher is an ugly piece of shit
|
3
|
+
match do |model|
|
4
|
+
model.send :"#{attribute_name}=", "notavalidurl"
|
5
|
+
model.valid?
|
6
|
+
test_0 = model.errors[attribute_name].include?("is not a valid URL")
|
7
|
+
model.send :"#{attribute_name}=", "http://validurl.com"
|
8
|
+
model.valid?
|
9
|
+
test_1 = !model.errors[attribute_name].include?("is not a valid URL")
|
10
|
+
model.send :"#{attribute_name}=", "nohttp.com"
|
11
|
+
model.run_callbacks :save
|
12
|
+
test_2 = model.send(attribute_name) == "http://nohttp.com"
|
13
|
+
test_0 && test_1 && test_2
|
14
|
+
end
|
15
|
+
|
16
|
+
failure_message do |model|
|
17
|
+
"expected that #{model} would have a URL attribute called #{attribute_name}, but it doesn't look like a URL"
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: url_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Millo
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/url_attributes.rb
|
111
111
|
- lib/url_attributes/extensions/active_record.rb
|
112
112
|
- lib/url_attributes/extensions/active_support.rb
|
113
|
+
- lib/url_attributes/rspec/have_url_attribute.rb
|
113
114
|
- lib/url_attributes/url_validator.rb
|
114
115
|
- lib/url_attributes/version.rb
|
115
116
|
- spec/dummy/.gitignore
|