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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 562497d9d1a6158943dc8d6fa803f18f63f209d9
4
- data.tar.gz: 8cfd0db3b77dc3405cfd846207a1d25e44c7ff19
3
+ metadata.gz: 36462a136b54957f0ccfee104306510bd2b6cfe9
4
+ data.tar.gz: 2ca35b51e07f1b7d1fd4adb641f1a7c9ee96edd2
5
5
  SHA512:
6
- metadata.gz: 04a6289f8d61c3ac4daf8f1d4e4d8c2e03ffc208fe03c355d9a5a5351ac75e943ef60a1908dcefed1ca276a3e33ad0f19c0392fc738beb451af62b14980b1fa3
7
- data.tar.gz: 36d6f6f97c0221c3ce0b2e6d3eb22c406f14c412b28f6f36ffa2fd7f170a848eb0034b34853b78daa8f6210db57667b55b681f63090a06f9de5daf972268ad82
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,
@@ -3,8 +3,4 @@ require "url_attributes/url_validator"
3
3
  require "url_attributes/extensions/active_support"
4
4
  require "url_attributes/extensions/active_record"
5
5
 
6
- module URLAttributes
7
- # Your code goes here...
8
- end
9
-
10
-
6
+ require "url_attributes/rspec/have_url_attribute"
@@ -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
@@ -1,3 +1,3 @@
1
1
  module URLAttributes
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  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.0.0
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