Skip to content

Commit

Permalink
Removing RSpec matcher warning
Browse files Browse the repository at this point in the history
Prior to this commit the specs included the following warning:

> WARNING: Using `expect { }.not_to raise_error(SpecificErrorClass)`
> risks false positives, since literally any other error would cause the
> expectation to pass, including those raised by Ruby
> (e.g. NoMethodError, NameError and ArgumentError), meaning the
> code you are intending to test may not even get reached. Instead
> consider using `expect { }.not_to raise_error` or `expect { }.to
> raise_error(DifferentSpecificErrorClass)`.

With this commit, we're removing that warning.

Less warnings, means less chatter.

Related to:

- #43
  • Loading branch information
jeremyf committed Feb 7, 2023
1 parent 888ab93 commit 1fda389
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions spec/models/iiif_print/derivative_attachment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ module IiifPrint
destination_name: 'txt'
)
# attempt save without required data; expect failure
expect { model.save! }.not_to raise_exception(ActiveRecord::RecordInvalid)
expect { model.save! }.not_to raise_exception
end

it "saves when all fields completely set" do
model = described_class.create
model.fileset_id = 'someid123'
model.path = '/path/to/somefile'
model.destination_name = 'txt'
expect { model.save! }.not_to raise_exception(ActiveRecord::RecordInvalid)
expect { model.save! }.not_to raise_exception
end

it "saves when only path, destination_name set" do
model = described_class.create
model.fileset_id = nil
model.path = '/path/to/somefile'
model.destination_name = 'txt'
expect { model.save! }.not_to raise_exception(ActiveRecord::RecordInvalid)
expect { model.save! }.not_to raise_exception
end
end
end
4 changes: 2 additions & 2 deletions spec/models/iiif_print/ingest_file_relation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ def make_test_records
file_path: '/path/to/this',
derivative_path: '/path/to/that'
)
expect { model.save! }.not_to raise_exception(ActiveRecord::RecordInvalid)
expect { model.save! }.not_to raise_exception
end

it "will save when all fields completely set" do
model = described_class.create
model.file_path = '/path/to/sourcefile.tiff'
model.derivative_path = '/path/to/derived.jp2'
expect { model.save! }.not_to raise_exception(ActiveRecord::RecordInvalid)
expect { model.save! }.not_to raise_exception
end

it "can query derivative paths for primary file" do
Expand Down

0 comments on commit 1fda389

Please sign in to comment.