wildcard_matchers 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -30,6 +30,9 @@ See specs, for more detail.
|
|
30
30
|
* is_time === "2012-05-13" #=> true
|
31
31
|
* is_url
|
32
32
|
* is_url(:host => "example.com") === "http://example.com" #=> true
|
33
|
+
* with_uri_template
|
34
|
+
* with_uri_template("http://example.com/users/{id}", "id" => "1") === "http://example.com/users/1" #=> true
|
35
|
+
* with_uri_template("http://example.com/users{?id}", "id" => "1") === "http://example.com/users?id=1" #=> true
|
33
36
|
* hash_includes
|
34
37
|
* hash_includes(:a) === { :a => 1 } #=> true
|
35
38
|
* hash_includes(:b) === { :a => 1 } #=> false
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "addressable/template"
|
2
|
+
|
3
|
+
module WildcardMatchers
|
4
|
+
module Matchers
|
5
|
+
define_wildcard_matcher(:with_uri_template)
|
6
|
+
|
7
|
+
class WithUriTemplate < ::WildcardMatchers::WildcardMatcher
|
8
|
+
def initialize(expectations, position = ".", &block)
|
9
|
+
template, expectation = *expectations
|
10
|
+
|
11
|
+
@template = template.is_a?(::Addressable::Template) ? template : ::Addressable::Template.new(template)
|
12
|
+
|
13
|
+
@expectation = (block_given? ? block : expectation)
|
14
|
+
@position = position
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
def wildcard_match(actual)
|
19
|
+
extracted = @template.extract(actual)
|
20
|
+
|
21
|
+
errors.push(*self.class.superclass.check_errors(extracted, expectation, position))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe WildcardMatchers::Matchers::WithUriTemplate do
|
4
|
+
[ [ "http://example.com/hoge/fuga", :with_uri_template, "http://example.com/hoge/{fuga}", "fuga" => "fuga" ],
|
5
|
+
].each do |actual, matcher, *args|
|
6
|
+
it_behaves_like "wildcard match", actual, matcher, *args
|
7
|
+
end
|
8
|
+
|
9
|
+
[ [ "http://example.com/hoge/fuga", :with_uri_template, "http://example.com/hoge/{fuga}", "fuga" => "hoge" ],
|
10
|
+
[ "http://example.com/hoge/fuga", :with_uri_template, "http://example.com/hoge/{fuga}", "hoge" => "fuga" ],
|
11
|
+
].each do |actual, matcher, *args|
|
12
|
+
it_behaves_like "not wildcard match", actual, matcher, *args
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wildcard_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: facets
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/wildcard_matchers/matchers.rb
|
149
149
|
- lib/wildcard_matchers/matchers/hash_includes.rb
|
150
150
|
- lib/wildcard_matchers/matchers/is_uri.rb
|
151
|
+
- lib/wildcard_matchers/matchers/with_uri_template.rb
|
151
152
|
- lib/wildcard_matchers/rspec.rb
|
152
153
|
- lib/wildcard_matchers/wildcard_matcher.rb
|
153
154
|
- spec/spec.watchr
|
@@ -158,6 +159,7 @@ files:
|
|
158
159
|
- spec/wildcard_matchers/helpers/nil_or_spec.rb
|
159
160
|
- spec/wildcard_matchers/matchers/hash_includes_spec.rb
|
160
161
|
- spec/wildcard_matchers/matchers/is_uri_spec.rb
|
162
|
+
- spec/wildcard_matchers/matchers/with_uri_template_spec.rb
|
161
163
|
- spec/wildcard_matchers/matchers_spec.rb
|
162
164
|
- spec/wildcard_matchers/rspec_spec.rb
|
163
165
|
- spec/wildcard_matchers_spec.rb
|
@@ -195,6 +197,7 @@ test_files:
|
|
195
197
|
- spec/wildcard_matchers/helpers/nil_or_spec.rb
|
196
198
|
- spec/wildcard_matchers/matchers/hash_includes_spec.rb
|
197
199
|
- spec/wildcard_matchers/matchers/is_uri_spec.rb
|
200
|
+
- spec/wildcard_matchers/matchers/with_uri_template_spec.rb
|
198
201
|
- spec/wildcard_matchers/matchers_spec.rb
|
199
202
|
- spec/wildcard_matchers/rspec_spec.rb
|
200
203
|
- spec/wildcard_matchers_spec.rb
|