appraisal 1.0.0.beta3 → 1.0.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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -8
  3. data/appraisal.gemspec +0 -2
  4. data/bin/appraisal +6 -1
  5. data/features/support/dependency_helpers.rb +27 -21
  6. data/lib/appraisal/appraisal.rb +30 -2
  7. data/lib/appraisal/dependency.rb +3 -5
  8. data/lib/appraisal/dependency_list.rb +21 -0
  9. data/lib/appraisal/gemfile.rb +37 -27
  10. data/lib/appraisal/gemspec.rb +5 -4
  11. data/lib/appraisal/git_source.rb +12 -4
  12. data/lib/appraisal/group.rb +11 -4
  13. data/lib/appraisal/path_source.rb +31 -0
  14. data/lib/appraisal/platform.rb +12 -4
  15. data/lib/appraisal/task.rb +10 -7
  16. data/lib/appraisal/utils.rb +21 -0
  17. data/lib/appraisal/version.rb +1 -1
  18. data/spec/acceptance/appraisals_file_bundler_dsl_compatibility_spec.rb +98 -0
  19. data/spec/acceptance/cli/clean_spec.rb +20 -0
  20. data/spec/acceptance/cli/generate_spec.rb +28 -0
  21. data/spec/acceptance/cli/help_spec.rb +17 -0
  22. data/spec/acceptance/cli/install_spec.rb +70 -0
  23. data/spec/acceptance/cli/run_spec.rb +47 -0
  24. data/spec/acceptance/cli/update_spec.rb +43 -0
  25. data/spec/acceptance/cli/with_no_arguments_spec.rb +16 -0
  26. data/spec/acceptance/gemfile_dsl_compatibility_spec.rb +107 -0
  27. data/spec/acceptance/gemspec_spec.rb +75 -0
  28. data/spec/appraisal/gemspec_spec.rb +22 -0
  29. data/spec/appraisal/utils_spec.rb +24 -0
  30. data/spec/spec_helper.rb +0 -1
  31. data/spec/support/acceptance_test_helpers.rb +73 -35
  32. data/spec/support/dependency_helpers.rb +49 -0
  33. metadata +32 -48
  34. data/features/appraisals.feature +0 -105
  35. data/features/bundler_gemfile_compatibility.feature +0 -70
  36. data/features/gemspec.feature +0 -68
  37. data/features/missing_appraisals_file.feature +0 -23
  38. data/features/step_definitions/dependency_steps.rb +0 -24
  39. data/features/support/aruba.rb +0 -4
  40. data/features/support/env.rb +0 -11
  41. data/spec/acceptance/cli_spec.rb +0 -233
@@ -28,14 +28,17 @@ module Appraisal
28
28
  exec 'bundle exec appraisal clean'
29
29
  end
30
30
 
31
- File.each do |appraisal|
32
- desc "DEPRECATED: Run the given task for appraisal #{appraisal.name}"
33
- task appraisal.name do
34
- ARGV.shift
35
- warn "`rake appraisal:#{appraisal.name}` task is deprecated and will be removed soon. " +
36
- "Please use `appraisal #{appraisal.name} rake #{ARGV.join(' ')}`."
37
- exec "bundle exec appraisal #{appraisal.name} rake #{ARGV.join(' ')}"
31
+ begin
32
+ File.each do |appraisal|
33
+ desc "DEPRECATED: Run the given task for appraisal #{appraisal.name}"
34
+ task appraisal.name do
35
+ ARGV.shift
36
+ warn "`rake appraisal:#{appraisal.name}` task is deprecated and will be removed soon. " +
37
+ "Please use `appraisal #{appraisal.name} rake #{ARGV.join(' ')}`."
38
+ exec "bundle exec appraisal #{appraisal.name} rake #{ARGV.join(' ')}"
39
+ end
38
40
  end
41
+ rescue AppraisalsNotFound
39
42
  end
40
43
 
41
44
  task :all do
@@ -4,5 +4,26 @@ module Appraisal
4
4
  def self.support_parallel_installation?
5
5
  Gem::Version.create(Bundler::VERSION) >= Gem::Version.create('1.4.0.pre.1')
6
6
  end
7
+
8
+ def self.format_string(object, enclosing_object = false)
9
+ case object
10
+ when Hash
11
+ items = object.map do |key, value|
12
+ "#{format_string(key, true)} => #{format_string(value, true)}"
13
+ end
14
+
15
+ if enclosing_object
16
+ "{ #{items.join(', ')} }"
17
+ else
18
+ items.join(', ')
19
+ end
20
+ else
21
+ object.inspect
22
+ end
23
+ end
24
+
25
+ def self.format_arguments(arguments)
26
+ arguments.map { |object| format_string(object, false) }.join(', ')
27
+ end
7
28
  end
8
29
  end
@@ -1,3 +1,3 @@
1
1
  module Appraisal
2
- VERSION = '1.0.0.beta3'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -0,0 +1,98 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Appraisals file Bundler DSL compatibility' do
4
+ it 'supports all Bundler DSL in Appraisals file' do
5
+ build_gems %w(bagel orange_juice milk waffle)
6
+ build_git_gem 'egg'
7
+
8
+ build_gemfile <<-Gemfile
9
+ source 'https://rubygems.org'
10
+ ruby RUBY_VERSION
11
+
12
+ gem 'bagel'
13
+
14
+ git '../gems/egg' do
15
+ gem 'egg'
16
+ end
17
+
18
+ path '../gems/waffle' do
19
+ gem 'waffle'
20
+ end
21
+
22
+ group :breakfast do
23
+ gem 'orange_juice'
24
+ end
25
+
26
+ platforms :ruby, :jruby do
27
+ gem 'milk'
28
+ end
29
+
30
+ gem 'appraisal', path: #{PROJECT_ROOT.inspect}
31
+ Gemfile
32
+
33
+ build_appraisal_file <<-Appraisals
34
+ appraise 'breakfast' do
35
+ source 'http://some-other-source.com'
36
+ ruby "1.8.7"
37
+
38
+ gem 'bread'
39
+
40
+ git '../gems/egg' do
41
+ gem 'porched_egg'
42
+ end
43
+
44
+ path '../gems/waffle' do
45
+ gem 'chocolate_waffle'
46
+ end
47
+
48
+ group :breakfast do
49
+ gem 'bacon'
50
+ end
51
+
52
+ platforms :ruby, :jruby do
53
+ gem 'yoghurt'
54
+ end
55
+
56
+ gemspec
57
+ end
58
+ Appraisals
59
+
60
+ run 'bundle install --local'
61
+ run 'appraisal generate'
62
+
63
+ expect(content_of 'gemfiles/breakfast.gemfile').to eq <<-Gemfile.strip_heredoc
64
+ # This file was generated by Appraisal
65
+
66
+ source "https://rubygems.org"
67
+ source "http://some-other-source.com"
68
+
69
+ ruby "1.8.7"
70
+
71
+ git "../gems/egg" do
72
+ gem "egg"
73
+ gem "porched_egg"
74
+ end
75
+
76
+ path "../gems/waffle" do
77
+ gem "waffle"
78
+ gem "chocolate_waffle"
79
+ end
80
+
81
+ gem "bagel"
82
+ gem "appraisal", :path => #{PROJECT_ROOT.inspect}
83
+ gem "bread"
84
+
85
+ group :breakfast do
86
+ gem "orange_juice"
87
+ gem "bacon"
88
+ end
89
+
90
+ platforms :ruby, :jruby do
91
+ gem "milk"
92
+ gem "yoghurt"
93
+ end
94
+
95
+ gemspec :path => "../"
96
+ Gemfile
97
+ end
98
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'CLI', 'appraisal clean' do
4
+ it 'remove all gemfiles from gemfiles directory' do
5
+ build_appraisal_file <<-Appraisal
6
+ appraise '1.0.0' do
7
+ gem 'dummy', '1.0.0'
8
+ end
9
+ Appraisal
10
+
11
+ run 'appraisal install'
12
+ write_file 'gemfiles/non_related_file', ''
13
+
14
+ run 'appraisal clean'
15
+
16
+ expect(file 'gemfiles/1.0.0.gemfile').not_to be_exists
17
+ expect(file 'gemfiles/1.0.0.gemfile.lock').not_to be_exists
18
+ expect(file 'gemfiles/non_related_file').to be_exists
19
+ end
20
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'CLI', 'appraisal generate' do
4
+ it 'generates the gemfiles' do
5
+ build_appraisal_file <<-Appraisal
6
+ appraise '1.0.0' do
7
+ gem 'dummy', '1.0.0'
8
+ end
9
+
10
+ appraise '1.1.0' do
11
+ gem 'dummy', '1.1.0'
12
+ end
13
+ Appraisal
14
+
15
+ run 'appraisal generate'
16
+
17
+ expect(file 'gemfiles/1.0.0.gemfile').to be_exists
18
+ expect(file 'gemfiles/1.1.0.gemfile').to be_exists
19
+ expect(content_of 'gemfiles/1.0.0.gemfile').to eq <<-gemfile.strip_heredoc
20
+ # This file was generated by Appraisal
21
+
22
+ source "https://rubygems.org"
23
+
24
+ gem "appraisal", :path => "#{PROJECT_ROOT}"
25
+ gem "dummy", "1.0.0"
26
+ gemfile
27
+ end
28
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'CLI', 'appraisal help' do
4
+ it 'prints usage along with commands, and list of appraisals' do
5
+ build_appraisal_file <<-Appraisal
6
+ appraise '1.0.0' do
7
+ gem 'dummy', '1.0.0'
8
+ end
9
+ Appraisal
10
+
11
+ output = run 'appraisal help'
12
+
13
+ expect(output).to include 'Usage:'
14
+ expect(output).to include 'appraisal [APPRAISAL_NAME] EXTERNAL_COMMAND'
15
+ expect(output).to include '1.0.0'
16
+ end
17
+ end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'CLI', 'appraisal install' do
4
+ it 'raises error when there is no Appraisals file' do
5
+ output = run 'appraisal install 2>&1', false
6
+
7
+ expect(output).to include "Unable to locate 'Appraisals' file"
8
+ end
9
+
10
+ it 'installs the dependencies' do
11
+ build_appraisal_file <<-Appraisal
12
+ appraise '1.0.0' do
13
+ gem 'dummy', '1.0.0'
14
+ end
15
+
16
+ appraise '1.1.0' do
17
+ gem 'dummy', '1.1.0'
18
+ end
19
+ Appraisal
20
+
21
+ run 'appraisal install'
22
+
23
+ expect(file 'gemfiles/1.0.0.gemfile.lock').to be_exists
24
+ expect(file 'gemfiles/1.1.0.gemfile.lock').to be_exists
25
+ end
26
+
27
+ it 'relativize directory in gemfile.lock' do
28
+ build_gemspec
29
+ add_gemspec_to_gemfile
30
+
31
+ build_appraisal_file <<-Appraisal
32
+ appraise '1.0.0' do
33
+ gem 'dummy', '1.0.0'
34
+ end
35
+ Appraisal
36
+
37
+ run 'appraisal install'
38
+
39
+ expect(content_of 'gemfiles/1.0.0.gemfile.lock').not_to include
40
+ current_directory
41
+ end
42
+
43
+ context 'with job size', parallel: true do
44
+ before do
45
+ build_appraisal_file <<-Appraisal
46
+ appraise '1.0.0' do
47
+ gem 'dummy', '1.0.0'
48
+ end
49
+ Appraisal
50
+ end
51
+
52
+ it 'accepts --jobs option to set job size' do
53
+ output = run 'appraisal install --jobs=2'
54
+
55
+ expect(output).to include
56
+ 'bundle install --gemfile=gemfiles/1.0.0.gemfile --jobs=2'
57
+ end
58
+
59
+ it 'ignores --jobs option if the job size is less than or equal to 1' do
60
+ output = run 'appraisal install --jobs=0'
61
+
62
+ expect(output).not_to include
63
+ 'bundle install --gemfile=gemfiles/1.0.0.gemfile'
64
+ expect(output).not_to include
65
+ 'bundle install --gemfile=gemfiles/1.0.0.gemfile --jobs=0'
66
+ expect(output).not_to include
67
+ 'bundle install --gemfile=gemfiles/1.0.0.gemfile --jobs=1'
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'CLI appraisal (with arguments)' do
4
+ before do
5
+ build_appraisal_file <<-Appraisal
6
+ appraise '1.0.0' do
7
+ gem 'dummy', '1.0.0'
8
+ end
9
+
10
+ appraise '1.1.0' do
11
+ gem 'dummy', '1.1.0'
12
+ end
13
+ Appraisal
14
+
15
+ run 'appraisal install'
16
+ write_file 'test.rb', 'puts "Running: #{$dummy_version}"'
17
+ end
18
+
19
+ it 'sets APPRAISAL_INITIALIZED environment variable' do
20
+ write_file 'test.rb', <<-TEST_FILE.strip_heredoc
21
+ if ENV['APPRAISAL_INITIALIZED']
22
+ puts "Appraisal initialized!"
23
+ end
24
+ TEST_FILE
25
+
26
+ output = run 'appraisal 1.0.0 ruby -rbundler/setup -rdummy test.rb'
27
+ expect(output).to include 'Appraisal initialized!'
28
+ end
29
+
30
+ context 'with appraisal name' do
31
+ it 'runs the given command against a correct versions of dependency' do
32
+ output = run 'appraisal 1.0.0 ruby -rbundler/setup -rdummy test.rb'
33
+
34
+ expect(output).to include 'Running: 1.0.0'
35
+ expect(output).not_to include 'Running: 1.1.0'
36
+ end
37
+ end
38
+
39
+ context 'without appraisal name' do
40
+ it 'runs the given command against all versions of dependency' do
41
+ output = run 'appraisal ruby -rbundler/setup -rdummy test.rb'
42
+
43
+ expect(output).to include 'Running: 1.0.0'
44
+ expect(output).to include 'Running: 1.1.0'
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'CLI', 'appraisal update' do
4
+ before do
5
+ build_gem 'dummy2', '1.0.0'
6
+
7
+ build_appraisal_file <<-Appraisal
8
+ appraise 'dummy' do
9
+ gem 'dummy', '~> 1.0.0'
10
+ gem 'dummy2', '~> 1.0.0'
11
+ end
12
+ Appraisal
13
+
14
+ run 'appraisal install'
15
+ build_gem 'dummy', '1.0.1'
16
+ build_gem 'dummy2', '1.0.1'
17
+ end
18
+
19
+ after do
20
+ in_test_directory do
21
+ `gem uninstall dummy -v 1.0.1`
22
+ `gem uninstall dummy2 -a`
23
+ end
24
+ end
25
+
26
+ context 'with no arguments' do
27
+ it 'updates all the gems' do
28
+ run 'appraisal update'
29
+
30
+ expect(content_of 'gemfiles/dummy.gemfile.lock').to include 'dummy (1.0.1)'
31
+ expect(content_of 'gemfiles/dummy.gemfile.lock').to include 'dummy2 (1.0.1)'
32
+ end
33
+ end
34
+
35
+ context 'with a list of gems' do
36
+ it 'only updates specified gems' do
37
+ run 'appraisal update dummy'
38
+
39
+ expect(content_of 'gemfiles/dummy.gemfile.lock').to include 'dummy (1.0.1)'
40
+ expect(content_of 'gemfiles/dummy.gemfile.lock').to include 'dummy2 (1.0.0)'
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'CLI appraisal (with no arguments)' do
4
+ it 'runs install command' do
5
+ build_appraisal_file <<-Appraisal
6
+ appraise '1.0.0' do
7
+ gem 'dummy', '1.0.0'
8
+ end
9
+ Appraisal
10
+
11
+ run 'appraisal'
12
+
13
+ expect(file 'gemfiles/1.0.0.gemfile').to be_exists
14
+ expect(file 'gemfiles/1.0.0.gemfile.lock').to be_exists
15
+ end
16
+ end
@@ -0,0 +1,107 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Gemfile DSL compatibility' do
4
+ it 'supports all Bundler DSL in Gemfile' do
5
+ build_gems %w(bacon orange_juice waffle)
6
+ build_git_gem 'egg'
7
+ build_gemspec
8
+
9
+ build_gemfile <<-Gemfile
10
+ source "https://rubygems.org"
11
+ ruby RUBY_VERSION
12
+
13
+ git "../gems/egg" do
14
+ gem "egg"
15
+ end
16
+
17
+ path "../gems/orange_juice" do
18
+ gem "orange_juice"
19
+ end
20
+
21
+ group :breakfast do
22
+ gem "bacon"
23
+ end
24
+
25
+ platforms :ruby, :jruby do
26
+ gem "waffle"
27
+ end
28
+
29
+ gem 'appraisal', path: #{PROJECT_ROOT.inspect}
30
+
31
+ gemspec
32
+ Gemfile
33
+
34
+ build_appraisal_file <<-Appraisals
35
+ appraise "japanese" do
36
+ gem "rice"
37
+ gem "miso_soup"
38
+ end
39
+
40
+ appraise "english" do
41
+ gem "bread"
42
+ end
43
+ Appraisals
44
+
45
+ run 'bundle install --local'
46
+ run 'appraisal generate'
47
+
48
+ expect(content_of 'gemfiles/japanese.gemfile').to eq <<-Gemfile.strip_heredoc
49
+ # This file was generated by Appraisal
50
+
51
+ source "https://rubygems.org"
52
+
53
+ ruby "#{RUBY_VERSION}"
54
+
55
+ git "../gems/egg" do
56
+ gem "egg"
57
+ end
58
+
59
+ path "../gems/orange_juice" do
60
+ gem "orange_juice"
61
+ end
62
+
63
+ gem "appraisal", :path => #{PROJECT_ROOT.inspect}
64
+ gem "rice"
65
+ gem "miso_soup"
66
+
67
+ group :breakfast do
68
+ gem "bacon"
69
+ end
70
+
71
+ platforms :ruby, :jruby do
72
+ gem "waffle"
73
+ end
74
+
75
+ gemspec :path => "../"
76
+ Gemfile
77
+
78
+ expect(content_of 'gemfiles/english.gemfile').to eq <<-Gemfile.strip_heredoc
79
+ # This file was generated by Appraisal
80
+
81
+ source "https://rubygems.org"
82
+
83
+ ruby "#{RUBY_VERSION}"
84
+
85
+ git "../gems/egg" do
86
+ gem "egg"
87
+ end
88
+
89
+ path "../gems/orange_juice" do
90
+ gem "orange_juice"
91
+ end
92
+
93
+ gem "appraisal", :path => #{PROJECT_ROOT.inspect}
94
+ gem "bread"
95
+
96
+ group :breakfast do
97
+ gem "bacon"
98
+ end
99
+
100
+ platforms :ruby, :jruby do
101
+ gem "waffle"
102
+ end
103
+
104
+ gemspec :path => "../"
105
+ Gemfile
106
+ end
107
+ end