Skip to content

Commit

Permalink
Rspec change matcher doesn't allow for raised errors, so convert the …
Browse files Browse the repository at this point in the history
…error to a string
  • Loading branch information
dlpierce committed Sep 8, 2023
1 parent 78c2642 commit bfe5096
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/collection_branding_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def save(file_location, upload_file = true)
super()
end

def delete(location_path = nil)
def delete(_location_path = nil)
storage.delete(id: local_path)
end

Expand Down
10 changes: 7 additions & 3 deletions spec/models/collection_branding_info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@
before { banner_info.save(file.path) }

it "removes banner file" do
expect { banner_info.delete }
.to change { storage_adapter.find_by(id: banner_info.local_path) }
.to raise_error Valkyrie::StorageAdapter::FileNotFound
expect { banner_info.delete }.to change {
begin
storage_adapter.find_by(id: banner_info.local_path)
rescue Valkyrie::StorageAdapter::FileNotFound
'Raised FileNotFound' # Convert the raised error so change can detect it
end
}.from(be_a(Valkyrie::StorageAdapter::File)).to(eq 'Raised FileNotFound')
end
end
end

0 comments on commit bfe5096

Please sign in to comment.