Skip to content

Commit

Permalink
(maint) Prefer negative expectations in spec tests
Browse files Browse the repository at this point in the history
Previously there were many cases of using a negative matcher instead of using
a negative expectation.  This commit changes use of `.never` to `.not_to` to
be consistent with the rest of the test suite.
  • Loading branch information
glennsarti committed Dec 9, 2019
1 parent c354423 commit 2959840
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion spec/unit/pdk/cli/release/prep_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
end

it 'does not start an interview when --force is used' do
expect(PDK::CLI::Util::Interview).to receive(:new).never
expect(PDK::CLI::Util::Interview).not_to receive(:new)

PDK::CLI.run(cli_args.concat(%w[--force]))
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/pdk/cli/release/publish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
end

it 'does not start an interview when --force is used' do
expect(PDK::CLI::Util::Interview).to receive(:new).never
expect(PDK::CLI::Util::Interview).not_to receive(:new)

PDK::CLI.run(cli_args.concat(%w[--force]))
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/pdk/cli/release_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
end

it 'does not start an interview when --force is used' do
expect(PDK::CLI::Util::Interview).to receive(:new).never
expect(PDK::CLI::Util::Interview).not_to receive(:new)

PDK::CLI.run(%w[release --force])
end
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/pdk/config/namespace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def spec_simple_validator
end

it 'does not save values when reading defaults' do
expect(config).to receive(:save_data).never # rubocop:disable RSpec/SubjectStub This is an expectation, not a stub
expect(config).not_to receive(:save_data)
expect(config[:missing]).to be_nil
end

Expand Down Expand Up @@ -89,7 +89,7 @@ def spec_simple_validator
end

it 'does not save default values to disk' do
expect(config).to receive(:save_data).never # rubocop:disable RSpec/SubjectStub This is an expectation, not a stub
expect(config).not_to receive(:save_data)
expect(config[:spec_test]).to eq('spec_default')
end
end
Expand Down Expand Up @@ -141,7 +141,7 @@ def spec_simple_validator
end

it 'does not save values when using the default' do
expect(config).to receive(:save_data).never # rubocop:disable RSpec/SubjectStub This is an expectation, not a stub
expect(config).not_to receive(:save_data)
config.fetch(:missing, 'default')
end
end
Expand All @@ -157,7 +157,7 @@ def spec_simple_validator
default_to { 'spec_default' }
end
# The resolver should not trigger any saves unless persistent_defaults is set to true
expect(PDK::Util::Filesystem).to receive(:write_file).never
expect(PDK::Util::Filesystem).not_to receive(:write_file)
end

context 'with an empty filter' do
Expand Down
14 changes: 7 additions & 7 deletions spec/unit/pdk/module/release_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@
end

it 'does not do anything' do
expect(instance).to receive(:run_validations).never
expect(instance).to receive(:run_documentation).never
expect(instance).to receive(:run_dependency_checker).never
expect(instance).to receive(:run_build).never
expect(instance).to receive(:run_publish).never
expect(PDK::Util::ChangelogGenerator).to receive(:generate_changelog).never
expect(instance).not_to receive(:run_validations)
expect(instance).not_to receive(:run_documentation)
expect(instance).not_to receive(:run_dependency_checker)
expect(instance).not_to receive(:run_build)
expect(instance).not_to receive(:run_publish)
expect(PDK::Util::ChangelogGenerator).not_to receive(:generate_changelog)

instance.run
end
Expand Down Expand Up @@ -159,7 +159,7 @@

it 'does not save the version if it has not changed' do
expect(PDK::Util::ChangelogGenerator).to receive(:compute_next_version).with('1.0.0').and_return('1.0.0')
expect(mock_metadata_object).to receive(:write!).never
expect(mock_metadata_object).not_to receive(:write!)

instance.run

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/pdk/util/version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
allow(PDK::Util::Filesystem).to receive(:exist?).with('/tmp/package/PDK_VERSION').and_return(true)
allow(PDK::Util::Filesystem).to receive(:read_file).with('/tmp/package/PDK_VERSION').and_return('0.1.2.3.4.pkg_hash')
allow(PDK::Util::Filesystem).to receive(:directory?).with(%r{.git\Z}).and_return(false)
allow(PDK::CLI::Exec).to receive(:git).never
expect(PDK::CLI::Exec).not_to receive(:git)
end

describe '#git_ref' do
Expand Down

0 comments on commit 2959840

Please sign in to comment.