Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test lint_files behavior when fail_on_error=true and select_block is implemented #199

Merged
merged 4 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
danger-swiftlint (0.34.0)
danger-swiftlint (0.35.0)
danger
rake (> 10)
thor (~> 1.0.0)
Expand Down
31 changes: 30 additions & 1 deletion spec/danger_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,36 @@ module Danger
expect(issues.length).to eql(warnings.length + errors.length)
end
end


context 'when select_block is implemented' do
it 'fails if fail_on_error is true' do
# given
@swiftlint.strict = false
allow(@swiftlint).to receive(:fail)
allow_any_instance_of(Swiftlint).to receive(:lint)
.and_return(@swiftlint_multiviolation_response)

# when
@swiftlint.lint_files('spec/fixtures/*.swift', inline_mode: true, fail_on_error: true) { |_| true }

# then
expect(@swiftlint).to have_received(:fail).at_least(:once)
end

it 'does not fail if fail_on_error is false' do
# given
@swiftlint.strict = false
allow(@swiftlint).to receive(:fail)
allow_any_instance_of(Swiftlint).to receive(:lint)
.and_return(@swiftlint_multiviolation_response)

# when
@swiftlint.lint_files('spec/fixtures/*.swift', inline_mode: true, fail_on_error: false) { |_| true }

# then
expect(@swiftlint).not_to have_received(:fail)
end
end

it 'parses environment variables set within the swiftlint config' do
ENV['ENVIRONMENT_EXAMPLE'] = 'excluded_dir'
Expand Down