Skip to content

Commit

Permalink
feat: add test to the new method collection_name
Browse files Browse the repository at this point in the history
  • 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.
6 changes: 1 addition & 5 deletions spec/examples/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9cdb3b0

Please sign in to comment.