gemika 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +50 -0
- data/README.md +51 -13
- data/Rakefile +7 -0
- data/doc/minidusen_test.png +0 -0
- data/gemfiles/Gemfile.2.3.mysql2 +11 -0
- data/gemfiles/Gemfile.2.3.mysql2.lock +29 -0
- data/gemfiles/Gemfile.3.2.mysql2 +11 -0
- data/gemfiles/Gemfile.3.2.mysql2.lock +54 -0
- data/gemfiles/Gemfile.4.2.mysql2 +9 -0
- data/gemfiles/Gemfile.4.2.mysql2.lock +58 -0
- data/gemfiles/Gemfile.4.2.pg +9 -0
- data/gemfiles/Gemfile.4.2.pg.lock +58 -0
- data/gemfiles/Gemfile.5.0.mysql2 +9 -0
- data/gemfiles/Gemfile.5.0.mysql2.lock +55 -0
- data/gemfiles/Gemfile.5.0.pg +9 -0
- data/gemfiles/Gemfile.5.0.pg.lock +55 -0
- data/lib/gemika/database.rb +11 -23
- data/lib/gemika/env.rb +115 -0
- data/lib/gemika/matrix.rb +97 -45
- data/lib/gemika/rspec.rb +37 -10
- data/lib/gemika/tasks/matrix.rb +24 -4
- data/lib/gemika/version.rb +1 -1
- data/lib/gemika.rb +2 -1
- data/spec/fixtures/travis_yml/Gemfile_without_gemika +1 -0
- data/spec/fixtures/travis_yml/excludes.yml +12 -0
- data/spec/fixtures/travis_yml/gemfile_without_gemika.yml +5 -0
- data/spec/fixtures/travis_yml/missing_gemfile.yml +5 -0
- data/spec/fixtures/travis_yml/two_by_two.yml +7 -0
- data/spec/gemika/database_spec.rb +15 -0
- data/spec/gemika/matrix_spec.rb +146 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/database.rb +8 -0
- data/spec/support/database.sample.yml +10 -0
- data/spec/support/database.travis.yml +9 -0
- data/spec/support/database.yml +10 -0
- data/spec/support/models.rb +3 -0
- metadata +72 -21
- checksums.yaml +0 -7
- data/lib/gemika/doc/minidusen_test.png +0 -0
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.4
|
data/.travis.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
rvm:
|
4
|
+
- 1.8.7
|
5
|
+
- 2.1.8
|
6
|
+
- 2.2.4
|
7
|
+
- 2.3.1
|
8
|
+
|
9
|
+
gemfile:
|
10
|
+
- gemfiles/Gemfile.2.3.mysql2
|
11
|
+
- gemfiles/Gemfile.3.2.mysql2
|
12
|
+
- gemfiles/Gemfile.4.2.mysql2
|
13
|
+
- gemfiles/Gemfile.4.2.pg
|
14
|
+
- gemfiles/Gemfile.5.0.mysql2
|
15
|
+
- gemfiles/Gemfile.5.0.pg
|
16
|
+
|
17
|
+
before_script:
|
18
|
+
- psql -c 'create database gemika_test;' -U postgres
|
19
|
+
- mysql -e 'create database IF NOT EXISTS gemika_test;'
|
20
|
+
|
21
|
+
script: bundle exec rake gemika:spec
|
22
|
+
|
23
|
+
sudo: false
|
24
|
+
|
25
|
+
cache: bundler
|
26
|
+
|
27
|
+
notifications:
|
28
|
+
email:
|
29
|
+
- fail@makandra.de
|
30
|
+
|
31
|
+
matrix:
|
32
|
+
exclude:
|
33
|
+
- rvm: 1.8.7
|
34
|
+
gemfile: gemfiles/Gemfile.4.2.mysql2
|
35
|
+
- rvm: 1.8.7
|
36
|
+
gemfile: gemfiles/Gemfile.4.2.pg
|
37
|
+
- rvm: 1.8.7
|
38
|
+
gemfile: gemfiles/Gemfile.5.0.mysql2
|
39
|
+
- rvm: 1.8.7
|
40
|
+
gemfile: gemfiles/Gemfile.5.0.pg
|
41
|
+
- rvm: 2.1.8
|
42
|
+
gemfile: gemfiles/Gemfile.2.3.mysql2
|
43
|
+
- rvm: 2.1.8
|
44
|
+
gemfile: gemfiles/Gemfile.5.0.mysql2
|
45
|
+
- rvm: 2.1.8
|
46
|
+
gemfile: gemfiles/Gemfile.5.0.pg
|
47
|
+
- rvm: 2.2.4
|
48
|
+
gemfile: gemfiles/Gemfile.2.3.mysql2
|
49
|
+
- rvm: 2.3.1
|
50
|
+
gemfile: gemfiles/Gemfile.2.3.mysql2
|
data/README.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
# Gemika
|
1
|
+
# Gemika [![Build Status](https://travis-ci.org/makandra/gemika.svg?branch=master)](https://travis-ci.org/makandra/gemika)
|
2
2
|
|
3
3
|
## Test a Ruby gem against multiple versions of everything
|
4
4
|
|
5
5
|
Gemika helps you test your gem against multiple versions of Ruby, gem dependencies and database types.
|
6
6
|
|
7
|
-
|
7
|
+
![Matrix task output](https://raw.githubusercontent.com/makandra/gemika/master/doc/minidusen_test.png)
|
8
|
+
|
9
|
+
## Features
|
10
|
+
|
11
|
+
Here's what Gemika can give your test's development setup (all features are opt-in):
|
8
12
|
|
9
13
|
- Test one codebase against multiple sets of gem dependency sets (e.g. Rails 4.2, Rails 5.0).
|
10
14
|
- Test one codebase against multiple Ruby versions (e.g. Ruby 2.1.8, Ruby 2.3.1).
|
@@ -19,10 +23,19 @@ Here's what Gemika can give your test's development setup (all steps are opt-in)
|
|
19
23
|
- Configure RSpec to wrap each example in a transaction that is rolled back when the example ends. This way each example starts with a blank database.
|
20
24
|
|
21
25
|
|
22
|
-
##
|
26
|
+
## Compatibility
|
27
|
+
|
28
|
+
Gemika currently supports the following dependency versions:
|
23
29
|
|
24
|
-
-
|
25
|
-
-
|
30
|
+
- Ruby: 1.8.7, 2.1, 2.2, 2.3
|
31
|
+
- RSpec: Versions 1, 3
|
32
|
+
- ActiveRecord: Versions 2.3, 3.2, 4.2, 5.0
|
33
|
+
- Databases: PostgreSQL (with `pg` gem), MySQL or MariaDB (with `mysql2` gem)
|
34
|
+
|
35
|
+
Gemika also makes some assumption about your Gem:
|
36
|
+
|
37
|
+
- You're testing with [RSpec](http://rspec.info/).
|
38
|
+
- If you use any database-related features, you need `activerecord` as a development dependency
|
26
39
|
|
27
40
|
|
28
41
|
## Example directory structure
|
@@ -44,13 +57,14 @@ Gemfile.lock -> gemfiles/Gemfile.set2.lock # Symlink to default Gemfile.lock fo
|
|
44
57
|
my_gem.gemspec # Specification for your gem
|
45
58
|
Rakefile # Should require 'gemika/tasks'
|
46
59
|
README.md # README for your gem
|
47
|
-
lib/my_gem.rb #
|
60
|
+
lib/my_gem.rb # Main file to require for your gem
|
48
61
|
lib/my_gem/my_class.rb # Class delivered by your gem
|
49
62
|
lib/my_gem/version.rb # Version definition for your gem
|
50
63
|
spec/spec_helper.rb # Requires 'gemika' and all files in support folder
|
51
|
-
spec/support/database.rb #
|
52
|
-
spec/support/database.yml #
|
53
|
-
spec/support/database.
|
64
|
+
spec/support/database.rb # Database schema for test database
|
65
|
+
spec/support/database.yml # Database credentials for local development (not checked in)
|
66
|
+
spec/support/database.sample.yml # Sample database credentials for new developers
|
67
|
+
spec/support/database.travis.yml # Database credentials for Travis CI
|
54
68
|
spec/my_gem/my_class_spec.rb # Tests for your gem
|
55
69
|
```
|
56
70
|
|
@@ -64,10 +78,10 @@ For a live example of this setup, check the [makandra/minidusen](https://github.
|
|
64
78
|
|
65
79
|
Gemika expects a standard gem directory that looks roughly like this:
|
66
80
|
|
67
|
-
```
|
68
|
-
my_gem.gemspec
|
69
|
-
Rakefile
|
70
|
-
lib/my_gem.rb
|
81
|
+
```shell
|
82
|
+
my_gem.gemspec # Specification for your gem
|
83
|
+
Rakefile # Rake tasks for your gem
|
84
|
+
lib/my_gem.rb # Main file to require for your gem
|
71
85
|
```
|
72
86
|
|
73
87
|
If you don't have a directory yet, you can [ask Bundler to create it for you](http://bundler.io/rubygems.html):
|
@@ -244,6 +258,8 @@ ln -s gemfiles/Gemfile.4.2.mysql2 Gemfile
|
|
244
258
|
ln -s gemfiles/Gemfile.4.2.mysql2.lock Gemfile.lock
|
245
259
|
```
|
246
260
|
|
261
|
+
Note that since you now have a Gemfile in your project root, you will need to call `bundle exec rake` instead of `rake` from this point on.
|
262
|
+
|
247
263
|
Commit both `.ruby-version` and symlinks to your repo.
|
248
264
|
|
249
265
|
We recommend to setup Travis CI (see below) to check the entire test matrix after each push, even if a developer only tested with the defaults.
|
@@ -492,6 +508,28 @@ We recommend to test large changes against multiple versions of Ruby and multipl
|
|
492
508
|
Note that we have configured Travis CI to automatically run tests in all supported Ruby versions and dependency sets after each push. We will only merge pull requests after a green Travis build.
|
493
509
|
```
|
494
510
|
|
511
|
+
|
512
|
+
Development
|
513
|
+
-----------
|
514
|
+
|
515
|
+
Here are some hints when you try to make changes to Gemika:
|
516
|
+
|
517
|
+
There are tests in `spec`. We only accept PRs with tests. To run tests:
|
518
|
+
|
519
|
+
- Install Ruby 2.2.4
|
520
|
+
- Create a local test database `gemika_test` in both MySQL and PostgreSQL
|
521
|
+
- Copy `spec/support/database.sample.yml` to `spec/support/database.yml` and enter your local credentials for the test databases
|
522
|
+
- Install development dependencies using `bundle install`
|
523
|
+
- Run tests using `bundle exec rspec`
|
524
|
+
|
525
|
+
We recommend to test large changes against multiple versions of Ruby and multiple dependency sets. Supported combinations are configured in `.travis.yml`. We provide some rake tasks to help with this:
|
526
|
+
|
527
|
+
- Install development dependencies using `bundle matrix:install`
|
528
|
+
- Run tests using `bundle matrix:spec`
|
529
|
+
|
530
|
+
Note that we have configured Travis CI to automatically run tests in all supported Ruby versions and dependency sets after each push. We will only merge pull requests after a green Travis build.
|
531
|
+
|
532
|
+
|
495
533
|
Credits
|
496
534
|
-------
|
497
535
|
|
data/Rakefile
CHANGED
Binary file
|
@@ -0,0 +1,29 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
gemika (0.1.4)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activerecord (2.3.18)
|
10
|
+
activesupport (= 2.3.18)
|
11
|
+
activesupport (2.3.18)
|
12
|
+
i18n (0.6.11)
|
13
|
+
mysql2 (0.2.20)
|
14
|
+
rake (10.0.4)
|
15
|
+
rspec (1.3.2)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
activerecord (= 2.3.18)
|
22
|
+
gemika!
|
23
|
+
i18n (= 0.6.11)
|
24
|
+
mysql2 (= 0.2.20)
|
25
|
+
rake (= 10.0.4)
|
26
|
+
rspec (~> 1.3.0)
|
27
|
+
|
28
|
+
BUNDLED WITH
|
29
|
+
1.12.5
|
@@ -0,0 +1,54 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
gemika (0.1.4)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (3.2.22)
|
10
|
+
activesupport (= 3.2.22)
|
11
|
+
builder (~> 3.0.0)
|
12
|
+
activerecord (3.2.22)
|
13
|
+
activemodel (= 3.2.22)
|
14
|
+
activesupport (= 3.2.22)
|
15
|
+
arel (~> 3.0.2)
|
16
|
+
tzinfo (~> 0.3.29)
|
17
|
+
activesupport (3.2.22)
|
18
|
+
i18n (~> 0.6, >= 0.6.4)
|
19
|
+
multi_json (~> 1.0)
|
20
|
+
arel (3.0.3)
|
21
|
+
builder (3.0.4)
|
22
|
+
diff-lcs (1.2.5)
|
23
|
+
i18n (0.6.11)
|
24
|
+
multi_json (1.12.1)
|
25
|
+
mysql2 (0.3.17)
|
26
|
+
rake (10.0.4)
|
27
|
+
rspec (3.5.0)
|
28
|
+
rspec-core (~> 3.5.0)
|
29
|
+
rspec-expectations (~> 3.5.0)
|
30
|
+
rspec-mocks (~> 3.5.0)
|
31
|
+
rspec-core (3.5.3)
|
32
|
+
rspec-support (~> 3.5.0)
|
33
|
+
rspec-expectations (3.5.0)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.5.0)
|
36
|
+
rspec-mocks (3.5.0)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.5.0)
|
39
|
+
rspec-support (3.5.0)
|
40
|
+
tzinfo (0.3.51)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
activerecord (= 3.2.22)
|
47
|
+
gemika!
|
48
|
+
i18n (= 0.6.11)
|
49
|
+
mysql2 (= 0.3.17)
|
50
|
+
rake (= 10.0.4)
|
51
|
+
rspec (~> 3.4)
|
52
|
+
|
53
|
+
BUNDLED WITH
|
54
|
+
1.12.5
|
@@ -0,0 +1,58 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
gemika (0.1.4)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (4.2.7.1)
|
10
|
+
activesupport (= 4.2.7.1)
|
11
|
+
builder (~> 3.1)
|
12
|
+
activerecord (4.2.7.1)
|
13
|
+
activemodel (= 4.2.7.1)
|
14
|
+
activesupport (= 4.2.7.1)
|
15
|
+
arel (~> 6.0)
|
16
|
+
activesupport (4.2.7.1)
|
17
|
+
i18n (~> 0.7)
|
18
|
+
json (~> 1.7, >= 1.7.7)
|
19
|
+
minitest (~> 5.1)
|
20
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
21
|
+
tzinfo (~> 1.1)
|
22
|
+
arel (6.0.3)
|
23
|
+
builder (3.2.2)
|
24
|
+
diff-lcs (1.2.5)
|
25
|
+
i18n (0.7.0)
|
26
|
+
json (1.8.3)
|
27
|
+
minitest (5.9.0)
|
28
|
+
mysql2 (0.3.21)
|
29
|
+
rake (11.3.0)
|
30
|
+
rspec (3.5.0)
|
31
|
+
rspec-core (~> 3.5.0)
|
32
|
+
rspec-expectations (~> 3.5.0)
|
33
|
+
rspec-mocks (~> 3.5.0)
|
34
|
+
rspec-core (3.5.3)
|
35
|
+
rspec-support (~> 3.5.0)
|
36
|
+
rspec-expectations (3.5.0)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.5.0)
|
39
|
+
rspec-mocks (3.5.0)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.5.0)
|
42
|
+
rspec-support (3.5.0)
|
43
|
+
thread_safe (0.3.5)
|
44
|
+
tzinfo (1.2.2)
|
45
|
+
thread_safe (~> 0.1)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
activerecord (~> 4.2.1)
|
52
|
+
gemika!
|
53
|
+
mysql2 (~> 0.3.17)
|
54
|
+
rake
|
55
|
+
rspec (~> 3.4)
|
56
|
+
|
57
|
+
BUNDLED WITH
|
58
|
+
1.12.5
|
@@ -0,0 +1,58 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
gemika (0.1.4)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (4.2.7.1)
|
10
|
+
activesupport (= 4.2.7.1)
|
11
|
+
builder (~> 3.1)
|
12
|
+
activerecord (4.2.7.1)
|
13
|
+
activemodel (= 4.2.7.1)
|
14
|
+
activesupport (= 4.2.7.1)
|
15
|
+
arel (~> 6.0)
|
16
|
+
activesupport (4.2.7.1)
|
17
|
+
i18n (~> 0.7)
|
18
|
+
json (~> 1.7, >= 1.7.7)
|
19
|
+
minitest (~> 5.1)
|
20
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
21
|
+
tzinfo (~> 1.1)
|
22
|
+
arel (6.0.3)
|
23
|
+
builder (3.2.2)
|
24
|
+
diff-lcs (1.2.5)
|
25
|
+
i18n (0.7.0)
|
26
|
+
json (1.8.3)
|
27
|
+
minitest (5.9.0)
|
28
|
+
pg (0.19.0)
|
29
|
+
rake (11.3.0)
|
30
|
+
rspec (3.5.0)
|
31
|
+
rspec-core (~> 3.5.0)
|
32
|
+
rspec-expectations (~> 3.5.0)
|
33
|
+
rspec-mocks (~> 3.5.0)
|
34
|
+
rspec-core (3.5.3)
|
35
|
+
rspec-support (~> 3.5.0)
|
36
|
+
rspec-expectations (3.5.0)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.5.0)
|
39
|
+
rspec-mocks (3.5.0)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.5.0)
|
42
|
+
rspec-support (3.5.0)
|
43
|
+
thread_safe (0.3.5)
|
44
|
+
tzinfo (1.2.2)
|
45
|
+
thread_safe (~> 0.1)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
activerecord (~> 4.2.1)
|
52
|
+
gemika!
|
53
|
+
pg
|
54
|
+
rake
|
55
|
+
rspec (~> 3.4)
|
56
|
+
|
57
|
+
BUNDLED WITH
|
58
|
+
1.12.5
|
@@ -0,0 +1,55 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
gemika (0.1.4)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (5.0.0.1)
|
10
|
+
activesupport (= 5.0.0.1)
|
11
|
+
activerecord (5.0.0.1)
|
12
|
+
activemodel (= 5.0.0.1)
|
13
|
+
activesupport (= 5.0.0.1)
|
14
|
+
arel (~> 7.0)
|
15
|
+
activesupport (5.0.0.1)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (~> 0.7)
|
18
|
+
minitest (~> 5.1)
|
19
|
+
tzinfo (~> 1.1)
|
20
|
+
arel (7.1.2)
|
21
|
+
concurrent-ruby (1.0.2)
|
22
|
+
diff-lcs (1.2.5)
|
23
|
+
i18n (0.7.0)
|
24
|
+
minitest (5.9.0)
|
25
|
+
mysql2 (0.4.4)
|
26
|
+
rake (11.3.0)
|
27
|
+
rspec (3.5.0)
|
28
|
+
rspec-core (~> 3.5.0)
|
29
|
+
rspec-expectations (~> 3.5.0)
|
30
|
+
rspec-mocks (~> 3.5.0)
|
31
|
+
rspec-core (3.5.3)
|
32
|
+
rspec-support (~> 3.5.0)
|
33
|
+
rspec-expectations (3.5.0)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.5.0)
|
36
|
+
rspec-mocks (3.5.0)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.5.0)
|
39
|
+
rspec-support (3.5.0)
|
40
|
+
thread_safe (0.3.5)
|
41
|
+
tzinfo (1.2.2)
|
42
|
+
thread_safe (~> 0.1)
|
43
|
+
|
44
|
+
PLATFORMS
|
45
|
+
ruby
|
46
|
+
|
47
|
+
DEPENDENCIES
|
48
|
+
activerecord (~> 5.0.0)
|
49
|
+
gemika!
|
50
|
+
mysql2 (~> 0.4.4)
|
51
|
+
rake
|
52
|
+
rspec (~> 3.5)
|
53
|
+
|
54
|
+
BUNDLED WITH
|
55
|
+
1.12.5
|
@@ -0,0 +1,55 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
gemika (0.1.4)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (5.0.0.1)
|
10
|
+
activesupport (= 5.0.0.1)
|
11
|
+
activerecord (5.0.0.1)
|
12
|
+
activemodel (= 5.0.0.1)
|
13
|
+
activesupport (= 5.0.0.1)
|
14
|
+
arel (~> 7.0)
|
15
|
+
activesupport (5.0.0.1)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (~> 0.7)
|
18
|
+
minitest (~> 5.1)
|
19
|
+
tzinfo (~> 1.1)
|
20
|
+
arel (7.1.2)
|
21
|
+
concurrent-ruby (1.0.2)
|
22
|
+
diff-lcs (1.2.5)
|
23
|
+
i18n (0.7.0)
|
24
|
+
minitest (5.9.0)
|
25
|
+
pg (0.18.4)
|
26
|
+
rake (11.3.0)
|
27
|
+
rspec (3.5.0)
|
28
|
+
rspec-core (~> 3.5.0)
|
29
|
+
rspec-expectations (~> 3.5.0)
|
30
|
+
rspec-mocks (~> 3.5.0)
|
31
|
+
rspec-core (3.5.3)
|
32
|
+
rspec-support (~> 3.5.0)
|
33
|
+
rspec-expectations (3.5.0)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.5.0)
|
36
|
+
rspec-mocks (3.5.0)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.5.0)
|
39
|
+
rspec-support (3.5.0)
|
40
|
+
thread_safe (0.3.5)
|
41
|
+
tzinfo (1.2.2)
|
42
|
+
thread_safe (~> 0.1)
|
43
|
+
|
44
|
+
PLATFORMS
|
45
|
+
ruby
|
46
|
+
|
47
|
+
DEPENDENCIES
|
48
|
+
activerecord (~> 5.0.0)
|
49
|
+
gemika!
|
50
|
+
pg (~> 0.18.4)
|
51
|
+
rake
|
52
|
+
rspec (~> 3.5)
|
53
|
+
|
54
|
+
BUNDLED WITH
|
55
|
+
1.12.5
|
data/lib/gemika/database.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'gemika/env'
|
2
3
|
|
3
4
|
module Gemika
|
4
5
|
class Database
|
5
6
|
|
7
|
+
class Error < StandardError; end
|
8
|
+
class UnknownAdapter < Error; end
|
9
|
+
|
6
10
|
def initialize(options = {})
|
7
11
|
yaml_config_folder = options.fetch(:config_folder, 'spec/support')
|
8
|
-
yaml_config_filename = travis? ? 'database.travis.yml' : 'database.yml'
|
12
|
+
yaml_config_filename = Env.travis? ? 'database.travis.yml' : 'database.yml'
|
9
13
|
yaml_config_path = File.join(yaml_config_folder, yaml_config_filename)
|
10
14
|
if File.exists?(yaml_config_path)
|
11
15
|
@yaml_config = YAML.load_file(yaml_config_path)
|
@@ -46,24 +50,24 @@ module Gemika
|
|
46
50
|
def adapter_config
|
47
51
|
default_config = {}
|
48
52
|
default_config['database'] = guess_database_name
|
49
|
-
if pg?
|
53
|
+
if Env.pg?
|
50
54
|
default_config['adapter'] = 'postgresql'
|
51
|
-
default_config['username'] = 'postgres' if travis?
|
55
|
+
default_config['username'] = 'postgres' if Env.travis?
|
52
56
|
default_config['password'] = ''
|
53
57
|
user_config = @yaml_config['postgresql'] || @yaml_config['postgres'] || @yaml_config['pg'] || {}
|
54
|
-
elsif mysql2?
|
58
|
+
elsif Env.mysql2?
|
55
59
|
default_config['adapter'] = 'mysql2'
|
56
|
-
default_config['username'] = 'travis' if travis?
|
60
|
+
default_config['username'] = 'travis' if Env.travis?
|
57
61
|
default_config['encoding'] = 'utf8'
|
58
62
|
user_config = (@yaml_config['mysql'] || @yaml_config['mysql2']) || {}
|
59
63
|
else
|
60
|
-
raise "Unknown database type"
|
64
|
+
raise UnknownAdapter, "Unknown database type. Either 'pg' or 'mysql2' gem should be in your current bundle."
|
61
65
|
end
|
62
66
|
default_config.merge(user_config)
|
63
67
|
end
|
64
68
|
|
65
69
|
def guess_database_name
|
66
|
-
project_name = File.basename(
|
70
|
+
project_name = File.basename(Dir.pwd)
|
67
71
|
"#{project_name}_test"
|
68
72
|
end
|
69
73
|
|
@@ -71,21 +75,5 @@ module Gemika
|
|
71
75
|
ActiveRecord::Base.connection
|
72
76
|
end
|
73
77
|
|
74
|
-
def pg?
|
75
|
-
gem_loaded?('pg')
|
76
|
-
end
|
77
|
-
|
78
|
-
def mysql2?
|
79
|
-
gem_loaded?('mysql2')
|
80
|
-
end
|
81
|
-
|
82
|
-
def gem_loaded?(name)
|
83
|
-
Gem.loaded_specs.has_key?(name)
|
84
|
-
end
|
85
|
-
|
86
|
-
def travis?
|
87
|
-
!!ENV['TRAVIS']
|
88
|
-
end
|
89
|
-
|
90
78
|
end
|
91
79
|
end
|