-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from arathunku/add-missing-spec-for-middleware
Tests for middleware.
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,8 @@ def call(env) | |
analyze(env) do | ||
@app.call(env) | ||
end | ||
else | ||
@app.call(env) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require "spec_helper" | ||
|
||
describe Apipie::Extractor::Recorder::Middleware do | ||
let(:app) { ->(env) { [200, env, "app"] } } | ||
let(:stack) { Apipie::Extractor::Recorder::Middleware.new(app) } | ||
let(:request) { Rack::MockRequest.new(stack) } | ||
let(:response) { request.get('/') } | ||
|
||
it 'correctly process request without recording' do | ||
expect(stack).not_to receive(:analyze) | ||
response | ||
end | ||
|
||
it "analyze request if recording is set" do | ||
Apipie.configuration.record = true | ||
expect(Apipie::Extractor.call_recorder).to receive(:analyse_env) | ||
expect(Apipie::Extractor.call_recorder).to receive(:analyse_response) | ||
expect(Apipie::Extractor).to receive(:clean_call_recorder) | ||
response | ||
end | ||
end |