Skip to content

Commit

Permalink
Minor tweaks in README, plus CoC
Browse files Browse the repository at this point in the history
  • Loading branch information
unindented committed Jun 22, 2016
1 parent cdb0209 commit ae852ba
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
# PgTester [![Build Status](https://travis-ci.org/Microsoft/pgtester.svg?branch=master)](https://travis-ci.org/Microsoft/pgtester) [![Dependency Status](https://www.versioneye.com/user/projects/5760240349310500442edfc3/badge.svg?style=flat)](https://www.versioneye.com/user/projects/5760240349310500442edfc3)

A handy gem to help with testing postgresql related scripts or anything postgresql related
A handy gem to help with testing postgresql related scripts or anything PostgreSQL related.

## Installation

Add this line to your application's Gemfile (source https://rubygems.org):
Add this line to your application's `Gemfile` (source <https://rubygems.org>):

```ruby
gem 'pg_tester'
```

And then execute:

$ bundle
```
$ bundle
```

Or install it yourself as:

$ gem install pg_tester
```
$ gem install pg_tester
```

## Usage

Initialize `PgTester` instance
Initialize a `PgTester` instance:

```
```ruby
require 'pg_tester'

psql = PgTester.new({
Expand All @@ -39,44 +43,48 @@ psql = PgTester.new({
})
```

Case 1
### Case 1

Create a test postgres cluster in /tmp, connection as testpostgresql user and database name testpostgresql and run queries against the test database.
```
Create a test PostgreSQL cluster in `/tmp`, connect as `testpostgresql` user and database name `testpostgresql`, and run queries against the test database:

```ruby
psql.setup
result = psql.exec(query)
# ... do some expectation on result
```

Remember to teardown the database to stop postgresql
```
Remember to teardown the database to stop PostgreSQL:

```ruby
psql.teardown # Cluster is torn down and dir in /tmp deleted
```

Case 2
### Case 2

Execute the block and teardown database after block execution
```
Execute the block and teardown database after block execution:

```ruby
psql.exec(query) do |result|
# ... do some expectation on result
end
```

Case 3
### Case 3

Pass custom arguments and execute query in block
```
Pass custom arguments and execute query in block:

```ruby
PgTester.new({
port: '312',
data_dir: '/tmp/',
}).exec(query) { |result| # some expectation }
```

Case 4
### Case 4

The rspec usage
Use inside `rspec` specs:

```
```ruby
context 'run query in block' do
it 'should run exec query in a block' do
PgTester.new().exec('SELECT 2') do |result|
Expand All @@ -88,15 +96,16 @@ context 'run query in block' do
PgTester.new().exec('SELECT 3') { |result| expect(result.getvalue(0,0)).to eq("3") }
end
end
```

## Contributing

Pull requests are welcome!

## Tests

You can run the tests by doing

`bundle exec rspec`

## Contributing

Pull requests are welcome!

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

0 comments on commit ae852ba

Please sign in to comment.