purobu 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +40 -13
- data/lib/purobu/database_connection.rb +40 -0
- data/lib/purobu/dsl.rb +1 -0
- data/lib/purobu/helpers.rb +23 -0
- data/lib/purobu/heroku_helpers.rb +3 -0
- data/lib/purobu/runner.rb +0 -2
- data/lib/purobu/test.rb +0 -2
- data/lib/purobu/version.rb +1 -1
- data/lib/purobu.rb +3 -1
- data/purobu.gemspec +2 -1
- data/spec/purobu/database_connection_spec.rb +34 -0
- data/spec/purobu/helpers_spec.rb +27 -0
- metadata +30 -12
data/README.md
CHANGED
@@ -105,19 +105,46 @@ heroku_api.get_config_vars('some-app').body
|
|
105
105
|
# {"HEROKU_POSTGRESQL_PURPLE_URL"=>"postgres://user:pass@host:5732/database"}
|
106
106
|
heroku_api.get_addons('some-app').body
|
107
107
|
# [{"slug"=>"crane", "selective"=>false,
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
108
|
+
# "configured"=>true,
|
109
|
+
# "url"=>nil,
|
110
|
+
# "state"=>"public",
|
111
|
+
# "group_description"=>"Heroku Postgresql",
|
112
|
+
# "consumes_dyno_hours"=>false,
|
113
|
+
# "price"=>{"cents"=>0, "unit"=>"month"},
|
114
|
+
# "attachment_name"=>"HEROKU_POSTGRESQL_TEAL",
|
115
|
+
# "plan_description"=>"Crane",
|
116
|
+
# "name"=>"heroku-postgresql:crane",
|
117
|
+
# "beta"=>false,
|
118
|
+
# "attachable"=>false,
|
119
|
+
# "description"=>"Heroku Postgres Crane",
|
120
|
+
# "terms_of_service"=>false}]
|
121
|
+
```
|
122
|
+
|
123
|
+
## Adding helpers
|
124
|
+
|
125
|
+
You can add helpers to be used across your tests via `helpers`:
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
helpers do
|
129
|
+
def do_it
|
130
|
+
# it does it
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
test do
|
135
|
+
verify do
|
136
|
+
do_it # it does it
|
137
|
+
end
|
138
|
+
end
|
139
|
+
```
|
140
|
+
|
141
|
+
A `database_connection` helper is included which can be used in your tests:
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
url = 'postgres://user:pass@host/database'
|
145
|
+
database_connection(url) do |conn|
|
146
|
+
conn # a Sequel connection object
|
147
|
+
end
|
121
148
|
```
|
122
149
|
|
123
150
|
## Meta
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'sequel'
|
2
|
+
|
3
|
+
module Purobu
|
4
|
+
class DatabaseConnection
|
5
|
+
|
6
|
+
attr_reader :url
|
7
|
+
|
8
|
+
def initialize(url)
|
9
|
+
@url = url
|
10
|
+
end
|
11
|
+
|
12
|
+
def connect
|
13
|
+
attempts = 0
|
14
|
+
begin
|
15
|
+
connection = Sequel.connect(url)
|
16
|
+
rescue => e
|
17
|
+
Purobu.log(connection_failure: "Connection attempt to '#{@url}' failed.")
|
18
|
+
end
|
19
|
+
|
20
|
+
if block_given?
|
21
|
+
begin
|
22
|
+
yield connection
|
23
|
+
ensure
|
24
|
+
connection.disconnect
|
25
|
+
end
|
26
|
+
else
|
27
|
+
return connection
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module Helper
|
32
|
+
def database_connection(url, &block)
|
33
|
+
Purobu::DatabaseConnection.new(url).connect(&block)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
Purobu::Helpers.register(Purobu::DatabaseConnection::Helper)
|
40
|
+
end
|
data/lib/purobu/dsl.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Purobu
|
2
|
+
module Helpers
|
3
|
+
CLASSES = [Purobu::Test, Purobu::Runner, Purobu::DSL].freeze
|
4
|
+
|
5
|
+
def self.register(helpers)
|
6
|
+
CLASSES.each do |klass|
|
7
|
+
klass.class_eval do
|
8
|
+
include helpers
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module HelpersHelper
|
14
|
+
def helpers(&block)
|
15
|
+
::Purobu::Helpers.register(Module.new(&block))
|
16
|
+
end
|
17
|
+
alias :helper :helpers
|
18
|
+
end
|
19
|
+
self.register(HelpersHelper)
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
data/lib/purobu/runner.rb
CHANGED
data/lib/purobu/test.rb
CHANGED
data/lib/purobu/version.rb
CHANGED
data/lib/purobu.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require "purobu/version"
|
2
2
|
require "purobu/log"
|
3
3
|
require "purobu/configuration"
|
4
|
-
require "purobu/heroku_helpers"
|
5
4
|
require "purobu/test"
|
6
5
|
require "purobu/runner"
|
7
6
|
require "purobu/dsl"
|
7
|
+
require "purobu/helpers"
|
8
|
+
require "purobu/database_connection"
|
9
|
+
require "purobu/heroku_helpers"
|
8
10
|
require "purobu/heroku"
|
9
11
|
require "purobu/reporter"
|
data/purobu.gemspec
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/purobu/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Harold Giménez"]
|
6
6
|
gem.email = ["harold.gimenez@gmail.com"]
|
7
|
-
gem.description = %q{
|
7
|
+
gem.description = %q{ Black-box integration test framework for components on the Heroku platform. }
|
8
8
|
gem.summary = %q{ Black-box integration test framework for components on the Heroku platform. }
|
9
9
|
gem.homepage = "http://practiceovertheory.com"
|
10
10
|
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_dependency "heroku", "2.28.2"
|
19
19
|
gem.add_dependency "heroku-api"
|
20
20
|
gem.add_dependency "scrolls", "0.2.1"
|
21
|
+
gem.add_dependency "sequel"
|
21
22
|
gem.add_development_dependency "rspec"
|
22
23
|
gem.add_development_dependency "fakefs"
|
23
24
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'purobu'
|
2
|
+
|
3
|
+
describe Purobu::DatabaseConnection, '#connect' do
|
4
|
+
|
5
|
+
let(:url) { 'postgres:///foo' }
|
6
|
+
|
7
|
+
it 'yields a connection to the given url' do
|
8
|
+
conn = double(:connection, close: nil)
|
9
|
+
conn.should_receive(:disconnect).once
|
10
|
+
Sequel.should_receive(:connect).with(url).and_return(conn)
|
11
|
+
|
12
|
+
expect { |block|
|
13
|
+
Purobu::DatabaseConnection.new(url).connect &block
|
14
|
+
}.to yield_with_args(conn)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'gives the connection object when no block is given 'do
|
18
|
+
conn = double(:connection, close: nil)
|
19
|
+
conn.should_not_receive(:disconnect)
|
20
|
+
Sequel.should_receive(:connect).with(url).and_return(conn)
|
21
|
+
|
22
|
+
Purobu::DatabaseConnection.new(url).connect.should == conn
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'exposes a database_connection helper' do
|
26
|
+
conn = double(:conn)
|
27
|
+
conn.should_receive(:connect).once
|
28
|
+
Purobu::DatabaseConnection.stub(:new).with(url).and_return(conn)
|
29
|
+
|
30
|
+
test = Purobu::Test.new
|
31
|
+
test.database_connection(url)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'purobu'
|
2
|
+
|
3
|
+
module TestHelpers
|
4
|
+
def test_helper
|
5
|
+
throw :test_helper
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Purobu::Helpers, '.register' do
|
10
|
+
it 'makes helpers available to tests and the runner' do
|
11
|
+
Purobu::Helpers.register(TestHelpers)
|
12
|
+
|
13
|
+
test = Purobu::Test.new
|
14
|
+
expect { test.test_helper }.to throw_symbol :test_helper
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'exposes a helper helper' do
|
18
|
+
test = Purobu::Test.new
|
19
|
+
test.helper do
|
20
|
+
def test_helper
|
21
|
+
throw :test_helper
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
expect { test.test_helper }.to throw_symbol :test_helper
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: purobu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-06-26 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: heroku
|
16
|
-
requirement: &
|
16
|
+
requirement: &70336029135080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.28.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70336029135080
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: heroku-api
|
27
|
-
requirement: &
|
27
|
+
requirement: &70336029134040 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70336029134040
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: scrolls
|
38
|
-
requirement: &
|
38
|
+
requirement: &70336029021320 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - =
|
@@ -43,10 +43,21 @@ dependencies:
|
|
43
43
|
version: 0.2.1
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70336029021320
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sequel
|
49
|
+
requirement: &70336029004160 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70336029004160
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: rspec
|
49
|
-
requirement: &
|
60
|
+
requirement: &70336028995820 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ! '>='
|
@@ -54,10 +65,10 @@ dependencies:
|
|
54
65
|
version: '0'
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *70336028995820
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: fakefs
|
60
|
-
requirement: &
|
71
|
+
requirement: &70336028987520 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ! '>='
|
@@ -65,8 +76,9 @@ dependencies:
|
|
65
76
|
version: '0'
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
69
|
-
description: ! '
|
79
|
+
version_requirements: *70336028987520
|
80
|
+
description: ! ' Black-box integration test framework for components on the Heroku
|
81
|
+
platform. '
|
70
82
|
email:
|
71
83
|
- harold.gimenez@gmail.com
|
72
84
|
executables:
|
@@ -82,7 +94,9 @@ files:
|
|
82
94
|
- bin/purobu
|
83
95
|
- lib/purobu.rb
|
84
96
|
- lib/purobu/configuration.rb
|
97
|
+
- lib/purobu/database_connection.rb
|
85
98
|
- lib/purobu/dsl.rb
|
99
|
+
- lib/purobu/helpers.rb
|
86
100
|
- lib/purobu/heroku.rb
|
87
101
|
- lib/purobu/heroku_helpers.rb
|
88
102
|
- lib/purobu/log.rb
|
@@ -91,7 +105,9 @@ files:
|
|
91
105
|
- lib/purobu/test.rb
|
92
106
|
- lib/purobu/version.rb
|
93
107
|
- purobu.gemspec
|
108
|
+
- spec/purobu/database_connection_spec.rb
|
94
109
|
- spec/purobu/dsl_spec.rb
|
110
|
+
- spec/purobu/helpers_spec.rb
|
95
111
|
- spec/purobu/reporter_spec.rb
|
96
112
|
- spec/purobu/runner_spec.rb
|
97
113
|
- spec/purobu/test_spec.rb
|
@@ -120,7 +136,9 @@ signing_key:
|
|
120
136
|
specification_version: 3
|
121
137
|
summary: Black-box integration test framework for components on the Heroku platform.
|
122
138
|
test_files:
|
139
|
+
- spec/purobu/database_connection_spec.rb
|
123
140
|
- spec/purobu/dsl_spec.rb
|
141
|
+
- spec/purobu/helpers_spec.rb
|
124
142
|
- spec/purobu/reporter_spec.rb
|
125
143
|
- spec/purobu/runner_spec.rb
|
126
144
|
- spec/purobu/test_spec.rb
|