Commit 75739e54 authored by Robert Speicher's avatar Robert Speicher

Enable RSpec/NotToNot cop and auto-correct offenses

Also removes the note from the development/testing.md guide
parent 16ca3ee6
......@@ -1130,7 +1130,7 @@ RSpec/MultipleDescribes:
# Enforces the usage of the same method on all negative message expectations.
RSpec/NotToNot:
EnforcedStyle: not_to
Enabled: false
Enabled: true
# Prefer using verifying doubles over normal doubles.
RSpec/VerifiedDoubles:
......
......@@ -65,7 +65,7 @@ the command line via `bundle exec teaspoon`, or via a web browser at
- Use `context` to test branching logic.
- Don't `describe` symbols (see [Gotchas](gotchas.md#dont-describe-symbols)).
- Don't supply the `:each` argument to hooks since it's the default.
- Prefer `not_to` to `to_not`.
- Prefer `not_to` to `to_not` (_this is enforced by Rubocop_).
- Try to match the ordering of tests to the ordering within the class.
- Try to follow the [Four-Phase Test][four-phase-test] pattern, using newlines
to separate phases.
......
......@@ -158,7 +158,7 @@ class Spinach::Features::AdminUsers < Spinach::FeatureSteps
step 'I should not see twitter details' do
expect(page).to have_content 'Pete'
expect(page).to_not have_content 'twitter'
expect(page).not_to have_content 'twitter'
end
step 'click on ssh keys tab' do
......
......@@ -106,7 +106,7 @@ def should_see_todo(position, title, body, pending = true)
if pending
expect(page).to have_link 'Done'
else
expect(page).to_not have_link 'Done'
expect(page).not_to have_link 'Done'
end
end
end
......
......@@ -105,7 +105,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
end
step 'I should not see button to create a new merge request' do
expect(page).to_not have_link 'Create Merge Request'
expect(page).not_to have_link 'Create Merge Request'
end
step 'I should see button to the merge request' do
......
......@@ -39,8 +39,8 @@ class Spinach::Features::AwardEmoji < Spinach::FeatureSteps
step 'I can see the activity and food categories' do
page.within '.emoji-menu' do
expect(page).to_not have_selector 'Activity'
expect(page).to_not have_selector 'Food'
expect(page).not_to have_selector 'Activity'
expect(page).not_to have_selector 'Food'
end
end
......
......@@ -216,7 +216,7 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
page.within 'li.issue:nth-child(3)' do
expect(page).to have_content 'Bugfix'
expect(page).to_not have_content '0 0'
expect(page).not_to have_content '0 0'
end
end
end
......@@ -235,7 +235,7 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
page.within 'li.issue:nth-child(3)' do
expect(page).to have_content 'Bugfix'
expect(page).to_not have_content '0 0'
expect(page).not_to have_content '0 0'
end
end
end
......
......@@ -203,7 +203,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
page.within 'li.merge-request:nth-child(3)' do
expect(page).to have_content 'Bug NS-05'
expect(page).to_not have_content '0 0'
expect(page).not_to have_content '0 0'
end
end
end
......@@ -222,7 +222,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
page.within 'li.merge-request:nth-child(3)' do
expect(page).to have_content 'Bug NS-05'
expect(page).to_not have_content '0 0'
expect(page).not_to have_content '0 0'
end
end
end
......
......@@ -107,7 +107,7 @@ module SharedNote
end
step 'I should see no notes at all' do
expect(page).to_not have_css('.note')
expect(page).not_to have_css('.note')
end
# Markdown
......
......@@ -17,7 +17,7 @@
it 'does not retrieve the project' do
get :index, visibility_levels: [Gitlab::VisibilityLevel::INTERNAL]
expect(response.body).to_not match(project.name)
expect(response.body).not_to match(project.name)
end
end
end
......@@ -19,7 +19,7 @@
to: ref_to)
expect(response).to be_success
expect(assigns(:diffs).first).to_not be_nil
expect(assigns(:diffs).first).not_to be_nil
expect(assigns(:commits).length).to be >= 1
end
......@@ -32,7 +32,7 @@
w: 1)
expect(response).to be_success
expect(assigns(:diffs).first).to_not be_nil
expect(assigns(:diffs).first).not_to be_nil
expect(assigns(:commits).length).to be >= 1
# without whitespace option, there are more than 2 diff_splits
diff_splits = assigns(:diffs).first.diff.split("\n")
......
......@@ -43,7 +43,7 @@
end
it 'does not share project with that group' do
expect(group.shared_projects).to_not include project
expect(group.shared_projects).not_to include project
end
end
end
......
......@@ -56,7 +56,7 @@
move_issue
expect(response).to have_http_status :found
expect(another_project.issues).to_not be_empty
expect(another_project.issues).not_to be_empty
end
end
......
......@@ -38,7 +38,7 @@
include_context 'import applied'
it 'does not import team members' do
expect(project.team_members).to_not include member
expect(project.team_members).not_to include member
end
it 'responds with not found' do
......
......@@ -16,7 +16,7 @@
it 'logs user in directly' do
post(:create, user_params)
expect(ActionMailer::Base.deliveries.last).to be_nil
expect(subject.current_user).to_not be_nil
expect(subject.current_user).not_to be_nil
end
end
......
......@@ -47,7 +47,7 @@ def authenticate_2fa(user_params)
authenticate_2fa(login: another_user.username,
otp_attempt: another_user.current_otp)
expect(subject.current_user).to_not eq another_user
expect(subject.current_user).not_to eq another_user
end
end
......@@ -56,7 +56,7 @@ def authenticate_2fa(user_params)
authenticate_2fa(login: another_user.username,
otp_attempt: 'invalid')
expect(subject.current_user).to_not eq another_user
expect(subject.current_user).not_to eq another_user
end
end
......@@ -73,7 +73,7 @@ def authenticate_2fa(user_params)
before { authenticate_2fa(otp_attempt: 'invalid') }
it 'does not authenticate' do
expect(subject.current_user).to_not eq user
expect(subject.current_user).not_to eq user
end
it 'warns about invalid OTP code' do
......
......@@ -6,7 +6,7 @@
let(:entity) { build(factory.name) }
it 'does not raise error when created' do
expect { entity }.to_not raise_error
expect { entity }.not_to raise_error
end
it 'should be valid', if: factory.build_class < ActiveRecord::Base do
......
......@@ -79,7 +79,7 @@
end
it 'changes registration token' do
expect(page_token).to_not eq token
expect(page_token).not_to eq token
end
end
end
......
......@@ -152,7 +152,7 @@
it 'sees impersonation log out icon' do
icon = first('.fa.fa-user-secret')
expect(icon).to_not eql nil
expect(icon).not_to eql nil
end
it 'can log out of impersonated user back to original user' do
......
......@@ -47,7 +47,7 @@
it { expect(page).to have_content @build.short_sha }
it { expect(page).to have_content @build.ref }
it { expect(page).to have_content @build.name }
it { expect(page).to_not have_link 'Cancel running' }
it { expect(page).not_to have_link 'Cancel running' }
end
end
......@@ -63,7 +63,7 @@
it { expect(page).to have_content @build.short_sha }
it { expect(page).to have_content @build.ref }
it { expect(page).to have_content @build.name }
it { expect(page).to_not have_link 'Cancel running' }
it { expect(page).not_to have_link 'Cancel running' }
end
describe "GET /:project/builds/:id" do
......
......@@ -137,8 +137,8 @@
expect(page).to have_content commit.git_commit_message
expect(page).to have_content commit.git_author_name
expect(page).to have_link('Download artifacts')
expect(page).to_not have_link('Cancel running')
expect(page).to_not have_link('Retry failed')
expect(page).not_to have_link('Cancel running')
expect(page).not_to have_link('Retry failed')
end
end
......@@ -155,9 +155,9 @@
expect(page).to have_content commit.sha[0..7]
expect(page).to have_content commit.git_commit_message
expect(page).to have_content commit.git_author_name
expect(page).to_not have_link('Download artifacts')
expect(page).to_not have_link('Cancel running')
expect(page).to_not have_link('Retry failed')
expect(page).not_to have_link('Download artifacts')
expect(page).not_to have_link('Cancel running')
expect(page).not_to have_link('Retry failed')
end
end
end
......
......@@ -95,7 +95,7 @@
find('.dropdown-menu-milestone a', text: "No Milestone").click
click_update_issues_button
expect(first('.issue')).to_not have_content milestone.title
expect(first('.issue')).not_to have_content milestone.title
end
end
......
......@@ -41,7 +41,7 @@
context 'when canceling' do
before { click_link('Cancel') }
it { expect(page).to_not have_link('Cancel') }
it { expect(page).not_to have_link('Cancel') }
it { expect(page).to have_selector('.ci-canceled') }
end
end
......@@ -57,7 +57,7 @@
context 'when retrying' do
before { click_link('Retry') }
it { expect(page).to_not have_link('Retry') }
it { expect(page).not_to have_link('Retry') }
it { expect(page).to have_selector('.ci-pending') }
end
end
......@@ -75,7 +75,7 @@
context 'without artifacts' do
let!(:without_artifacts) { create(:ci_build, :success, commit: pipeline, name: 'rspec', stage: 'test') }
it { expect(page).to_not have_selector('.build-artifacts') }
it { expect(page).not_to have_selector('.build-artifacts') }
end
end
end
......@@ -104,23 +104,23 @@
end
context 'retrying builds' do
it { expect(page).to_not have_content('retried') }
it { expect(page).not_to have_content('retried') }
context 'when retrying' do
before { click_on 'Retry failed' }
it { expect(page).to_not have_content('Retry failed') }
it { expect(page).not_to have_content('Retry failed') }
it { expect(page).to have_content('retried') }
end
end
context 'canceling builds' do
it { expect(page).to_not have_selector('.ci-canceled') }
it { expect(page).not_to have_selector('.ci-canceled') }
context 'when canceling' do
before { click_on 'Cancel running' }
it { expect(page).to_not have_content('Cancel running') }
it { expect(page).not_to have_content('Cancel running') }
it { expect(page).to have_selector('.ci-canceled') }
end
end
......
......@@ -29,8 +29,8 @@
end
before do
expect(page).to_not have_content(@specific_runner3.display_name)
expect(page).to_not have_content(@specific_runner3.display_name)
expect(page).not_to have_content(@specific_runner3.display_name)
expect(page).not_to have_content(@specific_runner3.display_name)
end
it "places runners in right places" do
......
......@@ -34,7 +34,7 @@
find('.btn-variable-delete').click
end
expect(page).to_not have_selector('variables-table')
expect(page).not_to have_selector('variables-table')
end
it 'should edit variable' do
......
......@@ -36,7 +36,7 @@
)
expect(helper.enabled_button_based_providers).to include('twitter')
expect(helper.enabled_button_based_providers).to_not include('github')
expect(helper.enabled_button_based_providers).not_to include('github')
end
end
end
......
......@@ -17,7 +17,7 @@
it 'does not include api credentials in a link' do
allow(ci_service).
to receive(:build_page).and_return("http://secretuser:secretpass@jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c")
expect(helper.ci_build_details_path(merge_request)).to_not match("secret")
expect(helper.ci_build_details_path(merge_request)).not_to match("secret")
end
end
......
......@@ -5,7 +5,7 @@
subject { AwardEmoji.urls }
it { is_expected.to be_an_instance_of(Array) }
it { is_expected.to_not be_empty }
it { is_expected.not_to be_empty }
context 'every Hash in the Array' do
it 'has the correct keys and values' do
......
......@@ -619,19 +619,19 @@ module Ci
context 'no dependencies' do
let(:dependencies) { }
it { expect { subject }.to_not raise_error }
it { expect { subject }.not_to raise_error }
end
context 'dependencies to builds' do
let(:dependencies) { ['build1', 'build2'] }
it { expect { subject }.to_not raise_error }
it { expect { subject }.not_to raise_error }
end
context 'dependencies to builds defined as symbols' do
let(:dependencies) { [:build1, :build2] }
it { expect { subject }.to_not raise_error }
it { expect { subject }.not_to raise_error }
end
context 'undefined dependency' do
......
......@@ -10,7 +10,7 @@
it { is_expected.to respond_to(:uri) }
it { is_expected.to respond_to(:path) }
it { expect(subject.repository('test')).to_not be_nil }
it { expect(subject.repository('test')).not_to be_nil }
context '#path' do
subject { registry.path }
......
......@@ -6,7 +6,7 @@
it { expect(repository).to respond_to(:registry) }
it { expect(repository).to delegate_method(:client).to(:registry) }
it { expect(repository.tag('test')).to_not be_nil }
it { expect(repository.tag('test')).not_to be_nil }
context '#path' do
subject { repository.path }
......@@ -27,7 +27,7 @@
context '#manifest' do
subject { repository.manifest }
it { is_expected.to_not be_nil }
it { is_expected.not_to be_nil }
end
context '#valid?' do
......@@ -39,7 +39,7 @@
context '#tags' do
subject { repository.tags }
it { is_expected.to_not be_empty }
it { is_expected.not_to be_empty }
end
end
......
......@@ -50,13 +50,13 @@
context '#config' do
subject { tag.config }
it { is_expected.to_not be_nil }
it { is_expected.not_to be_nil }
end
context '#created_at' do
subject { tag.created_at }
it { is_expected.to_not be_nil }
it { is_expected.not_to be_nil }
end
end
end
......
......@@ -59,7 +59,7 @@
bitbucket_access_token_secret: "test" } })
project.import_url = "ssh://git@bitbucket.org/test/test.git"
expect { described_class.from_project(project) }.to_not raise_error
expect { described_class.from_project(project) }.not_to raise_error
end
end
end
......@@ -122,7 +122,7 @@ def entry(path)
describe 'empty path', path: '' do
subject { |example| path(example) }
it { is_expected.to_not have_parent }
it { is_expected.not_to have_parent }
describe '#children' do
subject { |example| path(example).children }
......
......@@ -33,8 +33,8 @@
end
it { is_expected.to include issue_first.to_reference(new_project) }
it { is_expected.to_not include issue_second.to_reference(new_project) }
it { is_expected.to_not include merge_request.to_reference(new_project) }
it { is_expected.not_to include issue_second.to_reference(new_project) }
it { is_expected.not_to include merge_request.to_reference(new_project) }
end
context 'description ambigous elements' do
......
......@@ -32,13 +32,13 @@
let(:new_paths) { new_files.map(&:path) }
it 'rewrites content' do
expect(new_text).to_not eq text
expect(new_text).not_to eq text
expect(new_text.length).to eq text.length
end
it 'copies files' do
expect(new_files).to all(exist)
expect(old_paths).to_not match_array new_paths
expect(old_paths).not_to match_array new_paths
expect(old_paths).to all(include(old_project.path_with_namespace))
expect(new_paths).to all(include(new_project.path_with_namespace))
end
......@@ -48,8 +48,8 @@
end
it 'generates a new secret for each file' do
expect(new_paths).to_not include image_uploader.secret
expect(new_paths).to_not include zip_uploader.secret
expect(new_paths).not_to include image_uploader.secret
expect(new_paths).not_to include zip_uploader.secret
end
end
......
......@@ -368,7 +368,7 @@
expect(response['objects']).to be_kind_of(Array)
expect(response['objects'].first['oid']).to eq(sample_oid)
expect(response['objects'].first['size']).to eq(sample_size)
expect(lfs_object.projects.pluck(:id)).to_not include(project.id)
expect(lfs_object.projects.pluck(:id)).not_to include(project.id)
expect(lfs_object.projects.pluck(:id)).to include(public_project.id)
expect(response['objects'].first['actions']['upload']['href']).to eq("#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}.git/gitlab-lfs/objects/#{sample_oid}/#{sample_size}")
expect(response['objects'].first['actions']['upload']['header']).to eq('Authorization' => @auth)
......@@ -430,7 +430,7 @@
expect(response_body['objects'].last['oid']).to eq(sample_oid)
expect(response_body['objects'].last['size']).to eq(sample_size)
expect(response_body['objects'].last).to_not have_key('actions')
expect(response_body['objects'].last).not_to have_key('actions')
end
end
end
......
......@@ -67,7 +67,7 @@ def bar(text = 'bar')
allow(Gitlab::Metrics).to receive(:method_call_threshold).
and_return(100)
expect(transaction).to_not receive(:add_metric)
expect(transaction).not_to receive(:add_metric)
@dummy.foo
end
......@@ -147,7 +147,7 @@ def self.test; end
allow(Gitlab::Metrics).to receive(:method_call_threshold).
and_return(100)
expect(transaction).to_not receive(:add_metric)
expect(transaction).not_to receive(:add_metric)
@dummy.new.bar
end
......@@ -220,7 +220,7 @@ def kittens
described_class.instrument_methods(@dummy)
expect(@dummy).to_not respond_to(:_original_kittens)
expect(@dummy).not_to respond_to(:_original_kittens)
end
it 'can take a block to determine if a method should be instrumented' do
......@@ -228,7 +228,7 @@ def kittens
false
end
expect(@dummy).to_not respond_to(:_original_foo)
expect(@dummy).not_to respond_to(:_original_foo)
end
end
......
......@@ -130,7 +130,7 @@
100.times do
interval = sampler.sleep_interval
expect(interval).to_not eq(last)
expect(interval).not_to eq(last)
last = interval
end
......
......@@ -13,7 +13,7 @@
describe 'without a current transaction' do
it 'simply returns' do
expect_any_instance_of(Gitlab::Metrics::Transaction).
to_not receive(:increment)
not_to receive(:increment)
subscriber.sql(event)
end
......
......@@ -11,13 +11,13 @@
it 'adds a new transaction' do
collection.add(transaction)
expect(collection).to_not be_empty