appraisal 2.4.1 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -33
- data/lib/appraisal/appraisal.rb +27 -3
- data/lib/appraisal/appraisal_file.rb +5 -0
- data/lib/appraisal/bundler_dsl.rb +9 -2
- data/lib/appraisal/cli.rb +0 -8
- data/lib/appraisal/command.rb +18 -28
- data/lib/appraisal/conditional.rb +20 -0
- data/lib/appraisal/customize.rb +16 -0
- data/lib/appraisal/gemfile.rb +5 -6
- data/lib/appraisal/version.rb +1 -1
- data/spec/acceptance/appraisals_file_bundler_dsl_compatibility_spec.rb +14 -1
- data/spec/acceptance/bundle_without_spec.rb +3 -1
- data/spec/acceptance/cli/install_spec.rb +20 -0
- data/spec/acceptance/gemfile_dsl_compatibility_spec.rb +6 -0
- data/spec/acceptance/gemspec_spec.rb +4 -0
- data/spec/appraisal/appraisal_spec.rb +57 -0
- data/spec/appraisal/customize_spec.rb +18 -0
- data/spec/appraisal/gemfile_spec.rb +9 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/acceptance_test_helpers.rb +2 -1
- metadata +7 -7
- data/.travis.yml +0 -18
- data/lib/appraisal/travis_ci_helper.rb +0 -69
- data/spec/acceptance/travis_ci_integration_spec.rb +0 -94
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3574be66377d3aae65b37b349e4f345a2c3902e4e5ec6030401b6b1b30a2992f
|
4
|
+
data.tar.gz: 745cb04bc9266861ff9097ce5ff1c1bc84a5a0fd7b7877e66aaa568ca84aa80e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f7d36071e02f1a31ebea13cf350733708ab799507dc315c97667d50aec24d7a4f51d0e13a88dc4225c65d13599020ff0bc7d5ed62bf64d1ceca24f0b0c1c081
|
7
|
+
data.tar.gz: 31d3c863906955c139632f6ddd957a6ba73d95012b1fb09b5ffa64112f1b2dc3606b9e5d337d3ef6019e2eec27fd8f745a7bd79eadacd66dfe2f16376000e5a7
|
data/README.md
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
Appraisal
|
2
2
|
=========
|
3
3
|
|
4
|
-
[![Build Status][Build Status Image]][Build Status]
|
5
|
-
|
6
4
|
Find out what your Ruby gems are worth.
|
7
5
|
|
8
|
-
[Build Status Image]: https://secure.travis-ci.org/thoughtbot/appraisal.svg?branch=master
|
9
|
-
[Build Status]: http://travis-ci.org/thoughtbot/appraisal
|
10
|
-
|
11
6
|
Synopsis
|
12
7
|
--------
|
13
8
|
|
@@ -89,7 +84,7 @@ your real default task, which usually is your `test` task.)
|
|
89
84
|
|
90
85
|
Note that this may conflict with your CI setup if you decide to split the test
|
91
86
|
into multiple processes by Appraisal and you are using `rake` to run tests by
|
92
|
-
default.
|
87
|
+
default.
|
93
88
|
|
94
89
|
### Commands
|
95
90
|
|
@@ -155,41 +150,53 @@ group :test do
|
|
155
150
|
end
|
156
151
|
```
|
157
152
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
When using Appraisal, we recommend you check in the Gemfiles that Appraisal
|
162
|
-
generates within the gemfiles directory, but exclude the lockfiles there
|
163
|
-
(`*.gemfile.lock`.) The Gemfiles are useful when running your tests against a
|
164
|
-
continuous integration server such as [Travis CI][Travis CI].
|
153
|
+
Customization
|
154
|
+
-------------
|
165
155
|
|
166
|
-
|
156
|
+
It is possible to customize the generated Gemfiles by adding a `customize_gemfiles` block to
|
157
|
+
your `Appraisals` file. The block must contain a hash of key/value pairs. Currently supported
|
158
|
+
customizations include:
|
159
|
+
- heading: a string that by default adds "# This file was generated by Appraisal" to the top of each Gemfile, (the string will be commented for you)
|
160
|
+
- single_quotes: a boolean that controls if strings are single quoted in each Gemfile, defaults to false
|
167
161
|
|
168
|
-
|
169
|
-
---------------------
|
162
|
+
### Example Usage
|
170
163
|
|
171
|
-
|
172
|
-
|
173
|
-
|
164
|
+
**Appraisals**
|
165
|
+
```ruby
|
166
|
+
customize_gemfiles do
|
167
|
+
{
|
168
|
+
single_quotes: true,
|
169
|
+
heading: <<~HEADING
|
170
|
+
frozen_string_literal: true
|
171
|
+
|
172
|
+
File has been generated by Appraisal, do NOT modify it directly!
|
173
|
+
See the conventions at https://example.com/
|
174
|
+
HEADING
|
175
|
+
}
|
176
|
+
end
|
174
177
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
- gemfiles/3.2.gemfile
|
178
|
+
appraise "rails-3" do
|
179
|
+
gem "rails", "3.2.14"
|
180
|
+
end
|
181
|
+
```
|
180
182
|
|
181
|
-
|
182
|
-
|
183
|
+
Using the `Appraisals` file defined above, this is what the resulting `Gemfile` will look like:
|
184
|
+
```ruby
|
185
|
+
# frozen_string_literal: true
|
183
186
|
|
184
|
-
|
187
|
+
# File has been generated by Appraisal, do NOT modify it directly!
|
188
|
+
# See the conventions at https://example.com/
|
185
189
|
|
186
|
-
|
187
|
-
|
190
|
+
gem 'rails', '3.2.14'
|
191
|
+
```
|
188
192
|
|
189
|
-
|
190
|
-
|
193
|
+
Version Control
|
194
|
+
---------------
|
191
195
|
|
192
|
-
|
196
|
+
When using Appraisal, we recommend you check in the Gemfiles that Appraisal
|
197
|
+
generates within the gemfiles directory, but exclude the lockfiles there
|
198
|
+
(`*.gemfile.lock`.) The Gemfiles are useful when running your tests against a
|
199
|
+
continuous integration server.
|
193
200
|
|
194
201
|
Circle CI Integration
|
195
202
|
---------------------
|
@@ -217,7 +224,7 @@ command in the `override` section and use your favourite one.
|
|
217
224
|
Credits
|
218
225
|
-------
|
219
226
|
|
220
|
-

|
221
228
|
|
222
229
|
Appraisal is maintained and funded by [thoughtbot, inc][thoughtbot]
|
223
230
|
|
data/lib/appraisal/appraisal.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'appraisal/gemfile'
|
2
2
|
require 'appraisal/command'
|
3
|
+
require "appraisal/customize"
|
3
4
|
require 'appraisal/utils'
|
4
5
|
require 'fileutils'
|
5
6
|
require 'pathname'
|
@@ -44,6 +45,10 @@ module Appraisal
|
|
44
45
|
gemfile.group(*args, &block)
|
45
46
|
end
|
46
47
|
|
48
|
+
def install_if(*args, &block)
|
49
|
+
gemfile.install_if(*args, &block)
|
50
|
+
end
|
51
|
+
|
47
52
|
def platforms(*args, &block)
|
48
53
|
gemfile.platforms(*args, &block)
|
49
54
|
end
|
@@ -58,8 +63,8 @@ module Appraisal
|
|
58
63
|
|
59
64
|
def write_gemfile
|
60
65
|
File.open(gemfile_path, "w") do |file|
|
61
|
-
signature = "
|
62
|
-
file.puts([signature,
|
66
|
+
signature = Customize.heading || "This file was generated by Appraisal"
|
67
|
+
file.puts([comment_lines(signature), quoted_gemfile].join("\n\n"))
|
63
68
|
end
|
64
69
|
end
|
65
70
|
|
@@ -102,7 +107,10 @@ module Appraisal
|
|
102
107
|
lockfile_content = File.read(lockfile_path)
|
103
108
|
|
104
109
|
File.open(lockfile_path, 'w') do |file|
|
105
|
-
file.write lockfile_content.gsub(
|
110
|
+
file.write lockfile_content.gsub(
|
111
|
+
/ #{current_directory}/,
|
112
|
+
" #{relative_path}",
|
113
|
+
)
|
106
114
|
end
|
107
115
|
end
|
108
116
|
|
@@ -167,5 +175,21 @@ module Appraisal
|
|
167
175
|
|
168
176
|
options_strings.join(" ") if options_strings != []
|
169
177
|
end
|
178
|
+
|
179
|
+
def comment_lines(heading)
|
180
|
+
heading.lines.map do |line|
|
181
|
+
if line.lstrip.empty?
|
182
|
+
line
|
183
|
+
else
|
184
|
+
"# #{line}"
|
185
|
+
end
|
186
|
+
end.join
|
187
|
+
end
|
188
|
+
|
189
|
+
def quoted_gemfile
|
190
|
+
return gemfile.to_s unless Customize.single_quotes
|
191
|
+
|
192
|
+
gemfile.to_s.tr('"', "'")
|
193
|
+
end
|
170
194
|
end
|
171
195
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'appraisal/appraisal'
|
2
|
+
require "appraisal/customize"
|
2
3
|
require 'appraisal/errors'
|
3
4
|
require 'appraisal/gemfile'
|
4
5
|
|
@@ -33,6 +34,10 @@ module Appraisal
|
|
33
34
|
@appraisals << appraisal
|
34
35
|
end
|
35
36
|
|
37
|
+
def customize_gemfiles(&_block)
|
38
|
+
Customize.new(yield)
|
39
|
+
end
|
40
|
+
|
36
41
|
private
|
37
42
|
|
38
43
|
def run(definitions)
|
@@ -5,7 +5,7 @@ module Appraisal
|
|
5
5
|
attr_reader :dependencies
|
6
6
|
|
7
7
|
PARTS = %w(source ruby_version gits paths dependencies groups
|
8
|
-
|
8
|
+
platforms source_blocks install_if gemspec)
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@sources = []
|
@@ -18,6 +18,7 @@ module Appraisal
|
|
18
18
|
@paths = Hash.new
|
19
19
|
@source_blocks = Hash.new
|
20
20
|
@git_sources = {}
|
21
|
+
@install_if = {}
|
21
22
|
end
|
22
23
|
|
23
24
|
def run(&block)
|
@@ -38,6 +39,12 @@ module Appraisal
|
|
38
39
|
@groups[names].run(&block)
|
39
40
|
end
|
40
41
|
|
42
|
+
def install_if(condition, &block)
|
43
|
+
@install_if[condition] ||=
|
44
|
+
Conditional.new(condition).tap { |g| g.git_sources = @git_sources.dup }
|
45
|
+
@install_if[condition].run(&block)
|
46
|
+
end
|
47
|
+
|
41
48
|
def platforms(*names, &block)
|
42
49
|
@platforms[names] ||=
|
43
50
|
Platform.new(names).tap { |g| g.git_sources = @git_sources.dup }
|
@@ -124,7 +131,7 @@ module Appraisal
|
|
124
131
|
@dependencies.for_dup
|
125
132
|
end
|
126
133
|
|
127
|
-
[
|
134
|
+
%i[gits paths platforms groups source_blocks install_if].
|
128
135
|
each do |method_name|
|
129
136
|
class_eval <<-METHODS, __FILE__, __LINE__
|
130
137
|
private
|
data/lib/appraisal/cli.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'fileutils'
|
3
|
-
require "appraisal/travis_ci_helper"
|
4
3
|
|
5
4
|
module Appraisal
|
6
5
|
class CLI < Thor
|
@@ -63,17 +62,10 @@ module Appraisal
|
|
63
62
|
end
|
64
63
|
|
65
64
|
desc 'generate', 'Generate a gemfile for each appraisal'
|
66
|
-
method_option "travis", :type => :boolean, :default => false
|
67
65
|
def generate
|
68
66
|
AppraisalFile.each do |appraisal|
|
69
67
|
appraisal.write_gemfile
|
70
68
|
end
|
71
|
-
|
72
|
-
if options[:travis]
|
73
|
-
TravisCIHelper.display_instruction
|
74
|
-
else
|
75
|
-
TravisCIHelper.validate_configuration_file
|
76
|
-
end
|
77
69
|
end
|
78
70
|
|
79
71
|
desc 'clean', 'Remove all generated gemfiles and lockfiles from gemfiles folder'
|
data/lib/appraisal/command.rb
CHANGED
@@ -3,23 +3,24 @@ require "shellwords"
|
|
3
3
|
module Appraisal
|
4
4
|
# Executes commands with a clean environment
|
5
5
|
class Command
|
6
|
-
|
7
|
-
|
8
|
-
attr_reader :command, :env, :gemfile, :original_env
|
6
|
+
attr_reader :command, :env, :gemfile
|
9
7
|
|
10
8
|
def initialize(command, options = {})
|
11
9
|
@gemfile = options[:gemfile]
|
12
10
|
@env = options.fetch(:env, {})
|
13
11
|
@command = command_starting_with_bundle(command)
|
14
|
-
@original_env = {}
|
15
12
|
end
|
16
13
|
|
17
14
|
def run
|
18
|
-
|
19
|
-
|
15
|
+
run_env = test_environment.merge(env)
|
16
|
+
|
17
|
+
Bundler.with_original_env do
|
18
|
+
ensure_bundler_is_available
|
19
|
+
announce
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
ENV["BUNDLE_GEMFILE"] = gemfile
|
22
|
+
ENV["APPRAISAL_INITIALIZED"] = "1"
|
23
|
+
run_env.each_pair do |key, value|
|
23
24
|
ENV[key] = value
|
24
25
|
end
|
25
26
|
|
@@ -31,15 +32,6 @@ module Appraisal
|
|
31
32
|
|
32
33
|
private
|
33
34
|
|
34
|
-
def with_clean_env
|
35
|
-
unset_bundler_env_vars
|
36
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
37
|
-
ENV['APPRAISAL_INITIALIZED'] = '1'
|
38
|
-
yield
|
39
|
-
ensure
|
40
|
-
restore_env
|
41
|
-
end
|
42
|
-
|
43
35
|
def ensure_bundler_is_available
|
44
36
|
version = Utils.bundler_version
|
45
37
|
unless system %(gem list --silent -i bundler -v #{version})
|
@@ -66,17 +58,6 @@ module Appraisal
|
|
66
58
|
end
|
67
59
|
end
|
68
60
|
|
69
|
-
def unset_bundler_env_vars
|
70
|
-
BUNDLER_ENV_VARS.each do |key|
|
71
|
-
original_env[key] = ENV[key]
|
72
|
-
ENV[key] = nil
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def restore_env
|
77
|
-
original_env.each { |key, value| ENV[key] = value }
|
78
|
-
end
|
79
|
-
|
80
61
|
def command_starts_with_bundle?(original_command)
|
81
62
|
if original_command.is_a?(Array)
|
82
63
|
original_command.first =~ /^bundle/
|
@@ -100,5 +81,14 @@ module Appraisal
|
|
100
81
|
command
|
101
82
|
end
|
102
83
|
end
|
84
|
+
|
85
|
+
def test_environment
|
86
|
+
return {} unless ENV["APPRAISAL_UNDER_TEST"] == "1"
|
87
|
+
|
88
|
+
{
|
89
|
+
"GEM_HOME" => ENV["GEM_HOME"],
|
90
|
+
"GEM_PATH" => "",
|
91
|
+
}
|
92
|
+
end
|
103
93
|
end
|
104
94
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "appraisal/bundler_dsl"
|
2
|
+
require "appraisal/utils"
|
3
|
+
|
4
|
+
module Appraisal
|
5
|
+
class Conditional < BundlerDSL
|
6
|
+
def initialize(condition)
|
7
|
+
super()
|
8
|
+
@condition = condition
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
"install_if #{@condition} do\n#{indent(super)}\nend"
|
13
|
+
end
|
14
|
+
|
15
|
+
# :nodoc:
|
16
|
+
def for_dup
|
17
|
+
"install_if #{@condition} do\n#{indent(super)}\nend"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Appraisal
|
2
|
+
class Customize
|
3
|
+
def initialize(heading: nil, single_quotes: false)
|
4
|
+
@@heading = heading
|
5
|
+
@@single_quotes = single_quotes
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.heading
|
9
|
+
@@heading ||= nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.single_quotes
|
13
|
+
@@single_quotes ||= false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/appraisal/gemfile.rb
CHANGED
@@ -7,23 +7,22 @@ module Appraisal
|
|
7
7
|
autoload :Path, "appraisal/path"
|
8
8
|
autoload :Platform, "appraisal/platform"
|
9
9
|
autoload :Source, "appraisal/source"
|
10
|
+
autoload :Conditional, "appraisal/conditional"
|
10
11
|
|
11
12
|
# Load bundler Gemfiles and merge dependencies
|
12
13
|
class Gemfile < BundlerDSL
|
13
14
|
def load(path)
|
14
|
-
if File.exist?(path)
|
15
|
-
run(IO.read(path))
|
16
|
-
end
|
15
|
+
run(IO.read(path), path) if File.exist?(path)
|
17
16
|
end
|
18
17
|
|
19
|
-
def run(definitions)
|
20
|
-
instance_eval(definitions,
|
18
|
+
def run(definitions, path, line = 1)
|
19
|
+
instance_eval(definitions, path, line) if definitions
|
21
20
|
end
|
22
21
|
|
23
22
|
def dup
|
24
23
|
Gemfile.new.tap do |gemfile|
|
25
24
|
gemfile.git_sources = @git_sources
|
26
|
-
gemfile.run(for_dup)
|
25
|
+
gemfile.run(for_dup, __FILE__, __LINE__)
|
27
26
|
end
|
28
27
|
end
|
29
28
|
end
|
data/lib/appraisal/version.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe 'Appraisals file Bundler DSL compatibility' do
|
4
4
|
it 'supports all Bundler DSL in Appraisals file' do
|
5
5
|
build_gems %w(bagel orange_juice milk waffle coffee ham
|
6
|
-
sausage pancake rotten_egg)
|
6
|
+
sausage pancake rotten_egg mayonnaise)
|
7
7
|
build_git_gems %w(egg croissant pain_au_chocolat omelette)
|
8
8
|
|
9
9
|
build_gemfile <<-Gemfile
|
@@ -40,6 +40,10 @@ describe 'Appraisals file Bundler DSL compatibility' do
|
|
40
40
|
gem "sausage"
|
41
41
|
end
|
42
42
|
|
43
|
+
install_if '"-> { true }"' do
|
44
|
+
gem 'mayonnaise'
|
45
|
+
end
|
46
|
+
|
43
47
|
gem 'appraisal', :path => #{PROJECT_ROOT.inspect}
|
44
48
|
Gemfile
|
45
49
|
|
@@ -76,6 +80,10 @@ describe 'Appraisals file Bundler DSL compatibility' do
|
|
76
80
|
gem "pancake"
|
77
81
|
end
|
78
82
|
|
83
|
+
install_if "-> { true }" do
|
84
|
+
gem 'ketchup'
|
85
|
+
end
|
86
|
+
|
79
87
|
gemspec
|
80
88
|
gemspec :path => "sitepress"
|
81
89
|
end
|
@@ -132,6 +140,11 @@ describe 'Appraisals file Bundler DSL compatibility' do
|
|
132
140
|
gem "pancake"
|
133
141
|
end
|
134
142
|
|
143
|
+
install_if -> { true } do
|
144
|
+
gem "mayonnaise"
|
145
|
+
gem "ketchup"
|
146
|
+
end
|
147
|
+
|
135
148
|
gemspec :path => "../"
|
136
149
|
gemspec :path => "../sitepress"
|
137
150
|
Gemfile
|
@@ -39,7 +39,9 @@ describe "Bundler without flag" do
|
|
39
39
|
output = run "appraisal install --without drinks"
|
40
40
|
|
41
41
|
expect(output).to include("Bundle complete")
|
42
|
-
expect(output).to
|
42
|
+
expect(output).to(
|
43
|
+
match(/Gems in the group ['"]?drinks['"]? were not installed/),
|
44
|
+
)
|
43
45
|
expect(output).not_to include("orange_juice")
|
44
46
|
expect(output).not_to include("coffee")
|
45
47
|
expect(output).not_to include("soda")
|
@@ -40,6 +40,26 @@ describe 'CLI', 'appraisal install' do
|
|
40
40
|
not_to include(current_directory)
|
41
41
|
end
|
42
42
|
|
43
|
+
it "does not relativize directory of uris in gemfile.lock" do
|
44
|
+
build_gemspec
|
45
|
+
add_gemspec_to_gemfile
|
46
|
+
|
47
|
+
build_git_gem("uri_dummy")
|
48
|
+
uri_dummy_path = "#{current_directory}/uri_dummy"
|
49
|
+
FileUtils.symlink(File.absolute_path("tmp/gems/uri_dummy"), uri_dummy_path)
|
50
|
+
|
51
|
+
build_appraisal_file <<-APPRAISAL
|
52
|
+
appraise '1.0.0' do
|
53
|
+
gem 'uri_dummy', git: 'file://#{uri_dummy_path}'
|
54
|
+
end
|
55
|
+
APPRAISAL
|
56
|
+
|
57
|
+
run "appraisal install"
|
58
|
+
|
59
|
+
expect(content_of("gemfiles/1.0.0.gemfile.lock")).
|
60
|
+
to include("file://#{uri_dummy_path}")
|
61
|
+
end
|
62
|
+
|
43
63
|
context 'with job size', :parallel => true do
|
44
64
|
before do
|
45
65
|
build_appraisal_file <<-Appraisal
|
@@ -111,6 +111,8 @@ describe 'Gemfile DSL compatibility' do
|
|
111
111
|
build_gem "bacon", "1.2.0"
|
112
112
|
|
113
113
|
build_gemfile <<-Gemfile
|
114
|
+
source "https://rubygems.org"
|
115
|
+
|
114
116
|
gem "appraisal", :path => #{PROJECT_ROOT.inspect}
|
115
117
|
gem "bacon", "1.2.0"
|
116
118
|
Gemfile
|
@@ -142,6 +144,8 @@ describe 'Gemfile DSL compatibility' do
|
|
142
144
|
build_gemspec
|
143
145
|
|
144
146
|
build_gemfile <<-Gemfile
|
147
|
+
source "https://rubygems.org"
|
148
|
+
|
145
149
|
gem "appraisal", :path => #{PROJECT_ROOT.inspect}
|
146
150
|
|
147
151
|
group :plugin do
|
@@ -161,6 +165,8 @@ describe 'Gemfile DSL compatibility' do
|
|
161
165
|
expect(content_of "gemfiles/1.0.0.gemfile").to eq <<-gemfile.strip_heredoc
|
162
166
|
# This file was generated by Appraisal
|
163
167
|
|
168
|
+
source "https://rubygems.org"
|
169
|
+
|
164
170
|
gem "appraisal", :path => #{PROJECT_ROOT.inspect}
|
165
171
|
gem "bacon", "1.0.0"
|
166
172
|
|
@@ -10,6 +10,8 @@ describe 'Gemspec' do
|
|
10
10
|
build_gemspec
|
11
11
|
|
12
12
|
write_file 'Gemfile', <<-Gemfile
|
13
|
+
source "https://rubygems.org"
|
14
|
+
|
13
15
|
gem 'appraisal', :path => #{PROJECT_ROOT.inspect}
|
14
16
|
|
15
17
|
gemspec
|
@@ -26,6 +28,8 @@ describe 'Gemspec' do
|
|
26
28
|
build_gemspec 'specdir'
|
27
29
|
|
28
30
|
write_file 'Gemfile', <<-Gemfile
|
31
|
+
source "https://rubygems.org"
|
32
|
+
|
29
33
|
gem 'appraisal', :path => #{PROJECT_ROOT.inspect}
|
30
34
|
|
31
35
|
gemspec :path => './specdir'
|
@@ -28,6 +28,63 @@ describe Appraisal::Appraisal do
|
|
28
28
|
expect(output_file.read).to match(/[^\n]*\n\z/m)
|
29
29
|
end
|
30
30
|
|
31
|
+
context "gemfile customization" do
|
32
|
+
it "generates a gemfile with a custom heading" do
|
33
|
+
heading = "This file was generated with a custom heading!"
|
34
|
+
Appraisal::Customize.new(heading: heading)
|
35
|
+
output_file = Tempfile.new("gemfile")
|
36
|
+
appraisal = Appraisal::Appraisal.new("custom", "Gemfile")
|
37
|
+
allow(appraisal).to receive(:gemfile_path).and_return(output_file.path)
|
38
|
+
|
39
|
+
appraisal.write_gemfile
|
40
|
+
|
41
|
+
expected_output = "# #{heading}"
|
42
|
+
expect(output_file.read).to start_with(expected_output)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "generates a gemfile with multiple lines of custom heading" do
|
46
|
+
heading = <<~HEADING
|
47
|
+
frozen_string_literal: true\n
|
48
|
+
This file was generated with a custom heading!
|
49
|
+
HEADING
|
50
|
+
Appraisal::Customize.new(heading: heading)
|
51
|
+
output_file = Tempfile.new("gemfile")
|
52
|
+
appraisal = Appraisal::Appraisal.new("custom", "Gemfile")
|
53
|
+
allow(appraisal).to receive(:gemfile_path).and_return(output_file.path)
|
54
|
+
|
55
|
+
appraisal.write_gemfile
|
56
|
+
|
57
|
+
expected_output = <<~HEADING
|
58
|
+
# frozen_string_literal: true\n
|
59
|
+
# This file was generated with a custom heading!
|
60
|
+
HEADING
|
61
|
+
expect(output_file.read).to start_with(expected_output)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "generates a gemfile with single quotes rather than doubles" do
|
65
|
+
Appraisal::Customize.new(single_quotes: true)
|
66
|
+
output_file = Tempfile.new("gemfile")
|
67
|
+
appraisal = Appraisal::Appraisal.new("quotes", 'gem "foo"')
|
68
|
+
allow(appraisal).to receive(:gemfile_path).and_return(output_file.path)
|
69
|
+
|
70
|
+
appraisal.write_gemfile
|
71
|
+
|
72
|
+
expect(output_file.read).to match(/gem 'foo'/)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "does not customize anything by default" do
|
76
|
+
Appraisal::Customize.new
|
77
|
+
output_file = Tempfile.new("gemfile")
|
78
|
+
appraisal = Appraisal::Appraisal.new("fake", 'gem "foo"')
|
79
|
+
allow(appraisal).to receive(:gemfile_path).and_return(output_file.path)
|
80
|
+
|
81
|
+
appraisal.write_gemfile
|
82
|
+
|
83
|
+
expected_file = %(# This file was generated by Appraisal\n\ngem "foo"\n)
|
84
|
+
expect(output_file.read).to eq(expected_file)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
31
88
|
context 'parallel installation' do
|
32
89
|
include StreamHelpers
|
33
90
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "appraisal/customize"
|
3
|
+
|
4
|
+
describe Appraisal::Customize do
|
5
|
+
it "has defaults" do
|
6
|
+
expect(described_class.heading).to eq nil
|
7
|
+
expect(described_class.single_quotes).to eq false
|
8
|
+
expect { described_class.new }.to_not(change do
|
9
|
+
[described_class.heading, described_class.single_quotes]
|
10
|
+
end)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "can override defaults" do
|
14
|
+
described_class.new(single_quotes: true, heading: "foo")
|
15
|
+
expect(described_class.heading).to eq "foo"
|
16
|
+
expect(described_class.single_quotes).to eq true
|
17
|
+
end
|
18
|
+
end
|
@@ -430,4 +430,13 @@ describe Appraisal::Gemfile do
|
|
430
430
|
expect(gemfile.to_s).to eq %(gem "bacon", git: "../path/bacon_pancake")
|
431
431
|
end
|
432
432
|
end
|
433
|
+
|
434
|
+
it "preserves the Gemfile's __FILE__" do
|
435
|
+
gemfile = Appraisal::Gemfile.new
|
436
|
+
Tempfile.open do |tmpfile|
|
437
|
+
tmpfile.write "__FILE__"
|
438
|
+
tmpfile.rewind
|
439
|
+
expect(gemfile.load(tmpfile.path)).to include(File.dirname(tmpfile.path))
|
440
|
+
end
|
441
|
+
end
|
433
442
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,6 +5,7 @@ require "./spec/support/stream_helpers"
|
|
5
5
|
|
6
6
|
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze
|
7
7
|
TMP_GEM_ROOT = File.join(PROJECT_ROOT, "tmp", "gems")
|
8
|
+
ENV["APPRAISAL_UNDER_TEST"] = "1"
|
8
9
|
|
9
10
|
RSpec.configure do |config|
|
10
11
|
config.raise_errors_for_deprecations!
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appraisal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Ferris
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-07-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -93,7 +93,6 @@ extra_rdoc_files: []
|
|
93
93
|
files:
|
94
94
|
- ".gitignore"
|
95
95
|
- ".rspec"
|
96
|
-
- ".travis.yml"
|
97
96
|
- CONTRIBUTING.md
|
98
97
|
- Gemfile
|
99
98
|
- MIT-LICENSE
|
@@ -107,6 +106,8 @@ files:
|
|
107
106
|
- lib/appraisal/bundler_dsl.rb
|
108
107
|
- lib/appraisal/cli.rb
|
109
108
|
- lib/appraisal/command.rb
|
109
|
+
- lib/appraisal/conditional.rb
|
110
|
+
- lib/appraisal/customize.rb
|
110
111
|
- lib/appraisal/dependency.rb
|
111
112
|
- lib/appraisal/dependency_list.rb
|
112
113
|
- lib/appraisal/errors.rb
|
@@ -118,7 +119,6 @@ files:
|
|
118
119
|
- lib/appraisal/platform.rb
|
119
120
|
- lib/appraisal/source.rb
|
120
121
|
- lib/appraisal/task.rb
|
121
|
-
- lib/appraisal/travis_ci_helper.rb
|
122
122
|
- lib/appraisal/utils.rb
|
123
123
|
- lib/appraisal/version.rb
|
124
124
|
- spec/acceptance/appraisals_file_bundler_dsl_compatibility_spec.rb
|
@@ -135,9 +135,9 @@ files:
|
|
135
135
|
- spec/acceptance/cli/with_no_arguments_spec.rb
|
136
136
|
- spec/acceptance/gemfile_dsl_compatibility_spec.rb
|
137
137
|
- spec/acceptance/gemspec_spec.rb
|
138
|
-
- spec/acceptance/travis_ci_integration_spec.rb
|
139
138
|
- spec/appraisal/appraisal_file_spec.rb
|
140
139
|
- spec/appraisal/appraisal_spec.rb
|
140
|
+
- spec/appraisal/customize_spec.rb
|
141
141
|
- spec/appraisal/dependency_list_spec.rb
|
142
142
|
- spec/appraisal/gemfile_spec.rb
|
143
143
|
- spec/appraisal/utils_spec.rb
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
- !ruby/object:Gem::Version
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
|
-
rubygems_version: 3.2.
|
167
|
+
rubygems_version: 3.2.22
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: Find out what your Ruby gems are worth
|
@@ -183,9 +183,9 @@ test_files:
|
|
183
183
|
- spec/acceptance/cli/with_no_arguments_spec.rb
|
184
184
|
- spec/acceptance/gemfile_dsl_compatibility_spec.rb
|
185
185
|
- spec/acceptance/gemspec_spec.rb
|
186
|
-
- spec/acceptance/travis_ci_integration_spec.rb
|
187
186
|
- spec/appraisal/appraisal_file_spec.rb
|
188
187
|
- spec/appraisal/appraisal_spec.rb
|
188
|
+
- spec/appraisal/customize_spec.rb
|
189
189
|
- spec/appraisal/dependency_list_spec.rb
|
190
190
|
- spec/appraisal/gemfile_spec.rb
|
191
191
|
- spec/appraisal/utils_spec.rb
|
data/.travis.yml
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require "appraisal/appraisal_file"
|
2
|
-
require "yaml"
|
3
|
-
|
4
|
-
module Appraisal
|
5
|
-
class TravisCIHelper
|
6
|
-
NO_CONFIGURATION_WARNING = <<-WARNING.strip.gsub(/\s+/, " ")
|
7
|
-
Note: Run `appraisal generate --travis` to generate Travis CI
|
8
|
-
configuration.
|
9
|
-
WARNING
|
10
|
-
|
11
|
-
INVALID_CONFIGURATION_WARNING = <<-WARNING.strip.gsub(/\s+/, " ")
|
12
|
-
Warning: Your gemfiles directive in .travis.yml is incorrect. Run
|
13
|
-
`appraisal generate --travis` to get the correct configuration.
|
14
|
-
WARNING
|
15
|
-
|
16
|
-
# @see http://docs.travis-ci.com/user/languages/ruby/
|
17
|
-
GEMFILES_CONFIGURATION_KEY = "gemfile".freeze
|
18
|
-
|
19
|
-
def self.display_instruction
|
20
|
-
puts "# Put this in your .travis.yml"
|
21
|
-
puts "#{GEMFILES_CONFIGURATION_KEY}:"
|
22
|
-
|
23
|
-
AppraisalFile.each do |appraisal|
|
24
|
-
puts " - #{appraisal.relative_gemfile_path}"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.validate_configuration_file
|
29
|
-
ConfigurationValidator.new.validate
|
30
|
-
end
|
31
|
-
|
32
|
-
class ConfigurationValidator
|
33
|
-
CONFIGURATION_FILE = ".travis.yml"
|
34
|
-
|
35
|
-
def validate
|
36
|
-
if has_configuration_file?
|
37
|
-
if has_no_gemfiles_configuration?
|
38
|
-
$stderr.puts(NO_CONFIGURATION_WARNING)
|
39
|
-
elsif has_invalid_gemfiles_configuration?
|
40
|
-
$stderr.puts(INVALID_CONFIGURATION_WARNING)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def has_configuration_file?
|
48
|
-
File.exist?(CONFIGURATION_FILE)
|
49
|
-
end
|
50
|
-
|
51
|
-
def has_no_gemfiles_configuration?
|
52
|
-
!(configuration && configuration.has_key?(GEMFILES_CONFIGURATION_KEY))
|
53
|
-
end
|
54
|
-
|
55
|
-
def has_invalid_gemfiles_configuration?
|
56
|
-
if configuration && configuration[GEMFILES_CONFIGURATION_KEY]
|
57
|
-
appraisal_paths =
|
58
|
-
AppraisalFile.new.appraisals.map(&:relative_gemfile_path).sort
|
59
|
-
travis_gemfile_paths = configuration[GEMFILES_CONFIGURATION_KEY].sort
|
60
|
-
appraisal_paths != travis_gemfile_paths
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def configuration
|
65
|
-
YAML.load_file(CONFIGURATION_FILE) rescue nil
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "active_support/core_ext/kernel/reporting"
|
3
|
-
require "appraisal/travis_ci_helper"
|
4
|
-
|
5
|
-
describe "Travis CI integration" do
|
6
|
-
before do
|
7
|
-
build_appraisal_file <<-Appraisals.strip_heredoc
|
8
|
-
appraise "1.0.0" do
|
9
|
-
gem "dummy", "1.0.0"
|
10
|
-
end
|
11
|
-
|
12
|
-
appraise "1.1.0" do
|
13
|
-
gem "dummy", "1.1.0"
|
14
|
-
end
|
15
|
-
Appraisals
|
16
|
-
end
|
17
|
-
|
18
|
-
context "when user runs `appraisal generate --travis`" do
|
19
|
-
it "displays a correct Gemfile directive" do
|
20
|
-
output = run("appraisal generate --travis")
|
21
|
-
|
22
|
-
expect(output).to include <<-stdout.strip_heredoc
|
23
|
-
# Put this in your .travis.yml
|
24
|
-
gemfile:
|
25
|
-
- gemfiles/1.0.0.gemfile
|
26
|
-
- gemfiles/1.1.0.gemfile
|
27
|
-
stdout
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "When user has .travis.yml" do
|
32
|
-
context "with no gemfiles directive" do
|
33
|
-
before do
|
34
|
-
write_file ".travis.yml", ""
|
35
|
-
end
|
36
|
-
|
37
|
-
it "displays a warning message when run `appraisal generate`" do
|
38
|
-
warning = run "appraisal generate 2>&1"
|
39
|
-
|
40
|
-
expect(warning).to include no_configuration_warning
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "with incorrect gemfiles directive" do
|
45
|
-
before do
|
46
|
-
write_file ".travis.yml", <<-travis_yml
|
47
|
-
gemfile:
|
48
|
-
- gemfiles/1.0.0.gemfile
|
49
|
-
- gemfiles/1.0.1.gemfile
|
50
|
-
travis_yml
|
51
|
-
end
|
52
|
-
|
53
|
-
it "displays a warning message when run `appraisal generate`" do
|
54
|
-
warning = run "appraisal generate 2>&1"
|
55
|
-
|
56
|
-
expect(warning).to include invalid_configuration_warning
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context "with correct gemfiles directive" do
|
61
|
-
before do
|
62
|
-
write_file ".travis.yml", <<-travis_yml
|
63
|
-
gemfile:
|
64
|
-
- gemfiles/1.0.0.gemfile
|
65
|
-
- gemfiles/1.1.0.gemfile
|
66
|
-
travis_yml
|
67
|
-
end
|
68
|
-
|
69
|
-
it "does not display any warning when run `appraisal generate`" do
|
70
|
-
warning = run "appraisal generate 2>&1"
|
71
|
-
|
72
|
-
expect(warning).not_to include no_configuration_warning
|
73
|
-
expect(warning).not_to include invalid_configuration_warning
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context "when user does not have .travis.yml" do
|
79
|
-
it "does not display any warning when run `appraisal generate`" do
|
80
|
-
warning = run "appraisal generate 2>&1"
|
81
|
-
|
82
|
-
expect(warning).not_to include no_configuration_warning
|
83
|
-
expect(warning).not_to include invalid_configuration_warning
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def no_configuration_warning
|
88
|
-
Appraisal::TravisCIHelper::NO_CONFIGURATION_WARNING
|
89
|
-
end
|
90
|
-
|
91
|
-
def invalid_configuration_warning
|
92
|
-
Appraisal::TravisCIHelper::INVALID_CONFIGURATION_WARNING
|
93
|
-
end
|
94
|
-
end
|