webmock 0.9.1 → 1.0.0

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.
Files changed (40) hide show
  1. data/CHANGELOG.md +47 -2
  2. data/README.md +68 -6
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/lib/webmock.rb +2 -2
  6. data/lib/webmock/adapters/rspec.rb +1 -1
  7. data/lib/webmock/adapters/rspec/matchers.rb +2 -2
  8. data/lib/webmock/adapters/rspec/{request_profile_matcher.rb → request_pattern_matcher.rb} +5 -5
  9. data/lib/webmock/adapters/rspec/webmock_matcher.rb +2 -2
  10. data/lib/webmock/config.rb +2 -1
  11. data/lib/webmock/http_lib_adapters/httpclient.rb +5 -4
  12. data/lib/webmock/http_lib_adapters/net_http.rb +5 -3
  13. data/lib/webmock/http_lib_adapters/patron.rb +82 -0
  14. data/lib/webmock/request_execution_verifier.rb +8 -8
  15. data/lib/webmock/request_pattern.rb +130 -0
  16. data/lib/webmock/request_registry.rb +4 -9
  17. data/lib/webmock/request_signature.rb +18 -37
  18. data/lib/webmock/request_stub.rb +17 -6
  19. data/lib/webmock/response.rb +87 -31
  20. data/lib/webmock/util/headers.rb +5 -0
  21. data/lib/webmock/webmock.rb +10 -6
  22. data/spec/httpclient_spec.rb +0 -1
  23. data/spec/httpclient_spec_helper.rb +11 -1
  24. data/spec/net_http_spec.rb +8 -1
  25. data/spec/net_http_spec_helper.rb +11 -1
  26. data/spec/patron_spec.rb +83 -0
  27. data/spec/patron_spec_helper.rb +44 -0
  28. data/spec/request_execution_verifier_spec.rb +8 -8
  29. data/spec/request_pattern_spec.rb +243 -0
  30. data/spec/request_registry_spec.rb +34 -19
  31. data/spec/request_signature_spec.rb +23 -191
  32. data/spec/request_stub_spec.rb +32 -11
  33. data/spec/response_spec.rb +98 -5
  34. data/spec/spec_helper.rb +8 -16
  35. data/spec/webmock_spec.rb +154 -49
  36. data/webmock.gemspec +14 -7
  37. metadata +21 -7
  38. data/lib/webmock/request.rb +0 -29
  39. data/lib/webmock/request_profile.rb +0 -50
  40. data/spec/request_profile_spec.rb +0 -68
data/webmock.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{webmock}
8
- s.version = "0.9.1"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bartosz Blimke"]
12
- s.date = %q{2010-02-02}
12
+ s.date = %q{2010-04-12}
13
13
  s.description = %q{WebMock allows stubbing HTTP requests and setting expectations on HTTP requests.}
14
14
  s.email = %q{bartosz.blimke@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -26,16 +26,16 @@ Gem::Specification.new do |s|
26
26
  "lib/webmock.rb",
27
27
  "lib/webmock/adapters/rspec.rb",
28
28
  "lib/webmock/adapters/rspec/matchers.rb",
29
- "lib/webmock/adapters/rspec/request_profile_matcher.rb",
29
+ "lib/webmock/adapters/rspec/request_pattern_matcher.rb",
30
30
  "lib/webmock/adapters/rspec/webmock_matcher.rb",
31
31
  "lib/webmock/adapters/test_unit.rb",
32
32
  "lib/webmock/config.rb",
33
33
  "lib/webmock/errors.rb",
34
34
  "lib/webmock/http_lib_adapters/httpclient.rb",
35
35
  "lib/webmock/http_lib_adapters/net_http.rb",
36
- "lib/webmock/request.rb",
36
+ "lib/webmock/http_lib_adapters/patron.rb",
37
37
  "lib/webmock/request_execution_verifier.rb",
38
- "lib/webmock/request_profile.rb",
38
+ "lib/webmock/request_pattern.rb",
39
39
  "lib/webmock/request_registry.rb",
40
40
  "lib/webmock/request_signature.rb",
41
41
  "lib/webmock/request_stub.rb",
@@ -53,8 +53,10 @@ Gem::Specification.new do |s|
53
53
  "spec/net_http_spec.rb",
54
54
  "spec/net_http_spec_helper.rb",
55
55
  "spec/other_net_http_libs_spec.rb",
56
+ "spec/patron_spec.rb",
57
+ "spec/patron_spec_helper.rb",
56
58
  "spec/request_execution_verifier_spec.rb",
57
- "spec/request_profile_spec.rb",
59
+ "spec/request_pattern_spec.rb",
58
60
  "spec/request_registry_spec.rb",
59
61
  "spec/request_signature_spec.rb",
60
62
  "spec/request_stub_spec.rb",
@@ -103,8 +105,10 @@ Gem::Specification.new do |s|
103
105
  "spec/net_http_spec.rb",
104
106
  "spec/net_http_spec_helper.rb",
105
107
  "spec/other_net_http_libs_spec.rb",
108
+ "spec/patron_spec.rb",
109
+ "spec/patron_spec_helper.rb",
106
110
  "spec/request_execution_verifier_spec.rb",
107
- "spec/request_profile_spec.rb",
111
+ "spec/request_pattern_spec.rb",
108
112
  "spec/request_registry_spec.rb",
109
113
  "spec/request_signature_spec.rb",
110
114
  "spec/request_stub_spec.rb",
@@ -138,15 +142,18 @@ Gem::Specification.new do |s|
138
142
  s.add_runtime_dependency(%q<addressable>, [">= 2.1.1"])
139
143
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
140
144
  s.add_development_dependency(%q<httpclient>, [">= 2.1.5.2"])
145
+ s.add_development_dependency(%q<patron>, [">= 0.4.5"])
141
146
  else
142
147
  s.add_dependency(%q<addressable>, [">= 2.1.1"])
143
148
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
144
149
  s.add_dependency(%q<httpclient>, [">= 2.1.5.2"])
150
+ s.add_dependency(%q<patron>, [">= 0.4.5"])
145
151
  end
146
152
  else
147
153
  s.add_dependency(%q<addressable>, [">= 2.1.1"])
148
154
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
149
155
  s.add_dependency(%q<httpclient>, [">= 2.1.5.2"])
156
+ s.add_dependency(%q<patron>, [">= 0.4.5"])
150
157
  end
151
158
  end
152
159
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartosz Blimke
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-02 00:00:00 +00:00
12
+ date: 2010-04-12 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,6 +42,16 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 2.1.5.2
44
44
  version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: patron
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.4.5
54
+ version:
45
55
  description: WebMock allows stubbing HTTP requests and setting expectations on HTTP requests.
46
56
  email: bartosz.blimke@gmail.com
47
57
  executables: []
@@ -61,16 +71,16 @@ files:
61
71
  - lib/webmock.rb
62
72
  - lib/webmock/adapters/rspec.rb
63
73
  - lib/webmock/adapters/rspec/matchers.rb
64
- - lib/webmock/adapters/rspec/request_profile_matcher.rb
74
+ - lib/webmock/adapters/rspec/request_pattern_matcher.rb
65
75
  - lib/webmock/adapters/rspec/webmock_matcher.rb
66
76
  - lib/webmock/adapters/test_unit.rb
67
77
  - lib/webmock/config.rb
68
78
  - lib/webmock/errors.rb
69
79
  - lib/webmock/http_lib_adapters/httpclient.rb
70
80
  - lib/webmock/http_lib_adapters/net_http.rb
71
- - lib/webmock/request.rb
81
+ - lib/webmock/http_lib_adapters/patron.rb
72
82
  - lib/webmock/request_execution_verifier.rb
73
- - lib/webmock/request_profile.rb
83
+ - lib/webmock/request_pattern.rb
74
84
  - lib/webmock/request_registry.rb
75
85
  - lib/webmock/request_signature.rb
76
86
  - lib/webmock/request_stub.rb
@@ -88,8 +98,10 @@ files:
88
98
  - spec/net_http_spec.rb
89
99
  - spec/net_http_spec_helper.rb
90
100
  - spec/other_net_http_libs_spec.rb
101
+ - spec/patron_spec.rb
102
+ - spec/patron_spec_helper.rb
91
103
  - spec/request_execution_verifier_spec.rb
92
- - spec/request_profile_spec.rb
104
+ - spec/request_pattern_spec.rb
93
105
  - spec/request_registry_spec.rb
94
106
  - spec/request_signature_spec.rb
95
107
  - spec/request_stub_spec.rb
@@ -160,8 +172,10 @@ test_files:
160
172
  - spec/net_http_spec.rb
161
173
  - spec/net_http_spec_helper.rb
162
174
  - spec/other_net_http_libs_spec.rb
175
+ - spec/patron_spec.rb
176
+ - spec/patron_spec_helper.rb
163
177
  - spec/request_execution_verifier_spec.rb
164
- - spec/request_profile_spec.rb
178
+ - spec/request_pattern_spec.rb
165
179
  - spec/request_registry_spec.rb
166
180
  - spec/request_signature_spec.rb
167
181
  - spec/request_stub_spec.rb
@@ -1,29 +0,0 @@
1
- module WebMock
2
-
3
- class Request
4
- attr_accessor :method, :uri, :body, :headers
5
-
6
- def initialize(method, uri, options = {})
7
- self.method = method
8
- self.uri = uri.is_a?(Addressable::URI) ? uri : WebMock::Util::URI.normalize_uri(uri)
9
- assign_options(options)
10
- end
11
-
12
- def to_s
13
- string = "#{self.method.to_s.upcase} #{WebMock::Util::URI.strip_default_port_from_uri_string(self.uri.to_s)}"
14
- string << " with body '#{body.to_s}'" if body && body.to_s != ''
15
- if headers && !headers.empty?
16
- string << " with headers #{WebMock::Util::Headers.normalize_headers(headers).inspect.gsub("\"","'")}"
17
- end
18
- string
19
- end
20
-
21
- private
22
-
23
- def assign_options(options)
24
- self.body = options[:body] if options.has_key?(:body)
25
- self.headers = WebMock::Util::Headers.normalize_headers(options[:headers]) if options.has_key?(:headers)
26
- end
27
-
28
- end
29
- end
@@ -1,50 +0,0 @@
1
- module WebMock
2
-
3
- class RequestProfile < Request
4
-
5
- attr_reader :with_block
6
-
7
- def with(options = {}, &block)
8
- assign_options(options)
9
- @with_block = block
10
- self
11
- end
12
-
13
- def body=(body)
14
- @body = Body.new(body)
15
- end
16
-
17
- def to_s
18
- string = super
19
- string << " with given block" if @with_block
20
- string
21
- end
22
-
23
- class Body
24
-
25
- attr_reader :data
26
-
27
- def initialize(data)
28
- @data = data
29
- end
30
-
31
- def ==(other)
32
- other = Body.new(other) unless other.is_a?(Body)
33
- other.is_a?(Body) &&
34
- (other.is_empty? && self.is_empty? || other.data == self.data || self.data === other.data )
35
- end
36
-
37
- def is_empty?
38
- @data.nil? || @data == ""
39
- end
40
-
41
- def to_s
42
- @data
43
- end
44
-
45
- end
46
-
47
- end
48
-
49
-
50
- end
@@ -1,68 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe RequestProfile do
4
-
5
- describe "initialization" do
6
-
7
- it "should have assigned normalized uri" do
8
- WebMock::Util::URI.should_receive(:normalize_uri).and_return("www.example.kom")
9
- profile = RequestProfile.new(:get, "www.example.com")
10
- profile.uri.should == "www.example.kom"
11
- end
12
-
13
- it "should have assigned uri without normalization if uri is URI" do
14
- WebMock::Util::URI.should_not_receive(:normalize_uri)
15
- uri = Addressable::URI.parse("www.example.com")
16
- profile = RequestProfile.new(:get, uri)
17
- profile.uri.should == uri
18
- end
19
-
20
- it "should have assigned normalized headers" do
21
- WebMock::Util::Headers.should_receive(:normalize_headers).with('A' => 'a').and_return('B' => 'b')
22
- RequestProfile.new(:get, "www.example.com", :headers => {'A' => 'a'}).headers.should == {'B' => 'b'}
23
- end
24
-
25
- it "should have assigned body" do
26
- RequestProfile.new(:get, "www.example.com", :body => "abc").
27
- body.should == RequestProfile::Body.new("abc")
28
- end
29
-
30
- end
31
-
32
- it "should report string describing itself" do
33
- RequestProfile.new(:get, "www.example.com",
34
- :body => "abc", :headers => {'A' => 'a', 'B' => 'b'}).to_s.should ==
35
- "GET http://www.example.com/ with body 'abc' with headers {'A'=>'a', 'B'=>'b'}"
36
- end
37
-
38
- it "should report string describing itself with block" do
39
- RequestProfile.new(:get, "www.example.com",
40
- :body => "abc", :headers => {'A' => 'a', 'B' => 'b'}).with {|req| true}.to_s.should ==
41
- "GET http://www.example.com/ with body 'abc' with headers {'A'=>'a', 'B'=>'b'} with given block"
42
- end
43
-
44
- describe "with" do
45
- before(:each) do
46
- @request_profile = RequestProfile.new(:get, "www.example.com")
47
- end
48
-
49
- it "should assign body to request profile" do
50
- @request_profile.with(:body => "abc")
51
- @request_profile.body.should == RequestProfile::Body.new("abc")
52
- end
53
-
54
- it "should have the same body" do
55
- @request_profile.with(:body => "abc")
56
- @request_profile.body.should == RequestProfile::Body.new("abc")
57
- end
58
-
59
- it "should assign normalized headers to request profile" do
60
- WebMock::Util::Headers.should_receive(:normalize_headers).with('A' => 'a').and_return('B' => 'b')
61
- @request_profile.with(:headers => {'A' => 'a'})
62
- @request_profile.headers.should == {'B' => 'b'}
63
- end
64
-
65
- end
66
-
67
-
68
- end