Class: DeploymentTest::Postgres
- Inherits:
-
Object
- Object
- DeploymentTest::Postgres
- Defined in:
- lib/deployment_test/postgres.rb
Instance Method Summary collapse
- #database_exist?(name) ⇒ Boolean
-
#initialize(options = {}) ⇒ Postgres
constructor
A new instance of Postgres.
- #user_can_login?(name, password) ⇒ Boolean
- #user_exist?(name) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Postgres
Returns a new instance of Postgres.
6 7 8 9 10 11 12 13 |
# File 'lib/deployment_test/postgres.rb', line 6 def initialize( = {}) = { :host => "127.0.0.1", :dbname => 'postgres', :user => 'postgres', :password => 'postgres' }.merge() end |
Instance Method Details
#database_exist?(name) ⇒ Boolean
28 29 30 |
# File 'lib/deployment_test/postgres.rb', line 28 def database_exist?(name) database_count(name).entries[0]['count'] != '0' end |
#user_can_login?(name, password) ⇒ Boolean
19 20 21 22 23 24 25 26 |
# File 'lib/deployment_test/postgres.rb', line 19 def user_can_login?(name, password) begin PGconn.connect(.merge(:user=>name, :password => password)) true rescue PGError false end end |
#user_exist?(name) ⇒ Boolean
15 16 17 |
# File 'lib/deployment_test/postgres.rb', line 15 def user_exist?(name) user_count(name).entries[0]['count'] != '0' end |