fakeweb-matcher 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -29,6 +29,7 @@ Unsurprisingly, this library is tested using RSpec, and relies upon FakeWeb. It
29
29
  h2. Contributors
30
30
 
31
31
  * "Thilo Utke":http://github.com/thilo (Regex URL matching)
32
+ * "Wes Morgan":http://nerdyadventuresofwes.blogspot.com/ (Normalise query params)
32
33
 
33
34
  h2. Copyright
34
35
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
- :minor: 1
3
+ :minor: 2
4
4
  :patch: 0
@@ -2,6 +2,24 @@ 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
4
  #
5
+
6
+ # Monkey patch to add a normalize! method to the URI::HTTP class.
7
+ # It doesn't currently sort the query params which means two URLs
8
+ # that are equivalent except for a different order of query params
9
+ # will be !=. This isn't how FakeWeb works, so we patch it here.
10
+ class ::URI::HTTP
11
+
12
+ # Normalize an HTTP URI so that query param order differences don't
13
+ # affect equality.
14
+ def normalize!
15
+ if query
16
+ query_array = self.query.split('&')
17
+ set_query(query_array.sort.join('&'))
18
+ end
19
+ super
20
+ end
21
+ end
22
+
5
23
  class RequestMatcher
6
24
  attr_reader :url, :method
7
25
 
@@ -81,10 +99,10 @@ module FakeWebMatcher
81
99
  # @return [Boolean] true if exprexted URI and called URI match.
82
100
  #
83
101
  def match_url(url)
84
- regex?(@url) ? @url.match(url.to_s) : @url == url
102
+ return @url.match(url.to_s) if regex?(@url)
103
+ @url == url
85
104
  end
86
105
 
87
-
88
106
  # Expected method formatted to be an uppercase string. Example: :get becomes
89
107
  # "GET".
90
108
  #
@@ -32,4 +32,11 @@ describe FakeWebMatcher::Matchers do
32
32
 
33
33
  FakeWeb.should_not have_requested(:get, 'http://example.com')
34
34
  end
35
+
36
+ it "should not care about the order of the query parameters" do
37
+ FakeWeb.register_uri(:get, URI.parse('http://example.com/page?foo=bar&baz=qux'), :body => 'foo')
38
+ open('http://example.com/page?baz=qux&foo=bar')
39
+
40
+ FakeWeb.should have_requested(:get, 'http://example.com/page?foo=bar&baz=qux')
41
+ end
35
42
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakeweb-matcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 2
9
+ - 0
10
+ version: 1.2.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Pat Allan
@@ -9,29 +15,41 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-12-06 00:00:00 +11:00
18
+ date: 2010-10-25 00:00:00 +11:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: fakeweb
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 21
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 5
23
34
  version: 1.2.5
24
- version:
35
+ type: :runtime
36
+ version_requirements: *id001
25
37
  - !ruby/object:Gem::Dependency
26
38
  name: rspec
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
30
42
  requirements:
31
43
  - - ">="
32
44
  - !ruby/object:Gem::Version
45
+ hash: 31
46
+ segments:
47
+ - 1
48
+ - 2
49
+ - 0
33
50
  version: 1.2.0
34
- version:
51
+ type: :runtime
52
+ version_requirements: *id002
35
53
  description:
36
54
  email: pat@freelancing-gods.com
37
55
  executables: []
@@ -51,31 +69,42 @@ files:
51
69
  - lib/fake_web_matcher/matchers.rb
52
70
  - lib/fake_web_matcher/request_matcher.rb
53
71
  - lib/fakeweb_matcher.rb
72
+ - spec/lib/fake_web_matcher/extension_spec.rb
73
+ - spec/lib/fake_web_matcher/matchers_spec.rb
74
+ - spec/lib/fake_web_matcher/request_matcher_spec.rb
75
+ - spec/lib/fake_web_matcher_spec.rb
76
+ - spec/spec_helper.rb
54
77
  has_rdoc: true
55
78
  homepage: http://github.com/freelancing-god/fakeweb-matcher
56
79
  licenses: []
57
80
 
58
81
  post_install_message:
59
- rdoc_options:
60
- - --charset=UTF-8
82
+ rdoc_options: []
83
+
61
84
  require_paths:
62
85
  - lib
63
86
  required_ruby_version: !ruby/object:Gem::Requirement
87
+ none: false
64
88
  requirements:
65
89
  - - ">="
66
90
  - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
67
94
  version: "0"
68
- version:
69
95
  required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
70
97
  requirements:
71
98
  - - ">="
72
99
  - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
73
103
  version: "0"
74
- version:
75
104
  requirements: []
76
105
 
77
106
  rubyforge_project:
78
- rubygems_version: 1.3.5
107
+ rubygems_version: 1.3.7
79
108
  signing_key:
80
109
  specification_version: 3
81
110
  summary: RSpec matcher for the FakeWeb library