fakeweb-matcher 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +7 -2
- data/VERSION.yml +2 -2
- data/lib/fake_web_matcher/request_matcher.rb +41 -36
- data/spec/lib/fake_web_matcher/extension_spec.rb +1 -1
- data/spec/lib/fake_web_matcher/matchers_spec.rb +1 -1
- data/spec/lib/fake_web_matcher/request_matcher_spec.rb +1 -1
- data/spec/lib/fake_web_matcher_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -5
- metadata +84 -66
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 43ddc80116ddeeddb5d4b268a0252c99f9bd2411
|
4
|
+
data.tar.gz: 7c1fb3ba541ddd2466645fcd0b553453279e6d8a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4ad8c46c69e7809dcfdaac6ba7a8eef114cc33ea2861bedf3c28d1093f6d316c92fbbfdf73c8d2bb9cfcf900fb407898f66c74228e31f63ca64fc0ec9f598dea
|
7
|
+
data.tar.gz: db1e4a89c70313c28e4af53d268aae8233cb657cbbacc3b37430bd16bc57301173e4823e0204dfa59dfa90e3a150ef9be35df4247073038f4dee3b5af56da25a
|
data/Rakefile
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
Bundler.require :default, :development
|
5
|
+
|
6
|
+
require "#{File.dirname(__FILE__)}/tasks/distribution"
|
7
|
+
require "#{File.dirname(__FILE__)}/tasks/testing"
|
3
8
|
|
4
9
|
task :default => :spec
|
data/VERSION.yml
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module FakeWebMatcher
|
2
2
|
# Matcher class, following RSpec's expectations. Used to confirm whether a
|
3
3
|
# request has been made on a given method and URI.
|
4
|
-
#
|
5
|
-
|
4
|
+
#
|
5
|
+
|
6
6
|
# Monkey patch to add a normalize! method to the URI::HTTP class.
|
7
7
|
# It doesn't currently sort the query params which means two URLs
|
8
8
|
# that are equivalent except for a different order of query params
|
@@ -13,115 +13,120 @@ module FakeWebMatcher
|
|
13
13
|
# affect equality.
|
14
14
|
def normalize!
|
15
15
|
if query
|
16
|
-
|
17
|
-
set_query
|
16
|
+
normalised_query = self.query.split('&').sort.join('&')
|
17
|
+
if respond_to? :set_query
|
18
|
+
set_query normalised_query
|
19
|
+
else
|
20
|
+
self.query = normalised_query
|
21
|
+
end
|
18
22
|
end
|
23
|
+
|
19
24
|
super
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
28
|
class RequestMatcher
|
24
29
|
attr_reader :url, :method
|
25
|
-
|
30
|
+
|
26
31
|
# Create a new matcher.
|
27
|
-
#
|
32
|
+
#
|
28
33
|
# @param [Symbol] method The HTTP method. Defaults to :any if not supplied.
|
29
34
|
# @param [String, Regexp] uri The URI to check for
|
30
|
-
#
|
35
|
+
#
|
31
36
|
def initialize(*args)
|
32
37
|
@method, @url = args_split(*args)
|
33
38
|
end
|
34
|
-
|
39
|
+
|
35
40
|
# Indication of whether there's a match on the URI from given requests.
|
36
|
-
#
|
41
|
+
#
|
37
42
|
# @param [Module] FakeWeb Module, necessary for RSpec, although not
|
38
43
|
# required internally.
|
39
44
|
# @return [Boolean] true if the URI was requested, otherwise false.
|
40
|
-
#
|
45
|
+
#
|
41
46
|
def matches?(fakeweb)
|
42
47
|
!FakeWeb::Registry.instance.requests.detect { |req|
|
43
48
|
method, url = args_split(*req)
|
44
49
|
match_method(method) && match_url(url)
|
45
50
|
}.nil?
|
46
51
|
end
|
47
|
-
|
52
|
+
|
48
53
|
# Failure message if the URI should have been requested.
|
49
|
-
#
|
54
|
+
#
|
50
55
|
# @return [String] failure message
|
51
|
-
#
|
56
|
+
#
|
52
57
|
def failure_message
|
53
58
|
regex?(@url) ? regex_failure_message : url_failure_message
|
54
59
|
end
|
55
|
-
|
60
|
+
|
56
61
|
# Failure message if the URI should not have been requested.
|
57
|
-
#
|
62
|
+
#
|
58
63
|
# @return [String] failure message
|
59
64
|
#
|
60
65
|
def negative_failure_message
|
61
66
|
regex?(@url) ? regex_negative_failure_message : url_negative_failure_message
|
62
67
|
end
|
63
|
-
|
68
|
+
|
64
69
|
private
|
65
|
-
|
70
|
+
|
66
71
|
def regex_negative_failure_message
|
67
72
|
"A URL that matches #{@url.inspect} was requested#{failure_message_method} and should not have been."
|
68
73
|
end
|
69
|
-
|
74
|
+
|
70
75
|
def url_negative_failure_message
|
71
76
|
"The URL #{@url} was requested#{failure_message_method} and should not have been."
|
72
77
|
end
|
73
|
-
|
78
|
+
|
74
79
|
def regex_failure_message
|
75
80
|
"A URL that matches #{@url.inspect} was not requested#{failure_message_method}."
|
76
81
|
end
|
77
|
-
|
82
|
+
|
78
83
|
def url_failure_message
|
79
84
|
"The URL #{@url} was not requested#{failure_message_method}."
|
80
85
|
end
|
81
|
-
|
86
|
+
|
82
87
|
def failure_message_method
|
83
88
|
" using #{formatted_method}" unless @method == :any
|
84
89
|
end
|
85
|
-
|
90
|
+
|
86
91
|
# Compares methods, or ignores if either side of the comparison is :any.
|
87
|
-
#
|
92
|
+
#
|
88
93
|
# @param [Symbol] method HTTP method
|
89
94
|
# @return [Boolean] true if methods match or either is :any.
|
90
|
-
#
|
95
|
+
#
|
91
96
|
def match_method(method)
|
92
97
|
@method == :any || method == :any || method == @method
|
93
98
|
end
|
94
|
-
|
95
|
-
# Compares the url either by match it agains a regular expression or
|
99
|
+
|
100
|
+
# Compares the url either by match it agains a regular expression or
|
96
101
|
# by simple comparison
|
97
|
-
#
|
102
|
+
#
|
98
103
|
# @param [String] url the called URI
|
99
104
|
# @return [Boolean] true if exprexted URI and called URI match.
|
100
|
-
#
|
105
|
+
#
|
101
106
|
def match_url(url)
|
102
107
|
return @url.match(url.to_s) if regex?(@url)
|
103
108
|
@url == url
|
104
109
|
end
|
105
|
-
|
110
|
+
|
106
111
|
# Expected method formatted to be an uppercase string. Example: :get becomes
|
107
112
|
# "GET".
|
108
|
-
#
|
113
|
+
#
|
109
114
|
# @return [String] uppercase method
|
110
|
-
#
|
115
|
+
#
|
111
116
|
def formatted_method
|
112
117
|
@method.to_s.upcase
|
113
118
|
end
|
114
|
-
|
119
|
+
|
115
120
|
# Interprets given arguments to a method and URI instance. The URI, as a
|
116
121
|
# string, is required, but the method is not (will default to :any).
|
117
|
-
#
|
122
|
+
#
|
118
123
|
# @param [Array] args
|
119
124
|
# @return [Array] Two items: method and URI instance or regular expression
|
120
|
-
#
|
125
|
+
#
|
121
126
|
def args_split(*args)
|
122
127
|
method = :any
|
123
128
|
uri = nil
|
124
|
-
|
129
|
+
|
125
130
|
case args.length
|
126
131
|
when 1 then uri = args[0]
|
127
132
|
when 2 then method, uri = args[0], args[1]
|
@@ -131,7 +136,7 @@ module FakeWebMatcher
|
|
131
136
|
uri = URI.parse(uri) unless regex?(uri)
|
132
137
|
return method, uri
|
133
138
|
end
|
134
|
-
|
139
|
+
|
135
140
|
def regex?(object)
|
136
141
|
object.is_a?(Regexp)
|
137
142
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
$:.unshift File.dirname(__FILE__) + '/../lib'
|
2
|
+
$:.unshift File.dirname(__FILE__) + '/.'
|
2
3
|
|
3
4
|
require 'rubygems'
|
5
|
+
require 'bundler'
|
6
|
+
|
7
|
+
Bundler.require :default, :development
|
8
|
+
|
4
9
|
require 'open-uri'
|
5
|
-
require 'spec'
|
6
10
|
require 'fake_web'
|
7
11
|
require 'fake_web_matcher'
|
8
|
-
|
9
|
-
Spec::Runner.configure do |config|
|
10
|
-
#
|
11
|
-
end
|
metadata
CHANGED
@@ -1,65 +1,93 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: fakeweb-matcher
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
- 2
|
10
|
-
version: 1.2.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.3
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Pat Allan
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-12-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: fakeweb
|
23
|
-
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
27
17
|
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 21
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 2
|
33
|
-
- 5
|
18
|
+
- !ruby/object:Gem::Version
|
34
19
|
version: 1.2.5
|
35
20
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rspec
|
39
21
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.2.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
43
31
|
- - ">="
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 31
|
46
|
-
segments:
|
47
|
-
- 1
|
48
|
-
- 2
|
49
|
-
- 0
|
32
|
+
- !ruby/object:Gem::Version
|
50
33
|
version: 1.2.0
|
51
34
|
type: :runtime
|
52
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jeweler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.7.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.7.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.7
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.8.7
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.7.2
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.7.2
|
53
83
|
description:
|
54
84
|
email: pat@freelancing-gods.com
|
55
85
|
executables: []
|
56
|
-
|
57
86
|
extensions: []
|
58
|
-
|
59
|
-
extra_rdoc_files:
|
87
|
+
extra_rdoc_files:
|
60
88
|
- LICENSE
|
61
89
|
- README.textile
|
62
|
-
files:
|
90
|
+
files:
|
63
91
|
- LICENSE
|
64
92
|
- README.textile
|
65
93
|
- Rakefile
|
@@ -74,43 +102,33 @@ files:
|
|
74
102
|
- spec/lib/fake_web_matcher/request_matcher_spec.rb
|
75
103
|
- spec/lib/fake_web_matcher_spec.rb
|
76
104
|
- spec/spec_helper.rb
|
77
|
-
has_rdoc: true
|
78
105
|
homepage: http://github.com/freelancing-god/fakeweb-matcher
|
79
106
|
licenses: []
|
80
|
-
|
107
|
+
metadata: {}
|
81
108
|
post_install_message:
|
82
109
|
rdoc_options: []
|
83
|
-
|
84
|
-
require_paths:
|
110
|
+
require_paths:
|
85
111
|
- lib
|
86
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
-
|
88
|
-
requirements:
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
89
114
|
- - ">="
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
version: "0"
|
95
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
-
none: false
|
97
|
-
requirements:
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
98
119
|
- - ">="
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
|
101
|
-
segments:
|
102
|
-
- 0
|
103
|
-
version: "0"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
104
122
|
requirements: []
|
105
|
-
|
106
123
|
rubyforge_project:
|
107
|
-
rubygems_version:
|
124
|
+
rubygems_version: 2.2.2
|
108
125
|
signing_key:
|
109
|
-
specification_version:
|
126
|
+
specification_version: 4
|
110
127
|
summary: RSpec matcher for the FakeWeb library
|
111
|
-
test_files:
|
128
|
+
test_files:
|
112
129
|
- spec/lib/fake_web_matcher/extension_spec.rb
|
113
130
|
- spec/lib/fake_web_matcher/matchers_spec.rb
|
114
131
|
- spec/lib/fake_web_matcher/request_matcher_spec.rb
|
115
132
|
- spec/lib/fake_web_matcher_spec.rb
|
116
133
|
- spec/spec_helper.rb
|
134
|
+
has_rdoc:
|