-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
52 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
describe Singed::RackMiddleware do | ||
subject do | ||
instance.call(env) | ||
end | ||
|
||
let(:app) { ->(*) { [200, {'Content-Type' => 'text/plain'}, ['OK']] } } | ||
let(:instance) { described_class.new(app) } | ||
let(:env) { Rack::MockRequest.env_for('/', headers) } | ||
let(:headers) { {} } | ||
|
||
it 'returns a proper rack response' do | ||
status, _ = subject | ||
expect(status).to eq 200 | ||
end | ||
|
||
it 'does not capture a flamegraph by default' do | ||
expect_any_instance_of(Object).not_to receive(:flamegraph) | ||
subject | ||
end | ||
|
||
context 'when enabled' do | ||
before { allow(instance).to receive(:capture_flamegraph?).and_return(true) } | ||
|
||
it 'captures a flamegraph' do | ||
expect_any_instance_of(Object).to receive(:flamegraph) | ||
subject | ||
end | ||
end | ||
|
||
describe '.capture_flamegraph?' do | ||
subject { instance.capture_flamegraph?(env) } | ||
|
||
it { is_expected.to be false } | ||
|
||
context 'when HTTP_X_SINGED is true' do | ||
let(:headers) { { 'HTTP_X_SINGED' => 'true' } } | ||
|
||
it { is_expected.to be true } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters