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
@@ -1,105 +0,0 @@
1
- @disable-bundler
2
- Feature: run a rake task through several appraisals
3
-
4
- Background:
5
- Given a directory named "projecto"
6
- And the following installed dummy gems:
7
- | name | version |
8
- | dummy_girl | 1.3.0 |
9
- | dummy_girl | 1.3.2 |
10
- | dummy_rake | 0.8.7 |
11
- | dummy_rake | 0.9.0 |
12
- | dummy_sass | 3.1.0 |
13
- | dummy_spec | 3.1.9 |
14
- When I cd to "projecto"
15
- And I write to "Gemfile" with:
16
- """
17
- gem "dummy_rake", "0.8.7"
18
- gem "dummy_girl"
19
-
20
- group :assets do
21
- gem 'dummy_sass', "~> 3.1.0"
22
- end
23
-
24
- group :test, :development do
25
- gem 'dummy_spec', "~> 3.1.0"
26
- end
27
- """
28
- When I add "appraisal" from this project as a dependency
29
- And I write to "Appraisals" with:
30
- """
31
- appraise "1.3.2" do
32
- gem "dummy_girl", "1.3.2"
33
- end
34
-
35
- appraise "1.3.0" do
36
- gem "dummy_girl", "1.3.0"
37
- gem "dummy_rake", "0.9.0"
38
- end
39
- """
40
- When I write to "Rakefile" with:
41
- """
42
- require 'rubygems'
43
- require 'bundler/setup'
44
- require 'appraisal'
45
-
46
- task :version do
47
- require 'dummy_girl'
48
- puts "Loaded #{$dummy_girl_version}"
49
- end
50
-
51
- task :fail do
52
- require 'dummy_girl'
53
- puts "Fail #{$dummy_girl_version}"
54
- raise
55
- end
56
-
57
- task :default => :version
58
- """
59
- When I successfully run `bundle install --local`
60
- And I successfully run `bundle exec rake appraisal:install --trace`
61
-
62
- Scenario: run a specific task with one appraisal
63
- When I successfully run `bundle exec rake appraisal:1.3.0 version --trace`
64
- Then the output should contain "Loaded 1.3.0"
65
-
66
- Scenario: run a specific task with all appraisals
67
- When I successfully run `bundle exec rake appraisal version --trace`
68
- Then the output should contain "Loaded 1.3.0"
69
- And the output should contain "Loaded 1.3.2"
70
- And the output should not contain "Invoke version"
71
-
72
- Scenario: run the default task with one appraisal
73
- When I successfully run `bundle exec rake appraisal:1.3.0 --trace`
74
- Then the output should contain "Loaded 1.3.0"
75
-
76
- Scenario: run the default task with all appraisals
77
- When I successfully run `bundle exec rake appraisal --trace`
78
- Then the output should contain "Loaded 1.3.0"
79
- And the output should contain "Loaded 1.3.2"
80
-
81
- Scenario: run a failing task with one appraisal
82
- When I run `bundle exec rake appraisal:1.3.0 fail --trace`
83
- Then the output should contain "Fail 1.3.0"
84
- And the exit status should be 1
85
-
86
- Scenario: run a failing task with all appraisals
87
- When I run `bundle exec rake appraisal fail --trace`
88
- Then the output should contain "Fail 1.3.2"
89
- But the output should not contain "Fail 1.3.0"
90
- And the exit status should be 1
91
-
92
- Scenario: run a cleanup task
93
- When I run `bundle exec rake appraisal:cleanup --trace`
94
- Then a file named "gemfiles/1.3.0.gemfile" should not exist
95
- And a file named "gemfiles/1.3.0.gemfile.lock" should not exist
96
- And a file named "gemfiles/1.3.2.gemfile" should not exist
97
- And a file named "gemfiles/1.3.2.gemfile.lock" should not exist
98
-
99
- Scenario: install gems within groups
100
- Then the file "gemfiles/1.3.0.gemfile" should contain:
101
- """
102
- group :assets do
103
- gem "dummy_sass", "~> 3.1.0"
104
- end
105
- """
@@ -1,70 +0,0 @@
1
- @disable-bundler
2
- Feature: Bundler Gemfile Compatibility
3
-
4
- Scenario: Parsing Gemfile
5
- Given the following installed dummy gems:
6
- | name | version |
7
- | bacon | 1.0.0 |
8
- | bread | 1.0.0 |
9
- | miso_soup | 1.0.0 |
10
- | rice | 1.0.0 |
11
- And a git repository exists for gem "egg" with version "0.1.0"
12
- And I write to "Gemfile" with:
13
- """
14
- source "https://rubygems.org"
15
- ruby RUBY_VERSION
16
-
17
- git "./egg" do
18
- gem "egg"
19
- end
20
-
21
- group :breakfast do
22
- gem "bacon"
23
- end
24
- """
25
- And I add "appraisal" from this project as a dependency
26
- And I write to "Appraisals" with:
27
- """
28
- appraise "japanese" do
29
- gem "rice"
30
- gem "miso_soup"
31
- end
32
-
33
- appraise "english" do
34
- gem "bread"
35
- end
36
- """
37
- And I write to "Rakefile" with:
38
- """
39
- require 'rubygems'
40
- require 'bundler/setup'
41
- require 'appraisal'
42
- """
43
- When I successfully run `bundle install --local`
44
- And I successfully run `bundle exec rake appraisal:gemfiles --trace`
45
- Then the file "gemfiles/japanese.gemfile" should contain:
46
- """
47
- source "https://rubygems.org"
48
- """
49
- And the file "gemfiles/japanese.gemfile" should contain a correct ruby directive
50
- And the file "gemfiles/japanese.gemfile" should contain:
51
- """
52
- gem "rice"
53
- gem "miso_soup"
54
- """
55
- And the file "gemfiles/japanese.gemfile" should contain:
56
- """
57
- git "./egg" do
58
- gem "egg"
59
- end
60
- """
61
- And the file "gemfiles/japanese.gemfile" should contain:
62
- """
63
- group :breakfast do
64
- gem "bacon"
65
- end
66
- """
67
- And the file "gemfiles/english.gemfile" should contain:
68
- """
69
- gem "bread"
70
- """
@@ -1,68 +0,0 @@
1
- @disable-bundler
2
- Feature: appraisals using an existing gemspec
3
-
4
- Background:
5
- Given a directory named "gemspecced"
6
- And the following installed dummy gems:
7
- | name | version |
8
- | dummy_girl | 1.3.0 |
9
- | dummy_girl | 1.3.2 |
10
- When I cd to "gemspecced"
11
- And I write to "gemspecced.gemspec" with:
12
- """
13
- Gem::Specification.new do |s|
14
- s.name = %q{gemspecced}
15
- s.version = '0.1'
16
- s.summary = %q{featureful!}
17
-
18
- s.add_development_dependency('dummy_girl', '1.3.2')
19
- end
20
- """
21
- And a directory named "specdir"
22
- And I write to "specdir/gemspecced.gemspec" with:
23
- """
24
- Gem::Specification.new do |s|
25
- s.name = %q{gemspecced}
26
- s.version = '0.1'
27
- s.summary = %q{featureful!}
28
-
29
- s.add_development_dependency('dummy_girl', '1.3.0')
30
- end
31
- """
32
- And I write to "Appraisals" with:
33
- """
34
- appraise "stock" do
35
- gem "rake"
36
- end
37
- """
38
- When I write to "Rakefile" with:
39
- """
40
- require 'rubygems'
41
- require 'bundler/setup'
42
- require 'appraisal'
43
- task :version do
44
- require 'dummy_girl'
45
- puts "Loaded #{$dummy_girl_version}"
46
- end
47
- """
48
-
49
- Scenario: run a gem in the gemspec
50
- And I write to "Gemfile" with:
51
- """
52
- gemspec
53
- """
54
- When I add "appraisal" from this project as a dependency
55
- And I successfully run `bundle install --local`
56
- And I successfully run `bundle exec rake appraisal:install --trace`
57
- And I run `bundle exec rake appraisal version --trace`
58
- Then the output should contain "Loaded 1.3.2"
59
-
60
- Scenario: run a gem in the gemspec via path
61
- And I write to "Gemfile" with:
62
- """
63
- gemspec :path => './specdir'
64
- """
65
- When I add "appraisal" from this project as a dependency
66
- When I successfully run `bundle exec rake appraisal:install --trace`
67
- When I run `bundle exec rake appraisal version --trace`
68
- Then the output should contain "Loaded 1.3.0"
@@ -1,23 +0,0 @@
1
- @disable-bundler
2
- Feature: raise an exception when there is no Appraisal file
3
-
4
- Scenario: No Appraisal file
5
- Given a directory named "projecto"
6
- And the following installed dummy gems:
7
- | name | version |
8
- | dummy_girl | 1.3.0 |
9
- And I cd to "projecto"
10
- And I write to "Gemfile" with:
11
- """
12
- gem "dummy_girl"
13
- """
14
- And I add "appraisal" from this project as a dependency
15
- And I write to "Rakefile" with:
16
- """
17
- require 'rubygems'
18
- require 'bundler/setup'
19
- require 'appraisal'
20
- """
21
- And I successfully run `bundle install --local`
22
- When I run `bundle exec rake appraisal:install --trace`
23
- Then the output should contain "Unable to locate 'Appraisals' file in the current directory."
@@ -1,24 +0,0 @@
1
- When /^I add "([^"]*)" from this project as a dependency$/ do |gem_name|
2
- append_to_file('Gemfile', %{\ngem "#{gem_name}", :path => "#{PROJECT_ROOT}"})
3
- end
4
-
5
- Given /^the following installed dummy gems:$/ do |table|
6
- table.hashes.each { |hash| build_gem(hash["name"], hash["version"]) }
7
- end
8
-
9
- Given /^a git repository exists for gem "(.*?)" with version "(.*?)"$/ do |gem_name, version|
10
- build_gem(gem_name, version)
11
- cd gem_name
12
- run_simple 'git init .'
13
- run_simple 'git config user.email "appraisal@thoughtbot.com"'
14
- run_simple 'git config user.name "Appraisal"'
15
- run_simple 'git add .'
16
- run_simple 'git commit -a -m "initial commit"'
17
- dirs.pop
18
- end
19
-
20
- Then /^the file "(.*?)" should contain a correct ruby directive$/ do |filename|
21
- in_current_dir do
22
- File.read(filename).should match(/^ruby "#{RUBY_VERSION}"$/)
23
- end
24
- end
@@ -1,4 +0,0 @@
1
- Before do
2
- # Extend the timeout before Aruba will kill the process to 5 minutes.
3
- @aruba_timeout_seconds = 5 * 60 * 60
4
- end
@@ -1,11 +0,0 @@
1
- require 'aruba/cucumber'
2
-
3
- PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
4
- TMP_GEM_ROOT = File.join(PROJECT_ROOT, "tmp", "gems")
5
-
6
- Before do
7
- FileUtils.rm_rf(TMP_GEM_ROOT)
8
- FileUtils.mkdir_p(TMP_GEM_ROOT)
9
- end
10
-
11
- ENV["GEM_PATH"] = [TMP_GEM_ROOT, ENV["GEM_PATH"]].join(":")
@@ -1,233 +0,0 @@
1
- require 'spec_helper'
2
- require 'appraisal/utils'
3
-
4
- describe 'CLI' do
5
- context 'appraisal (with no arguments)' do
6
- it 'runs install command' do
7
- build_appraisal_file <<-Appraisal
8
- appraise '1.0.0' do
9
- gem 'dummy', '1.0.0'
10
- end
11
- Appraisal
12
-
13
- run_simple 'appraisal'
14
-
15
- expect(file 'gemfiles/1.0.0.gemfile').to be_exists
16
- expect(file 'gemfiles/1.0.0.gemfile.lock').to be_exists
17
- end
18
- end
19
-
20
- context 'appraisal (with arguments)' do
21
- before do
22
- build_appraisal_file <<-Appraisal
23
- appraise '1.0.0' do
24
- gem 'dummy', '1.0.0'
25
- end
26
-
27
- appraise '1.1.0' do
28
- gem 'dummy', '1.1.0'
29
- end
30
- Appraisal
31
-
32
- run_simple 'appraisal install'
33
- write_file 'test.rb', 'puts "Running: #{$dummy_version}"'
34
- end
35
-
36
- it 'sets APPRAISAL_INITIALIZED environment variable' do
37
- write_file 'test.rb', <<-TEST_FILE.strip_heredoc
38
- if ENV['APPRAISAL_INITIALIZED']
39
- puts "Appraisal initialized!"
40
- end
41
- TEST_FILE
42
-
43
- test_command = 'appraisal 1.0.0 ruby -rbundler/setup -rdummy test.rb'
44
- run_simple test_command
45
- expect(output_from test_command).to include 'Appraisal initialized!'
46
- end
47
-
48
- context 'with appraisal name' do
49
- it 'runs the given command against a correct versions of dependency' do
50
- test_command = 'appraisal 1.0.0 ruby -rbundler/setup -rdummy test.rb'
51
- run_simple test_command
52
-
53
- expect(output_from test_command).to include 'Running: 1.0.0'
54
- expect(output_from test_command).to_not include 'Running: 1.1.0'
55
- end
56
- end
57
-
58
- context 'without appraisal name' do
59
- it 'runs the given command against all versions of dependency' do
60
- test_command = 'appraisal ruby -rbundler/setup -rdummy test.rb'
61
- run_simple test_command
62
-
63
- expect(output_from test_command).to include 'Running: 1.0.0'
64
- expect(output_from test_command).to include 'Running: 1.1.0'
65
- end
66
- end
67
- end
68
-
69
- context 'appraisal generate' do
70
- it 'generates the gemfiles' do
71
- build_appraisal_file <<-Appraisal
72
- appraise '1.0.0' do
73
- gem 'dummy', '1.0.0'
74
- end
75
-
76
- appraise '1.1.0' do
77
- gem 'dummy', '1.1.0'
78
- end
79
- Appraisal
80
-
81
- run_simple 'appraisal generate'
82
-
83
- expect(file 'gemfiles/1.0.0.gemfile').to be_exists
84
- expect(file 'gemfiles/1.1.0.gemfile').to be_exists
85
- expect(content_of 'gemfiles/1.0.0.gemfile').to eq <<-gemfile.strip_heredoc
86
- # This file was generated by Appraisal
87
-
88
- source "https://rubygems.org"
89
-
90
- gem "appraisal", :path=>"#{PROJECT_ROOT}"
91
- gem "dummy", "1.0.0"
92
- gemfile
93
- end
94
- end
95
-
96
- context 'appraisal install' do
97
- it 'installs the dependencies' do
98
- build_appraisal_file <<-Appraisal
99
- appraise '1.0.0' do
100
- gem 'dummy', '1.0.0'
101
- end
102
-
103
- appraise '1.1.0' do
104
- gem 'dummy', '1.1.0'
105
- end
106
- Appraisal
107
-
108
- run_simple 'appraisal install'
109
-
110
- expect(file 'gemfiles/1.0.0.gemfile.lock').to be_exists
111
- expect(file 'gemfiles/1.1.0.gemfile.lock').to be_exists
112
- end
113
-
114
- it 'relativize directory in gemfile.lock' do
115
- build_gemspec
116
- add_gemspec_to_gemfile
117
- build_appraisal_file <<-Appraisal
118
- appraise '1.0.0' do
119
- gem 'dummy', '1.0.0'
120
- end
121
- Appraisal
122
-
123
- run_simple 'appraisal install'
124
-
125
- expect(content_of 'gemfiles/1.0.0.gemfile.lock').not_to include current_dir
126
- end
127
-
128
- context 'with job size', parallel: true do
129
- before do
130
- build_appraisal_file <<-Appraisal
131
- appraise '1.0.0' do
132
- gem 'dummy', '1.0.0'
133
- end
134
- Appraisal
135
- end
136
-
137
- it 'accepts --jobs option to set job size' do
138
- run_simple 'appraisal install --jobs=2'
139
-
140
- expect(output_from 'appraisal install --jobs=2').to include
141
- 'bundle install --gemfile=gemfiles/1.0.0.gemfile --jobs=2'
142
- end
143
-
144
- it 'ignores --jobs option if the job size is less than or equal to 1' do
145
- run_simple 'appraisal install --jobs=0'
146
-
147
- expect(output_from 'appraisal install --jobs=0').not_to include
148
- 'bundle install --gemfile=gemfiles/1.0.0.gemfile'
149
- expect(output_from 'appraisal install --jobs=0').not_to include
150
- 'bundle install --gemfile=gemfiles/1.0.0.gemfile --jobs=0'
151
- expect(output_from 'appraisal install --jobs=0').not_to include
152
- 'bundle install --gemfile=gemfiles/1.0.0.gemfile --jobs=1'
153
- end
154
- end
155
- end
156
-
157
- context 'appraisal clean' do
158
- it 'remove all gemfiles from gemfiles directory' do
159
- build_appraisal_file <<-Appraisal
160
- appraise '1.0.0' do
161
- gem 'dummy', '1.0.0'
162
- end
163
- Appraisal
164
-
165
- run_simple 'appraisal install'
166
- write_file 'gemfiles/non_related_file', ''
167
-
168
- run_simple 'appraisal clean'
169
-
170
- expect(file 'gemfiles/1.0.0.gemfile').not_to be_exists
171
- expect(file 'gemfiles/1.0.0.gemfile.lock').not_to be_exists
172
- expect(file 'gemfiles/non_related_file').to be_exists
173
- end
174
- end
175
-
176
- context 'appraisal update' do
177
- before do
178
- build_gem 'dummy2', '1.0.0'
179
-
180
- build_appraisal_file <<-Appraisal
181
- appraise 'dummy' do
182
- gem 'dummy', '~> 1.0.0'
183
- gem 'dummy2', '~> 1.0.0'
184
- end
185
- Appraisal
186
-
187
- run_simple 'appraisal install'
188
- build_gem 'dummy', '1.0.1'
189
- build_gem 'dummy2', '1.0.1'
190
- end
191
-
192
- after do
193
- in_current_dir do
194
- `gem uninstall dummy -v 1.0.1`
195
- `gem uninstall dummy2 -a`
196
- end
197
- end
198
-
199
- context 'with no arguments' do
200
- it 'updates all the gems' do
201
- run_simple 'appraisal update'
202
-
203
- expect(content_of 'gemfiles/dummy.gemfile.lock').to include 'dummy (1.0.1)'
204
- expect(content_of 'gemfiles/dummy.gemfile.lock').to include 'dummy2 (1.0.1)'
205
- end
206
- end
207
-
208
- context 'with a list of gems' do
209
- it 'only updates specified gems' do
210
- run_simple 'appraisal update dummy'
211
-
212
- expect(content_of 'gemfiles/dummy.gemfile.lock').to include 'dummy (1.0.1)'
213
- expect(content_of 'gemfiles/dummy.gemfile.lock').to include 'dummy2 (1.0.0)'
214
- end
215
- end
216
- end
217
-
218
- context 'appraisal help' do
219
- it 'prints usage along with commands, and list of appraisals' do
220
- build_appraisal_file <<-Appraisal
221
- appraise '1.0.0' do
222
- gem 'dummy', '1.0.0'
223
- end
224
- Appraisal
225
-
226
- run_simple 'appraisal help'
227
-
228
- expect(output_from 'appraisal help').to include 'Usage:'
229
- expect(output_from 'appraisal help').to include 'appraisal [APPRAISAL_NAME] EXTERNAL_COMMAND'
230
- expect(output_from 'appraisal help').to include '1.0.0'
231
- end
232
- end
233
- end