url_attributes 1.1.0 → 1.1.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 +4 -4
- data/lib/url_attributes/rspec/have_url_attribute.rb +18 -16
- data/lib/url_attributes/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72fddb96602914d4b5919991d53951949012f68b
|
4
|
+
data.tar.gz: 2a8d960c781033dd6bb95aa28b49c5fb09bcb1c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16c66826858d8116aefb25d0037fe5d02fe0d33d8fb9766bd08b8e9b10a5f1588f3ea4139ffbf481fab5dcaf6c6978dd2c8def635508dc3b80fed65434cff046
|
7
|
+
data.tar.gz: f7aecd99cc47f80508c12f37d07be214db148d208a7cd51cc08145786ff1483a8a61a7cbbd43ad15839b081a5e951121d69ceeb89c45f75b311967528c6b5e7d
|
@@ -1,19 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
if Rails.env.test? && defined?(RSpec)
|
2
|
+
RSpec::Matchers.define :have_url_attribute do |attribute_name|
|
3
|
+
# This matcher is an ugly piece of shit
|
4
|
+
match do |model|
|
5
|
+
model.send :"#{attribute_name}=", "notavalidurl"
|
6
|
+
model.valid?
|
7
|
+
test_0 = model.errors[attribute_name].include?("is not a valid URL")
|
8
|
+
model.send :"#{attribute_name}=", "http://validurl.com"
|
9
|
+
model.valid?
|
10
|
+
test_1 = !model.errors[attribute_name].include?("is not a valid URL")
|
11
|
+
model.send :"#{attribute_name}=", "nohttp.com"
|
12
|
+
model.run_callbacks :save
|
13
|
+
test_2 = model.send(attribute_name) == "http://nohttp.com"
|
14
|
+
test_0 && test_1 && test_2
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
failure_message do |model|
|
18
|
+
"expected that #{model} would have a URL attribute called #{attribute_name}, but it doesn't look like a URL"
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|