gemika 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.travis.yml +30 -22
- data/.yardopts +1 -0
- data/README.md +140 -34
- data/gemfiles/Gemfile.2.3.mysql2 +8 -2
- data/gemfiles/Gemfile.2.3.mysql2.lock +3 -1
- data/gemfiles/Gemfile.3.2.mysql2 +8 -2
- data/gemfiles/Gemfile.3.2.mysql2.lock +6 -1
- data/gemfiles/Gemfile.4.2.mysql2 +7 -0
- data/gemfiles/Gemfile.4.2.mysql2.lock +3 -1
- data/gemfiles/Gemfile.4.2.pg +9 -0
- data/gemfiles/Gemfile.4.2.pg.lock +6 -1
- data/gemfiles/Gemfile.5.0.mysql2 +7 -0
- data/gemfiles/Gemfile.5.0.mysql2.lock +3 -1
- data/gemfiles/Gemfile.5.0.pg +7 -0
- data/gemfiles/Gemfile.5.0.pg.lock +3 -1
- data/lib/gemika/database.rb +41 -4
- data/lib/gemika/env.rb +119 -67
- data/lib/gemika/errors.rb +9 -0
- data/lib/gemika/matrix.rb +44 -11
- data/lib/gemika/rspec.rb +87 -44
- data/lib/gemika/tasks/matrix.rb +17 -23
- data/lib/gemika/tasks/rspec.rb +9 -0
- data/lib/gemika/tasks.rb +1 -1
- data/lib/gemika/version.rb +1 -1
- data/lib/gemika.rb +3 -2
- data/spec/fixtures/gemfiles/Gemfile_with_activesupport_5 +3 -0
- data/spec/fixtures/gemfiles/Gemfile_with_activesupport_5.lock +23 -0
- data/spec/gemika/env_spec.rb +86 -0
- data/spec/gemika/matrix_spec.rb +5 -5
- data/spec/gemika/rspec_spec.rb +44 -0
- data/spec/spec_helper.rb +2 -8
- metadata +30 -46
- data/lib/gemika/tasks/database.rb +0 -1
data/lib/gemika.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'gemika/version'
|
2
|
+
require 'gemika/errors'
|
2
3
|
require 'gemika/env'
|
3
|
-
require 'gemika/database' if
|
4
|
+
require 'gemika/database' if Gemika::Env.gem?('activerecord')
|
4
5
|
require 'gemika/matrix'
|
5
|
-
require 'gemika/rspec' if
|
6
|
+
require 'gemika/rspec' if Gemika::Env.gem?('rspec')
|
6
7
|
|
7
8
|
# don't load tasks by default
|
@@ -0,0 +1,23 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (5.0.0.1)
|
5
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
+
i18n (~> 0.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
tzinfo (~> 1.1)
|
9
|
+
concurrent-ruby (1.0.2)
|
10
|
+
i18n (0.7.0)
|
11
|
+
minitest (5.9.1)
|
12
|
+
thread_safe (0.3.5)
|
13
|
+
tzinfo (1.2.2)
|
14
|
+
thread_safe (~> 0.1)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
ruby
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
activesupport (~> 5.0.0)
|
21
|
+
|
22
|
+
BUNDLED WITH
|
23
|
+
1.12.5
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gemika::Env do
|
4
|
+
|
5
|
+
subject { Gemika::Env }
|
6
|
+
|
7
|
+
describe '.gemfile' do
|
8
|
+
|
9
|
+
it 'returns the path to the current gemfile' do
|
10
|
+
subject.gemfile.should =~ /Gemfile/
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'returns the original gemfile of the process, even within blocks to .with_gemfile' do
|
14
|
+
original_gemfile = subject.gemfile
|
15
|
+
subject.with_gemfile('Foofile') do
|
16
|
+
ENV['BUNDLE_GEMFILE'].should == 'Foofile'
|
17
|
+
subject.gemfile.should == original_gemfile
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '.with_gemfile' do
|
24
|
+
|
25
|
+
it "changes ENV['BUNDLE_GEMFILE'] for the duration of the given block, then sets it back" do
|
26
|
+
original_gemfile = ENV['BUNDLE_GEMFILE']
|
27
|
+
subject.with_gemfile('Foofile') do
|
28
|
+
ENV['BUNDLE_GEMFILE'].should == 'Foofile'
|
29
|
+
end
|
30
|
+
ENV['BUNDLE_GEMFILE'].should == original_gemfile
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '.gem?' do
|
36
|
+
|
37
|
+
it 'returns whether the given gem was activated by the current gemfile' do
|
38
|
+
spec = Gem::Specification.new do |spec|
|
39
|
+
spec.name = 'activated-gem'
|
40
|
+
spec.version = '1.2.3'
|
41
|
+
end
|
42
|
+
Gem.should_receive(:loaded_specs).at_least(:once).and_return({ 'activated-gem' => spec})
|
43
|
+
subject.gem?('activated-gem').should == true
|
44
|
+
subject.gem?('other-gem').should == false
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'allows to pass a version constraint' do
|
48
|
+
spec = Gem::Specification.new do |spec|
|
49
|
+
spec.name = 'activated-gem'
|
50
|
+
spec.version = '1.2.3'
|
51
|
+
end
|
52
|
+
Gem.should_receive(:loaded_specs).at_least(:once).and_return({ 'activated-gem' => spec})
|
53
|
+
subject.gem?('activated-gem', '=1.2.3').should == true
|
54
|
+
subject.gem?('activated-gem', '=1.2.4').should == false
|
55
|
+
subject.gem?('activated-gem', '>= 1').should == true
|
56
|
+
subject.gem?('activated-gem', '< 1').should == false
|
57
|
+
subject.gem?('activated-gem', '~> 1.2.0').should == true
|
58
|
+
subject.gem?('activated-gem', '~> 1.1.0').should == false
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'allows to query a gemfile that is not the current gemfile' do
|
62
|
+
path = 'spec/fixtures/gemfiles/Gemfile_with_activesupport_5'
|
63
|
+
subject.gem?('activesupport', :gemfile => path).should == true
|
64
|
+
subject.gem?('activesupport', '>= 5', :gemfile => path).should == true
|
65
|
+
subject.gem?('activesupport', '~> 5.0.0', :gemfile => path).should == true
|
66
|
+
subject.gem?('activesupport', '< 5', :gemfile => path).should == false
|
67
|
+
subject.gem?('consul', :gemfile => path).should == false
|
68
|
+
subject.gem?('consul', '>= 0', :gemfile => path).should == false
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '.ruby?' do
|
74
|
+
|
75
|
+
it 'returns whether the current Ruby version satisfies the given requirement' do
|
76
|
+
subject.should_receive(:ruby).at_least(:once).and_return('2.1.8')
|
77
|
+
subject.ruby?('=2.1.8').should == true
|
78
|
+
subject.ruby?('=1.9.3').should == false
|
79
|
+
subject.ruby?('>= 2').should == true
|
80
|
+
subject.ruby?('< 2').should == false
|
81
|
+
subject.ruby?('~> 2.1.0').should == true
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
data/spec/gemika/matrix_spec.rb
CHANGED
@@ -65,7 +65,7 @@ describe Gemika::Matrix do
|
|
65
65
|
lambda { io.puts 'Failed output'; false },
|
66
66
|
lambda { io.puts 'Skipped output'; false }
|
67
67
|
]
|
68
|
-
expect { matrix.each { commands.shift.call } }.to raise_error(Gemika::
|
68
|
+
expect { matrix.each { commands.shift.call } }.to raise_error(Gemika::MatrixFailed)
|
69
69
|
expected_output = <<EOF
|
70
70
|
gemfiles/GemfileAlpha
|
71
71
|
|
@@ -90,7 +90,7 @@ EOF
|
|
90
90
|
current_ruby = '2.1.8'
|
91
91
|
row = Gemika::Matrix::Row.new(:ruby => current_ruby, :gemfile => 'gemfiles/Gemfile')
|
92
92
|
matrix = Gemika::Matrix.new(:rows =>[row], :validate => false, :current_ruby => current_ruby, :silent => true)
|
93
|
-
expect { matrix.each { false } }.to raise_error(Gemika::
|
93
|
+
expect { matrix.each { false } }.to raise_error(Gemika::MatrixFailed, /Some gemfiles failed/i)
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'should raise an error if no row if compatible with the current Ruby' do
|
@@ -98,7 +98,7 @@ EOF
|
|
98
98
|
other_ruby = '2.3.1'
|
99
99
|
row = Gemika::Matrix::Row.new(:ruby => other_ruby, :gemfile => 'gemfiles/Gemfile')
|
100
100
|
matrix = Gemika::Matrix.new(:rows =>[row], :validate => false, :current_ruby => current_ruby, :silent => true)
|
101
|
-
expect { matrix.each { false } }.to raise_error(Gemika::
|
101
|
+
expect { matrix.each { false } }.to raise_error(Gemika::UnsupportedRuby, /No gemfiles were compatible/i)
|
102
102
|
end
|
103
103
|
|
104
104
|
end
|
@@ -133,12 +133,12 @@ EOF
|
|
133
133
|
|
134
134
|
it 'raises an error if a Gemfile does not exist' do
|
135
135
|
path = 'spec/fixtures/travis_yml/missing_gemfile.yml'
|
136
|
-
expect { Gemika::Matrix.from_travis_yml(:path => path) }.to raise_error(Gemika::
|
136
|
+
expect { Gemika::Matrix.from_travis_yml(:path => path) }.to raise_error(Gemika::MissingGemfile, /gemfile not found/i)
|
137
137
|
end
|
138
138
|
|
139
139
|
it 'raises an error if a Gemfile does not depend on "gemika"' do
|
140
140
|
path = 'spec/fixtures/travis_yml/gemfile_without_gemika.yml'
|
141
|
-
expect { Gemika::Matrix.from_travis_yml(:path => path) }.to raise_error(Gemika::
|
141
|
+
expect { Gemika::Matrix.from_travis_yml(:path => path) }.to raise_error(Gemika::UnusableGemfile, /missing gemika dependency/i)
|
142
142
|
end
|
143
143
|
|
144
144
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gemika::RSpec do
|
4
|
+
|
5
|
+
# before(:each) { puts "---", "RSpec example", "---" }
|
6
|
+
|
7
|
+
subject { Gemika::RSpec }
|
8
|
+
|
9
|
+
describe '.binary' do
|
10
|
+
|
11
|
+
it 'returns "spec" for RSpec 1' do
|
12
|
+
Gemika::Env.should_receive(:gem?).with('rspec', '< 2', {}).and_return(true)
|
13
|
+
subject.binary.should == 'spec'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'returns "rspec" for RSpec 2+' do
|
17
|
+
Gemika::Env.should_receive(:gem?).with('rspec', '< 2', {}).and_return(false)
|
18
|
+
subject.binary.should == 'rspec'
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '.run_specs' do
|
24
|
+
|
25
|
+
it 'shells out to the binary' do
|
26
|
+
expected_command = %{bundle exec #{subject.binary} --color spec}
|
27
|
+
subject.should_receive(:shell_out).with(expected_command).and_return(true)
|
28
|
+
subject.run_specs
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'allows to pass a :files option' do
|
32
|
+
expected_command = %{bundle exec #{subject.binary} --color spec/foo_spec.rb:23}
|
33
|
+
subject.should_receive(:shell_out).with(expected_command).and_return(true)
|
34
|
+
subject.run_specs(:files => 'spec/foo_spec.rb:23')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'raises an error if the call returns a non-zero error code' do
|
38
|
+
subject.should_receive(:shell_out).with(anything).and_return(false)
|
39
|
+
expect { subject.run_specs }.to raise_error(Gemika::RSpecFailed)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,11 +8,5 @@ ActiveRecord::Base.default_timezone = :local
|
|
8
8
|
Dir["#{File.dirname(__FILE__)}/support/*.rb"].sort.each {|f| require f}
|
9
9
|
Dir["#{File.dirname(__FILE__)}/shared_examples/*.rb"].sort.each {|f| require f}
|
10
10
|
|
11
|
-
Gemika::RSpec.
|
12
|
-
|
13
|
-
if Gemika::Env.rspec_2_plus?
|
14
|
-
RSpec.configure do |config|
|
15
|
-
config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
|
16
|
-
config.mock_with(:rspec) { |c| c.syntax = [:should, :expect] }
|
17
|
-
end
|
18
|
-
end
|
11
|
+
Gemika::RSpec.configure_clean_database_before_example
|
12
|
+
Gemika::RSpec.configure_should_syntax
|
metadata
CHANGED
@@ -1,36 +1,26 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemika
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 0.2.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Henning Koch
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2016-09-27 00:00:00 Z
|
11
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
19
12
|
dependencies: []
|
20
|
-
|
21
13
|
description: Helpers for testing Ruby gems
|
22
14
|
email: henning.koch@makandra.de
|
23
15
|
executables: []
|
24
|
-
|
25
16
|
extensions: []
|
26
|
-
|
27
17
|
extra_rdoc_files: []
|
28
|
-
|
29
|
-
|
30
|
-
- .
|
31
|
-
- .
|
32
|
-
- .
|
33
|
-
- .
|
18
|
+
files:
|
19
|
+
- ".gitignore"
|
20
|
+
- ".rspec"
|
21
|
+
- ".ruby-version"
|
22
|
+
- ".travis.yml"
|
23
|
+
- ".yardopts"
|
34
24
|
- LICENSE
|
35
25
|
- README.md
|
36
26
|
- Rakefile
|
@@ -51,19 +41,24 @@ files:
|
|
51
41
|
- lib/gemika.rb
|
52
42
|
- lib/gemika/database.rb
|
53
43
|
- lib/gemika/env.rb
|
44
|
+
- lib/gemika/errors.rb
|
54
45
|
- lib/gemika/matrix.rb
|
55
46
|
- lib/gemika/rspec.rb
|
56
47
|
- lib/gemika/tasks.rb
|
57
|
-
- lib/gemika/tasks/database.rb
|
58
48
|
- lib/gemika/tasks/matrix.rb
|
49
|
+
- lib/gemika/tasks/rspec.rb
|
59
50
|
- lib/gemika/version.rb
|
51
|
+
- spec/fixtures/gemfiles/Gemfile_with_activesupport_5
|
52
|
+
- spec/fixtures/gemfiles/Gemfile_with_activesupport_5.lock
|
60
53
|
- spec/fixtures/travis_yml/Gemfile_without_gemika
|
61
54
|
- spec/fixtures/travis_yml/excludes.yml
|
62
55
|
- spec/fixtures/travis_yml/gemfile_without_gemika.yml
|
63
56
|
- spec/fixtures/travis_yml/missing_gemfile.yml
|
64
57
|
- spec/fixtures/travis_yml/two_by_two.yml
|
65
58
|
- spec/gemika/database_spec.rb
|
59
|
+
- spec/gemika/env_spec.rb
|
66
60
|
- spec/gemika/matrix_spec.rb
|
61
|
+
- spec/gemika/rspec_spec.rb
|
67
62
|
- spec/spec_helper.rb
|
68
63
|
- spec/support/database.rb
|
69
64
|
- spec/support/database.sample.yml
|
@@ -71,38 +66,27 @@ files:
|
|
71
66
|
- spec/support/database.yml
|
72
67
|
- spec/support/models.rb
|
73
68
|
homepage: https://github.com/makandra/gemika
|
74
|
-
licenses:
|
69
|
+
licenses:
|
75
70
|
- MIT
|
71
|
+
metadata: {}
|
76
72
|
post_install_message:
|
77
73
|
rdoc_options: []
|
78
|
-
|
79
|
-
require_paths:
|
74
|
+
require_paths:
|
80
75
|
- lib
|
81
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
-
|
83
|
-
requirements:
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
84
78
|
- - ">="
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
version: "0"
|
90
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
|
-
requirements:
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
93
83
|
- - ">="
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
|
96
|
-
segments:
|
97
|
-
- 0
|
98
|
-
version: "0"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
99
86
|
requirements: []
|
100
|
-
|
101
87
|
rubyforge_project:
|
102
|
-
rubygems_version:
|
88
|
+
rubygems_version: 2.6.6
|
103
89
|
signing_key:
|
104
|
-
specification_version:
|
90
|
+
specification_version: 4
|
105
91
|
summary: Helpers for testing Ruby gems
|
106
92
|
test_files: []
|
107
|
-
|
108
|
-
has_rdoc:
|
@@ -1 +0,0 @@
|
|
1
|
-
# none yet
|