forked from Apipie/apipie-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This should be `get_resource_id`. The method `ignore_call?` wasn't exercised by the specs so it wasn't caught. (see Apipie#864) This was causing an exception when recording examples.
- Loading branch information
1 parent
661fc15
commit 55c1ae0
Showing
2 changed files
with
58 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe Apipie::Extractor::Collector do | ||
let(:recorder) { described_class.new } | ||
|
||
describe '#ignore_call?' do | ||
subject { recorder.ignore_call?(record) } | ||
|
||
let(:record) { { controller: controller, action: action } } | ||
let(:controller) { ActionController::Base } | ||
let(:action) { nil } | ||
|
||
context 'when controller is nil' do | ||
let(:controller) { nil } | ||
|
||
it { is_expected.to be true } | ||
end | ||
|
||
context 'when controller is ignored' do | ||
before do | ||
allow(Apipie.configuration).to receive(:ignored_by_recorder).and_return(['ActionController::Bas']) | ||
end | ||
|
||
it { is_expected.to be true } | ||
end | ||
|
||
context 'when resource#method is ignored' do | ||
let(:action) { 'ignored_action' } | ||
|
||
before do | ||
allow(Apipie.configuration).to receive(:ignored_by_recorder).and_return(['ActionController::Bas#ignored_action']) | ||
end | ||
|
||
it { is_expected.to be true } | ||
end | ||
|
||
context 'when controller is not an API controller' do | ||
before do | ||
allow(Apipie::Extractor).to receive(:controller_path).with('action_controller/base').and_return('foo') | ||
allow(Apipie).to receive(:api_controllers_paths).and_return([]) | ||
end | ||
|
||
it { is_expected.to be true } | ||
end | ||
|
||
context 'when controller is an API controller' do | ||
before do | ||
allow(Apipie::Extractor).to receive(:controller_path).with('action_controller/base').and_return('foo') | ||
allow(Apipie).to receive(:api_controllers_paths).and_return(['foo']) | ||
end | ||
|
||
it { is_expected.to be_falsey } | ||
end | ||
end | ||
end |