Add tests for label filtering

Signed-off-by: Tom Duffield <tom@chef.io>
This commit is contained in:
Tom Duffield 2016-11-20 09:57:38 -06:00 committed by Hunter Haugen
parent ce63f648ac
commit 0ca7371306
No known key found for this signature in database
GPG Key ID: EF99694AA599DDAD

View File

@ -17,14 +17,56 @@ module GitHubChangelogGenerator
expect(result).not_to include(issue)
end
context "with no option given" do
subject(:generator) { described_class.new }
it "passes everything through when no option given" do
result = generator.exclude_issues_by_labels(issues)
it { is_expected.to eq(expected_issues) }
end
expect(result).to eq(issues)
context "get_filtered_issues" do
let(:default_options) { GitHubChangelogGenerator::Parser.default_options }
let(:options) { {} }
let(:generator) { described_class.new(default_options.merge(options)) }
let(:bad_label) { { "name" => "BAD" } }
let(:bad_issue) { { "labels" => [bad_label] } }
let(:good_label) { { "name" => "GOOD" } }
let(:good_issue) { { "labels" => [good_label] } }
let(:unlabeled_issue) { { "labels" => [] } }
let(:issues) { [bad_issue, good_issue, unlabeled_issue] }
subject do
generator.get_filtered_issues(issues)
end
let(:expected_issues) { issues }
it { is_expected.to eq(expected_issues) }
describe "when 'exclude_labels' is provided" do
let(:options) { { exclude_labels: %w(BAD BOO) } }
let(:expected_issues) { [good_issue, unlabeled_issue] }
it { is_expected.to eq(expected_issues) }
end
end
context "when 'add_issues_wo_labels' is false" do
let(:options) { { add_issues_wo_labels: false } }
let(:expected_issues) { [bad_issue, good_issue] }
it { is_expected.to eq(expected_issues) }
context "with 'exclude_labels'" do
let(:options) { { add_issues_wo_labels: false, exclude_labels: %w(GOOD) } }
let(:expected_issues) { [bad_issue] }
it { is_expected.to eq(expected_issues) }
end
end
context "when 'include_labels' is specified" do
let(:options) { { include_labels: %w(GOOD) } }
let(:expected_issues) { [good_issue] }
it { is_expected.to eq(expected_issues) }
end
end
end