curb-fu 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,77 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
2
+ require 'curb-fu/core_ext'
3
+
4
+ describe CurbFu::Request::Parameter do
5
+ describe "initialize" do
6
+ it "should accept a key and value pair" do
7
+ param = CurbFu::Request::Parameter.new("simple", "value")
8
+ param.name.should == "simple"
9
+ param.value.should == "value"
10
+ end
11
+ it "should accept a hash" do
12
+ lambda { CurbFu::Request::Parameter.new("policy",
13
+ { "archive_length_units" => "eons", "to" => "cthulhu@goo.org" }) }.should_not raise_error
14
+ end
15
+ end
16
+
17
+ describe "to_uri_param" do
18
+ it "should serialize the key and value into an acceptable uri format" do
19
+ param = CurbFu::Request::Parameter.new("simple", "value")
20
+ param.to_uri_param.should == "simple=value"
21
+ end
22
+ describe "complex cases" do
23
+ it "should convert a hash parameter into the appropriate set of name-value pairs" do
24
+ params = CurbFu::Request::Parameter.new("policy", { "archive_length_units" => "eons", "to" => "cthulhu@goo.org" })
25
+ params.to_uri_param.should =~ /policy\[archive_length_units\]=eons/
26
+ params.to_uri_param.should =~ /policy\[to\]=cthulhu\%40goo\.org/
27
+ params.to_uri_param.should =~ /.+&.+/
28
+ end
29
+ it "should even handle cases where one of the hash parameters is an array" do
30
+ params = CurbFu::Request::Parameter.new("messages", { "failed" => [2134, 123, 4325], "policy_id" => 45 })
31
+ params.to_uri_param.should =~ /messages\[failed\]\[\]=2134/
32
+ params.to_uri_param.should =~ /messages\[failed\]\[\]=123/
33
+ params.to_uri_param.should =~ /messages\[failed\]\[\]=4325/
34
+ params.to_uri_param.should =~ /messages\[policy_id\]=45/
35
+ params.to_uri_param.should =~ /.+&.+&.+&.+/
36
+ end
37
+ end
38
+ end
39
+
40
+ describe "to_curl_post_field" do
41
+ it "should serialize the key and value into an acceptable uri format" do
42
+ param = CurbFu::Request::Parameter.new("simple", "value")
43
+ field = param.to_curl_post_field
44
+ field.name.should == 'simple'
45
+ field.content.should == 'value'
46
+ end
47
+ describe "complex cases" do
48
+ it "should convert a hash parameter into the appropriate set of name-value pairs" do
49
+ params = CurbFu::Request::Parameter.new("policy",
50
+ { "archive_length_units" => "eons", "to" => "cthulhu@goo.org" })
51
+ fields = params.to_curl_post_field
52
+ fields.find { |f| f.name == 'policy[archive_length_units]' && f.content == 'eons'}.should_not be_nil
53
+ fields.find { |f| f.name == 'policy[to]' && f.content == 'cthulhu@goo.org'}.should_not be_nil
54
+ end
55
+ it "should even handle cases where one of the hash parameters is an array" do
56
+ params = CurbFu::Request::Parameter.new("messages", { "failed" => [2134, 123, 4325], "policy_id" => 45 }).
57
+ to_curl_post_field
58
+ params.find { |p| p.name == 'messages[failed][]' && p.content == '2134' }.should_not be_nil
59
+ params.find { |p| p.name == 'messages[failed][]' && p.content == '123' }.should_not be_nil
60
+ params.find { |p| p.name == 'messages[failed][]' && p.content == '4325' }.should_not be_nil
61
+ params.find { |p| p.name == 'messages[policy_id]' && p.content == '45' }.should_not be_nil
62
+ end
63
+ it "should not send a CGI-escaped value to Curl::PostField" do
64
+ field = CurbFu::Request::Parameter.new("messages", "uh-oh! We've failed!").
65
+ to_curl_post_field
66
+
67
+ field.content.should == "uh-oh! We've failed!"
68
+ end
69
+ it "should not CGI-escape @ symbols" do
70
+ field = CurbFu::Request::Parameter.new("messages", "bob@apple.com").
71
+ to_curl_post_field
72
+
73
+ field.content.should == "bob@apple.com"
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,223 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ def test_file_path
4
+ File.dirname(__FILE__) + "/../../../fixtures/foo.txt"
5
+ end
6
+
7
+ describe CurbFu::Request::Test do
8
+ before :each do
9
+ @a_server = mock(Object, :call => [200, { 'Content-Type' => 'spec/testcase' }, ["A is for Archer, an excellent typeface."]])
10
+ @b_server = mock(Object, :call => [200, {},["B is for Ballyhoo, like what happened when Twitter switched to Scala"]])
11
+ @c_server = mock(Object, :call => [200, {}, ["C is for Continuous, as in Integration"]])
12
+
13
+ CurbFu.stubs = {
14
+ 'a.example.com' => @a_server,
15
+ 'b.example.com' => @b_server,
16
+ 'c.example.com' => @c_server
17
+ }
18
+
19
+ @mock_rack_response = mock(Rack::MockResponse, :status => 200, :headers => {}, :body => "C is for Continuous, as in Integration")
20
+ end
21
+
22
+ describe "module inclusion" do
23
+ it "should define a 'get' method" do
24
+ class Test
25
+ include CurbFu::Request::Test
26
+ end
27
+ Test.should respond_to(:get)
28
+ end
29
+ end
30
+
31
+ describe "parse_hostname" do
32
+ it "should return just the hostname from a full URL" do
33
+ CurbFu::Request.parse_hostname('http://a.example.com/foo/bar?transaxle=true').
34
+ should == 'a.example.com'
35
+ end
36
+ it 'should return the hostname if just a hostname is given' do
37
+ CurbFu::Request.parse_hostname('b.example.com').
38
+ should == 'b.example.com'
39
+ end
40
+ end
41
+
42
+ describe "process_headers" do
43
+ it "should convert http headers into their upcased, HTTP_ prepended form for the Rack environment" do
44
+ CurbFu::Request.process_headers({'X-Mirror-Request' => 'true'}).should == {"HTTP_X_MIRROR_REQUEST" => "true"}
45
+ end
46
+ it "should handle a whole hashful of headers" do
47
+ CurbFu::Request.process_headers({
48
+ 'X-Mirror-Request' => 'true',
49
+ 'Accept-Encoding' => '*/*',
50
+ 'X-Forwarded-For' => 'greenviewdata.com'
51
+ }).should == {
52
+ "HTTP_X_MIRROR_REQUEST" => "true",
53
+ "HTTP_ACCEPT_ENCODING" => "*/*",
54
+ "HTTP_X_FORWARDED_FOR" => "greenviewdata.com"
55
+ }
56
+ end
57
+ end
58
+
59
+ describe "match_host" do
60
+ it "should return the appropriate Rack::Test instance to delegate the request to" do
61
+ CurbFu::Request.match_host("a.example.com").app.should == @a_server
62
+ end
63
+ it "should return nil if no match is made" do
64
+ CurbFu::Request.match_host("m.google.com").should be_nil
65
+ end
66
+ end
67
+
68
+ describe "build_request_options" do
69
+ it "should parse headers" do
70
+ CurbFu::Request.build_request_options({:host => 'd.example.com', :path => '/big/white/dog', :headers => { 'Accept' => 'beer/pilsner' }}).
71
+ should include(:headers => { 'Accept' => 'beer/pilsner' })
72
+ end
73
+ it "should parse url" do
74
+ CurbFu::Request.build_request_options({:host => 'd.example.com', :path => '/big/white/dog'}).
75
+ should include(:url => 'http://d.example.com/big/white/dog')
76
+ end
77
+ it "should parse username and password" do
78
+ CurbFu::Request.build_request_options({:host => 'd.example.com', :path => '/big/white/dog', :username => 'bill', :password => 's3cr3t' }).
79
+ should include(:username => 'bill', :password => 's3cr3t')
80
+ end
81
+ it "should get an interface" do
82
+ CurbFu::Request.build_request_options({:host => 'c.example.com', :path => '/big/white/dog'}).
83
+ should include(:interface => CurbFu.stubs['c.example.com'])
84
+ end
85
+ end
86
+
87
+ describe "get_interface" do
88
+ it "should parse a string" do
89
+ CurbFu::Request.get_interface('http://a.example.com').app.should == @a_server
90
+ end
91
+ it "should parse a hash" do
92
+ CurbFu::Request.get_interface({:host => 'a.example.com'}).app.should == @a_server
93
+ end
94
+ end
95
+
96
+ describe "respond" do
97
+ it "should convert headers to uppercase, underscorized" do
98
+ CurbFu::Response::Base.stub!(:from_rack_response)
99
+ mock_interface = mock(Object, :send => mock(Object, :status => 200), :hostname= => nil, :hostname => 'a.example.com')
100
+ mock_interface.should_receive(:header).with('HTTP_X_MONARCHY','false')
101
+ mock_interface.should_receive(:header).with('HTTP_X_ANARCHO_SYNDICALIST_COMMUNE','true')
102
+
103
+ CurbFu::Request.respond(mock_interface, :get, 'http://a.example.com/', {},
104
+ {'X-Anarcho-Syndicalist-Commune' => 'true', 'X-Monarchy' => 'false'}, nil, nil)
105
+ end
106
+ end
107
+
108
+ describe "hashify_params" do
109
+ it "should turn a URL-formatted query string into a hash of parameters" do
110
+ hash = CurbFu::Request.hashify_params("color=red&shape=round")
111
+ hash.should include('color' => 'red')
112
+ hash.should include('shape' => 'round')
113
+ end
114
+ it "should convert array-formatted params into a hash of arrays" do
115
+ hash = CurbFu::Request.hashify_params("make[]=Chevrolet&make[]=Pontiac&make[]=GMC")
116
+ hash.should == {'make' => ['Chevrolet','Pontiac','GMC']}
117
+ end
118
+ it "should convert hash parameters into a hash of hashes" do
119
+ hash = CurbFu::Request.hashify_params("car[make]=Chevrolet&car[color]=red&car[wheel_shape]=round")
120
+ hash.should == {'car' => {
121
+ 'make' => 'Chevrolet',
122
+ 'color' => 'red',
123
+ 'wheel_shape' => 'round'
124
+ }}
125
+ end
126
+ it 'should remove any leading ?s' do
127
+ hash = CurbFu::Request.hashify_params("?q=134&dave=astronaut")
128
+ hash.keys.should_not include('?q')
129
+ end
130
+ end
131
+
132
+ describe "get" do
133
+ it 'should delegate the get request to the Rack::Test instance' do
134
+ CurbFu.stubs['a.example.com'].should_receive(:get).with('http://a.example.com/gimme/html', anything, anything).and_return(@mock_rack_response)
135
+ @a_server.should respond_to(:call)
136
+ CurbFu::Request.get('http://a.example.com/gimme/html')
137
+ end
138
+ it 'should raise Curl::Err::ConnectionFailedError if hostname is not defined in stub list' do
139
+ lambda { CurbFu::Request.get('http://m.google.com/gimme/html') }.should raise_error(Curl::Err::ConnectionFailedError)
140
+ end
141
+ it 'should return a CurbFu::Response object' do
142
+ response = CurbFu::Request.get('http://a.example.com/gimme/html')
143
+ response.should be_a_kind_of(CurbFu::Response::Base)
144
+ response.status.should == 200
145
+ response.headers.should == { 'Content-Type' => 'spec/testcase' }
146
+ response.body.should == "A is for Archer, an excellent typeface."
147
+ end
148
+ end
149
+
150
+ describe "post" do
151
+ it 'should delegate the post request to the Rack::Test instance' do
152
+ CurbFu.stubs['b.example.com'].should_receive(:post).
153
+ with('http://b.example.com/html/backatcha', {'html' => 'CSRF in da house! <script type="text/compromise">alert("gotcha!")</script>'}, anything).
154
+ and_return(@mock_rack_response)
155
+ CurbFu::Request.post('http://b.example.com/html/backatcha',
156
+ {'html' => 'CSRF in da house! <script type="text/compromise">alert("gotcha!")</script>'})
157
+ end
158
+ it 'should raise Curl::Err::ConnectionFailedError if hostname is not defined in stub list' do
159
+ lambda { CurbFu::Request.post('http://m.google.com/gimme/html') }.should raise_error(Curl::Err::ConnectionFailedError)
160
+ end
161
+ it 'should return a CurbFu::Response object' do
162
+ response = CurbFu::Request.post('http://a.example.com/gimme/html')
163
+ response.should be_a_kind_of(CurbFu::Response::Base)
164
+ response.status.should == 200
165
+ response.headers.should == { 'Content-Type' => 'spec/testcase' }
166
+ response.body.should == "A is for Archer, an excellent typeface."
167
+ end
168
+ end
169
+
170
+ describe "post_file" do
171
+ it 'should delegate the post request to the Rack::Test instance' do
172
+ CurbFu.stubs['b.example.com'].should_receive(:post).
173
+ with('http://b.example.com/html/backatcha', hash_including("foo.txt"=>anything, "filename"=>"asdf ftw"), anything).
174
+ and_return(@mock_rack_response)
175
+ CurbFu::Request.post_file('http://b.example.com/html/backatcha', {'filename' => 'asdf ftw'}, {'foo.txt' => test_file_path })
176
+ end
177
+ it 'should raise Curl::Err::ConnectionFailedError if hostname is not defined in stub list' do
178
+ lambda { CurbFu::Request.post_file('http://m.google.com/gimme/html') }.should raise_error(Curl::Err::ConnectionFailedError)
179
+ end
180
+ it 'should return a CurbFu::Response object' do
181
+ response = CurbFu::Request.post_file('http://a.example.com/gimme/html')
182
+ response.should be_a_kind_of(CurbFu::Response::Base)
183
+ response.status.should == 200
184
+ response.headers.should == { 'Content-Type' => 'spec/testcase' }
185
+ response.body.should == "A is for Archer, an excellent typeface."
186
+ end
187
+ end
188
+
189
+ describe "put" do
190
+ it 'should delegate the put request to the Rack::Test instance' do
191
+ CurbFu.stubs['a.example.com'].should_receive(:put).with('http://a.example.com/gimme/html', anything, anything).and_return(@mock_rack_response)
192
+ CurbFu::Request.put('http://a.example.com/gimme/html')
193
+ end
194
+ it 'should raise Curl::Err::ConnectionFailedError if hostname is not defined in stub list' do
195
+ lambda { CurbFu::Request.put('http://m.google.com/gimme/html') }.should raise_error(Curl::Err::ConnectionFailedError)
196
+ end
197
+ it 'should return a CurbFu::Response object' do
198
+ response = CurbFu::Request.put('http://a.example.com/gimme/html')
199
+ response.should be_a_kind_of(CurbFu::Response::Base)
200
+ response.status.should == 200
201
+ response.headers.should == { 'Content-Type' => 'spec/testcase' }
202
+ response.body.should == "A is for Archer, an excellent typeface."
203
+ end
204
+ end
205
+
206
+ describe "delete" do
207
+ it 'should delegate the delete request to the Rack::Test instance' do
208
+ CurbFu.stubs['a.example.com'].should_receive(:delete).with('http://a.example.com/gimme/html', anything, anything).and_return(@mock_rack_response)
209
+ @a_server.should respond_to(:call)
210
+ CurbFu::Request.delete('http://a.example.com/gimme/html')
211
+ end
212
+ it 'should raise Curl::Err::ConnectionFailedError if hostname is not defined in stub list' do
213
+ lambda { CurbFu::Request.delete('http://m.google.com/gimme/html') }.should raise_error(Curl::Err::ConnectionFailedError)
214
+ end
215
+ it 'should return a CurbFu::Response object' do
216
+ response = CurbFu::Request.delete('http://a.example.com/gimme/html')
217
+ response.should be_a_kind_of(CurbFu::Response::Base)
218
+ response.status.should == 200
219
+ response.headers.should == { 'Content-Type' => 'spec/testcase' }
220
+ response.body.should == "A is for Archer, an excellent typeface."
221
+ end
222
+ end
223
+ end
@@ -0,0 +1,99 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require 'htmlentities'
3
+
4
+ describe CurbFu::Response::Base do
5
+ describe "from_rack_response" do
6
+ it "should create a new CurbFu::Response object out of a rack response (array)" do
7
+ rack = mock(Object, :status => 200, :headers => { 'Expires' => '05-12-2034' }, :body => "This will never go out of style")
8
+ response = CurbFu::Response::Base.from_rack_response(rack)
9
+ response.should be_a_kind_of(CurbFu::Response::OK)
10
+ response.body.should == "This will never go out of style"
11
+ response.headers.should include('Expires' => '05-12-2034')
12
+ end
13
+ end
14
+
15
+ describe "from_curb_response" do
16
+ it "should create a new CurbFu::Response object out of a curb response object" do
17
+ curb = mock(Curl::Easy, :body_str => "Miscellaneous Facts About Curb", :header_str => "HTTP/1.1 200 OK\r\nCache-Control: private, max-age=0\r\nDate: Tue, 17 Mar 2009 17:34:08 GMT\r\nExpires: -1\r\n", :response_code => 200 )
18
+ response = CurbFu::Response::Base.from_curb_response(curb)
19
+ response.should be_a_kind_of(CurbFu::Response::OK)
20
+ response.body.should == "Miscellaneous Facts About Curb"
21
+ response.headers.should include("Expires" => '-1', "Cache-Control" => 'private, max-age=0')
22
+ response.status.should == 200
23
+ end
24
+ end
25
+
26
+ describe "successes" do
27
+ it "should create a success (200) response" do
28
+ mock_curb = mock(Object, :response_code => 200, :body_str => 'OK', :header_str => "")
29
+ r = CurbFu::Response::Base.from_curb_response(mock_curb)
30
+ r.should be_a_kind_of(CurbFu::Response::Base)
31
+ r.should be_a_kind_of(CurbFu::Response::Success)
32
+ r.should be_a_kind_of(CurbFu::Response::OK)
33
+ r.should_not be_a_kind_of(CurbFu::Response::Created)
34
+ end
35
+ it "should create a success (201) response" do
36
+ mock_curb = mock(Object, :response_code => 201, :body_str => 'OK', :header_str => "")
37
+ r = CurbFu::Response::Base.from_curb_response(mock_curb)
38
+ r.should be_a_kind_of(CurbFu::Response::Base)
39
+ r.should be_a_kind_of(CurbFu::Response::Success)
40
+ r.should be_a_kind_of(CurbFu::Response::Created)
41
+ end
42
+ end
43
+ it "should create a 400 response" do
44
+ mock_curb = mock(Object, :response_code => 404, :body_str => 'OK', :header_str => "", :timeout= => nil)
45
+ r = CurbFu::Response::Base.from_curb_response(mock_curb)
46
+ r.should be_a_kind_of(CurbFu::Response::Base)
47
+ r.should be_a_kind_of(CurbFu::Response::ClientError)
48
+ end
49
+ it "should create a 500 response" do
50
+ mock_curb = mock(Object, :response_code => 503, :body_str => 'OK', :header_str => "", :timeout= => nil)
51
+ r = CurbFu::Response::Base.from_curb_response(mock_curb)
52
+ r.should be_a_kind_of(CurbFu::Response::Base)
53
+ r.should be_a_kind_of(CurbFu::Response::ServerError)
54
+ end
55
+
56
+ describe "response modules" do
57
+ describe "to_i" do
58
+ it "should return the status code represented by the module" do
59
+ CurbFu::Response::OK.to_i.should == 200
60
+ CurbFu::Response::NotFound.to_i.should == 404
61
+ end
62
+ end
63
+ end
64
+
65
+ describe "parse_headers" do
66
+ before(:each) do
67
+ end
68
+
69
+ describe "test data" do
70
+ it "should parse all of Google's headers" do
71
+ headers = "HTTP/1.1 200 OK\r\nCache-Control: private, max-age=0\r\nDate: Tue, 17 Mar 2009 17:34:08 GMT\r\nExpires: -1\r\nContent-Type: text/html; charset=ISO-8859-1\r\nSet-Cookie: PREF=ID=16472704f58eb437:TM=1237311248:LM=1237311248:S=KrWlq33vvam8d_De; expires=Thu, 17-Mar-2011 17:34:08 GMT; path=/; domain=.google.com\r\nServer: gws\r\nTransfer-Encoding: chunked\r\n\r\n"
72
+ mock_curb = mock(Object, :response_code => 200, :body_str => 'OK', :header_str => headers, :timeout= => nil)
73
+ @cf = CurbFu::Response::Base.from_curb_response(mock_curb)
74
+
75
+ @cf.headers['Cache-Control'].should == 'private, max-age=0'
76
+ @cf.headers['Date'].should == 'Tue, 17 Mar 2009 17:34:08 GMT'
77
+ @cf.headers['Expires'].should == '-1'
78
+ @cf.headers['Content-Type'].should == 'text/html; charset=ISO-8859-1'
79
+ @cf.headers['Set-Cookie'].should == 'PREF=ID=16472704f58eb437:TM=1237311248:LM=1237311248:S=KrWlq33vvam8d_De; expires=Thu, 17-Mar-2011 17:34:08 GMT; path=/; domain=.google.com'
80
+ @cf.headers['Server'].should == 'gws'
81
+ @cf.headers['Transfer-Encoding'].should == 'chunked'
82
+ @cf.headers.keys.length.should == 7
83
+ end
84
+
85
+ it "should parse our json headers from the data_store" do
86
+ headers = "HTTP/1.1 200 OK\r\nServer: nginx/0.6.34\r\nDate: Tue, 17 Mar 2009 05:40:32 GMT\r\nContent-Type: text/json\r\nConnection: close\r\nContent-Length: 18\r\n\r\n"
87
+ mock_curb = mock(Object, :response_code => 200, :body_str => 'OK', :header_str => headers, :timeout= => nil)
88
+ @cf = CurbFu::Response::Base.from_curb_response(mock_curb)
89
+
90
+ @cf.headers['Server'].should == 'nginx/0.6.34'
91
+ @cf.headers['Date'].should == 'Tue, 17 Mar 2009 05:40:32 GMT'
92
+ @cf.headers['Content-Type'].should == 'text/json'
93
+ @cf.headers['Connection'].should == 'close'
94
+ @cf.headers['Content-Length'].should == '18'
95
+ @cf.headers.keys.length.should == 5
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe CurbFu do
4
+ describe "stubs=" do
5
+ it 'should insert the CurbFu::Request::Test module into CurbFu::Request' do
6
+ CurbFu.stubs = { 'example.com' => mock(Object, :call => [200, {}, "Hello, World"] ) }
7
+ CurbFu::Request.should include(CurbFu::Request::Test)
8
+ end
9
+ it 'should not insert the CurbFu::StubbedRequest module into CurbFu::Request if it is already there' do
10
+ CurbFu::Request.stub!(:include?).and_return(false, true)
11
+ CurbFu::Request.should_receive(:include).once
12
+ CurbFu.stubs = { 'example.com' => mock(Object, :call => [200, {}, "Hello, World"] ) }
13
+ CurbFu.stubs = { 'example.net' => mock(Object, :call => [404, {}, "not found"] ) }
14
+ end
15
+ it 'should not insert the CurbFu::StubbedRequest module if the method is given nil instead of a hash' do
16
+ CurbFu::Request.should_not_receive(:include)
17
+ CurbFu.stubs = nil
18
+ end
19
+ end
20
+
21
+ describe 'stub' do
22
+ it 'should create a stub interface for the given hostname using the supplied object' do
23
+ CurbFu.stubs = { 'localhost' => Object }
24
+ my_rack_app = mock(Object)
25
+ CurbFu.stub('webserver.com',my_rack_app)
26
+ CurbFu.stubs['webserver.com'].
27
+ should be_an_instance_of(CurbFu::Request::Test::Interface)
28
+ CurbFu.stubs = nil
29
+ end
30
+ end
31
+
32
+ describe 'stubs' do
33
+ it 'should return nil by default' do
34
+ CurbFu.stubs = nil # no way to guarantee that CurbFu.stubs hasn't already been set by another spec
35
+ CurbFu.stubs.should be_nil
36
+ end
37
+ it 'should return a hash of hostnames pointing to CurbFu::StubbedRequest::TestInterfaces' do
38
+ CurbFu.stubs = { 'example.com' => mock(Object, :call => [200, {}, "Hello, World"] ) }
39
+ CurbFu.stubs['example.com'].should be_a_kind_of(CurbFu::Request::Test::Interface)
40
+ end
41
+ it 'should set the hostname on each interface' do
42
+ CurbFu.stubs = {
43
+ 'ysthevanishedomens.com' => mock(Object)
44
+ }
45
+
46
+ CurbFu.stubs['ysthevanishedomens.com'].hostname.should == 'ysthevanishedomens.com'
47
+ end
48
+ end
49
+ end