Class: Middleware::InstrumentationTest
Defined Under Namespace
Classes: FakeInstrumenter
Instance Method Summary
collapse
#capture_warnings, jruby?, rbx?, ssl_mode?, #test_default
#live_server, #live_server=, #live_server?
Instance Method Details
#conn(hash = nil) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'test/middleware/instrumentation_test.rb', line 74
def conn(hash = nil)
hash ||= {}
hash[:instrumenter] = @instrumenter
Faraday.new do |f|
f.request :instrumentation, hash
f.adapter :test do |stub|
stub.get '/' do
[200, {}, 'ok']
end
end
end
end
|
5
6
7
|
# File 'test/middleware/instrumentation_test.rb', line 5
def setup
@instrumenter = FakeInstrumenter.new
end
|
#test_default_instrumenter ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'test/middleware/instrumentation_test.rb', line 13
def test_default_instrumenter
begin
instrumenter = options.instrumenter
rescue NameError => err
assert_match 'ActiveSupport', err.to_s
else
assert_equal ActiveSupport::Notifications, instrumenter
end
end
|
#test_default_name ⇒ Object
9
10
11
|
# File 'test/middleware/instrumentation_test.rb', line 9
def test_default_name
assert_equal 'request.faraday', options.name
end
|
#test_instrumentation ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'test/middleware/instrumentation_test.rb', line 44
def test_instrumentation
assert_equal 0, @instrumenter.instrumentations.size
faraday = conn :name => 'booya'
res = faraday.get '/'
assert_equal 'ok', res.body
assert_equal 1, @instrumenter.instrumentations.size
name, env = @instrumenter.instrumentations.first
assert_equal 'booya', name
assert_equal '/', env[:url].path
end
|
#test_instrumentation_with_default_name ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'test/middleware/instrumentation_test.rb', line 31
def test_instrumentation_with_default_name
assert_equal 0, @instrumenter.instrumentations.size
faraday = conn
res = faraday.get '/'
assert_equal 'ok', res.body
assert_equal 1, @instrumenter.instrumentations.size
name, env = @instrumenter.instrumentations.first
assert_equal 'request.faraday', name
assert_equal '/', env[:url].path
end
|
#test_instrumenter ⇒ Object
27
28
29
|
# File 'test/middleware/instrumentation_test.rb', line 27
def test_instrumenter
assert_equal :boom, options(:instrumenter => :boom).instrumenter
end
|
#test_name ⇒ Object
23
24
25
|
# File 'test/middleware/instrumentation_test.rb', line 23
def test_name
assert_equal 'booya', options(:name => 'booya').name
end
|