-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add test to the new method collection_name
- Loading branch information
Alef Ojeda de Oliveira
committed
Oct 12, 2023
1 parent
ff39505
commit 9cdb3b0
Showing
1 changed file
with
1 addition
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,33 +9,29 @@ | |
RSpec.describe Users do | ||
let(:user) { { name: "John Doe", email: "[email protected]", type: "DEFAULT" } } | ||
|
||
it { expect(Users.collection_name).to eq("users") } | ||
it { expect(Users.all).to be_a(Array) } | ||
|
||
it { expect(Users.insert(user)).to be_a(Hash) } | ||
|
||
it "should return a user by name" do | ||
response = Users.select(filter: user.slice(:name)).first | ||
expect(response).to be_a(Hash) | ||
expect(response["name"]).to eq("John Doe") | ||
end | ||
|
||
it "should update user by email" do | ||
set = { name: "John Doe Updated" } | ||
response = Users.update(where: user.slice(:email), set:) | ||
expect(response).to be_a(Hash) | ||
expect(response["modifiedCount"]).to eq(1) | ||
expect(response["matchedCount"]).to eq(1) | ||
end | ||
|
||
it "should delete user by email" do | ||
response = Users.destroy(where: user.slice(:email)) | ||
expect(response).to be_a(Hash) | ||
expect(response["deletedCount"]).to eq(1) | ||
end | ||
|
||
it "should delete all users" do | ||
response = Users.destroy_all | ||
expect(response).to be_a(Hash) | ||
expect(response["deletedCount"]).to be >= 0 | ||
end | ||
end |