Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implement Database#login and #logout

  • Loading branch information...
commit 4d4baaf0f1e60ccdc788bff59cb2555cbb838422 1 parent 1f47e77
@bernerdschaefer authored 1000jobboersen committed
View
5 lib/moped/database.rb
@@ -36,14 +36,13 @@ def drop
#
# @param [String] username the username
# @param [String] password the password
- # @raise [Errors::OperationFailure] when authentication fails
def login(username, password)
+ session.cluster.login(name, username, password)
end
# Log out from the current database.
- #
- # @raise [Errors::OperationFailure] when logout fails
def logout
+ session.cluster.logout(name)
end
# Run +command+ on the database.
View
16 spec/moped/database_spec.rb
@@ -67,4 +67,20 @@
database[:users]
end
end
+
+ describe "#login" do
+
+ it "logs in to the database with the username and password" do
+ session.cluster.should_receive(:login).with(:admin, "username", "password")
+ database.login("username", "password")
+ end
+ end
+
+ describe "#log out" do
+
+ it "logs out from the database" do
+ session.cluster.should_receive(:logout).with(:admin)
+ database.logout
+ end
+ end
end
View
20 spec/moped/session_spec.rb
@@ -258,6 +258,26 @@
end
end
+ describe "#login" do
+
+ it "delegates to the current database" do
+ database = mock(Moped::Database)
+ session.should_receive(:current_database).and_return(database)
+ database.should_receive(:login).with("username", "password")
+ session.login("username", "password")
+ end
+ end
+
+ describe "#logout" do
+
+ it "delegates to the current database" do
+ database = mock(Moped::Database)
+ session.should_receive(:current_database).and_return(database)
+ database.should_receive(:logout)
+ session.logout
+ end
+ end
+
describe "#socket_for" do
it "delegates to the cluster" do
Please sign in to comment.
Something went wrong with that request. Please try again.