Skip to content

Commit 8bf76ee

Browse files
committed
Move the default filter to be the last if statement
Otherwise if you only set an exclusion filter it will be ignored and everything will be documented.
1 parent 2fdcbc6 commit 8bf76ee

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/rspec_api_documentation/example.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ def http_method
2525

2626
def should_document?
2727
return false if pending? || !metadata[:resource_name] || !metadata[:document]
28-
return true if configuration.filter == :all
2928
return false if (Array(metadata[:document]) & Array(configuration.exclusion_filter)).length > 0
3029
return true if (Array(metadata[:document]) & Array(configuration.filter)).length > 0
30+
return true if configuration.filter == :all
3131
end
3232

3333
def public?

spec/example_spec.rb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
end
7171

7272
context "configuration sets a filter" do
73-
before do
73+
before do
7474
configuration.filter = :public
7575
configuration.exclusion_filter = :excluded
7676
end
@@ -93,6 +93,24 @@
9393
it { should be_false }
9494
end
9595
end
96+
97+
context "configuration only sets an exclusion filter" do
98+
before do
99+
configuration.exclusion_filter = :excluded
100+
end
101+
102+
context "when example doesn't match exclusion" do
103+
let(:metadata) { { :resource_name => "foo", :document => :public } }
104+
105+
it { should be_true }
106+
end
107+
108+
context "when example matches exclusion" do
109+
let(:metadata) { { :resource_name => "foo", :document => [:public, :excluded] } }
110+
111+
it { should be_false }
112+
end
113+
end
96114
end
97115

98116
describe "#public?" do

0 commit comments

Comments
 (0)