chrisk-fakeweb 1.1.2.4 → 1.1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +42 -31
- data/README.rdoc +63 -43
- data/Rakefile +33 -29
- data/lib/fake_net_http.rb +9 -10
- data/lib/fake_web.rb +66 -12
- data/test/test_allow_net_connect.rb +44 -0
- data/test/test_fake_web.rb +35 -35
- data/test/test_fake_web_open_uri.rb +2 -5
- data/test/test_helper.rb +52 -0
- data/test/test_query_string.rb +37 -0
- metadata +17 -6
- data/fakeweb.gemspec +0 -16
- data/setup.rb +0 -1585
- data/test/test_examples.rb +0 -45
data/test/test_examples.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
$:.unshift "#{File.dirname(__FILE__)}/../lib"
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'fake_web'
|
5
|
-
require 'open-uri'
|
6
|
-
|
7
|
-
class FakeWebExampleTest < Test::Unit::TestCase
|
8
|
-
def test_request
|
9
|
-
FakeWeb.register_uri('http://example.com/test_me', :string => "Hello World!")
|
10
|
-
content = Net::HTTP.get(URI.parse('http://example.com/test_me'))
|
11
|
-
assert_equal "Hello World!", content
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_request_with_response
|
15
|
-
FakeWeb.register_uri('http://www.google.com/', :response => `curl -is http://www.google.com/`)
|
16
|
-
Net::HTTP.start('www.google.com') do |req|
|
17
|
-
response = req.get('/')
|
18
|
-
if response.code == 200
|
19
|
-
assert_equal "OK", response.message
|
20
|
-
assert response.body.include?('<title>Google')
|
21
|
-
elsif response.code == 302
|
22
|
-
# Google redirects foreign sites to ccTLDs.
|
23
|
-
assert_equal "Found", response.message
|
24
|
-
assert response.body.include?('The document has moved')
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_request_with_custom_status
|
30
|
-
FakeWeb.register_uri('http://example.com/', :string => "Nothing to be found 'round here",
|
31
|
-
:status => ['404', 'Not Found'])
|
32
|
-
Net::HTTP.start('example.com') do |req|
|
33
|
-
response = req.get('/')
|
34
|
-
assert_equal "404", response.code
|
35
|
-
assert_equal "Not Found", response.message
|
36
|
-
assert_equal "Nothing to be found 'round here", response.body
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_open_uri
|
41
|
-
FakeWeb.register_uri('http://example.com/', :string => "Hello, World!")
|
42
|
-
content = open('http://example.com/').string
|
43
|
-
assert_equal "Hello, World!", content
|
44
|
-
end
|
45
|
-
end
|