Class: TestUtils
Defined Under Namespace
Classes: FakeSafeBuffer
Instance Method Summary
collapse
#capture_warnings, jruby?, rbx?, ssl_mode?, #test_default
#live_server, #live_server=, #live_server?
Instance Method Details
#normalize(url) ⇒ Object
44
45
46
|
# File 'test/utils_test.rb', line 44
def normalize(url)
Faraday::Utils::URI(url)
end
|
4
5
6
|
# File 'test/utils_test.rb', line 4
def setup
@url = "http://example.com/abc"
end
|
#test_escaping_safe_buffer ⇒ Object
19
20
21
22
|
# File 'test/utils_test.rb', line 19
def test_escaping_safe_buffer
str = FakeSafeBuffer.new('$32,000.00')
assert_equal '%2432%2C000.00', Faraday::Utils.escape(str)
end
|
#test_parses_with_block ⇒ Object
38
39
40
41
42
|
# File 'test/utils_test.rb', line 38
def test_parses_with_block
with_default_uri_parser(lambda {|u| "booya#{"!" * u.size}" }) do
assert_equal 'booya!!!!!!!!!!!!!!!!!!!!!!', normalize(@url)
end
end
|
#test_parses_with_default ⇒ Object
24
25
26
27
28
29
|
# File 'test/utils_test.rb', line 24
def test_parses_with_default
with_default_uri_parser(nil) do
uri = normalize(@url)
assert_equal 'example.com', uri.host
end
end
|
#test_parses_with_URI ⇒ Object
31
32
33
34
35
36
|
# File 'test/utils_test.rb', line 31
def test_parses_with_URI
with_default_uri_parser(::URI) do
uri = normalize(@url)
assert_equal 'example.com', uri.host
end
end
|
#with_default_uri_parser(parser) ⇒ Object