debian-mirror-gitlab/spec/rubocop/cop/rspec/httparty_basic_auth_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.1 KiB
Ruby
Raw Normal View History

2021-02-22 17:27:13 +05:30
# frozen_string_literal: true
2022-10-11 01:57:18 +05:30
require 'rubocop_spec_helper'
2021-02-22 17:27:13 +05:30
require_relative '../../../../rubocop/cop/rspec/httparty_basic_auth'
2023-07-09 08:55:56 +05:30
RSpec.describe RuboCop::Cop::RSpec::HTTPartyBasicAuth, feature_category: :shared do
2021-02-22 17:27:13 +05:30
context 'when passing `basic_auth: { user: ... }`' do
2021-03-11 19:13:27 +05:30
it 'registers an offense and corrects', :aggregate_failures do
2021-02-22 17:27:13 +05:30
expect_offense(<<~SOURCE, 'spec/foo.rb')
HTTParty.put(
url,
basic_auth: { user: user, password: token },
^^^^ #{described_class::MESSAGE}
body: body
)
SOURCE
2021-03-11 19:13:27 +05:30
expect_correction(<<~SOURCE)
HTTParty.put(
url,
basic_auth: { username: user, password: token },
body: body
)
SOURCE
2021-02-22 17:27:13 +05:30
end
end
context 'when passing `basic_auth: { username: ... }`' do
2021-03-11 19:13:27 +05:30
it 'does not register an offense' do
2021-02-22 17:27:13 +05:30
expect_no_offenses(<<~SOURCE, 'spec/frontend/fixtures/foo.rb')
HTTParty.put(
url,
basic_auth: { username: user, password: token },
body: body
)
SOURCE
end
end
end