capistrano 3.3.5 → 3.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +5 -5
  2. data/.github/issue_template.md +19 -0
  3. data/.github/pull_request_template.md +22 -0
  4. data/.github/release-drafter.yml +17 -0
  5. data/.github/workflows/push.yml +12 -0
  6. data/.gitignore +8 -5
  7. data/.rubocop.yml +62 -0
  8. data/.travis.yml +25 -7
  9. data/CHANGELOG.md +1 -273
  10. data/CONTRIBUTING.md +63 -93
  11. data/DEVELOPMENT.md +127 -0
  12. data/Dangerfile +1 -0
  13. data/Gemfile +36 -3
  14. data/LICENSE.txt +1 -1
  15. data/README.md +118 -292
  16. data/RELEASING.md +17 -0
  17. data/Rakefile +9 -1
  18. data/UPGRADING-3.7.md +86 -0
  19. data/bin/cap +1 -1
  20. data/capistrano.gemspec +24 -24
  21. data/features/deploy.feature +35 -1
  22. data/features/doctor.feature +11 -0
  23. data/features/installation.feature +8 -3
  24. data/features/sshconnect.feature +11 -0
  25. data/features/stage_failure.feature +9 -0
  26. data/features/step_definitions/assertions.rb +57 -20
  27. data/features/step_definitions/cap_commands.rb +9 -0
  28. data/features/step_definitions/setup.rb +56 -8
  29. data/features/subdirectory.feature +9 -0
  30. data/features/support/env.rb +5 -5
  31. data/features/support/remote_command_helpers.rb +12 -6
  32. data/features/support/vagrant_helpers.rb +17 -11
  33. data/lib/Capfile +1 -1
  34. data/lib/capistrano/all.rb +10 -10
  35. data/lib/capistrano/application.rb +47 -34
  36. data/lib/capistrano/configuration.rb +95 -44
  37. data/lib/capistrano/configuration/empty_filter.rb +9 -0
  38. data/lib/capistrano/configuration/filter.rb +16 -46
  39. data/lib/capistrano/configuration/host_filter.rb +29 -0
  40. data/lib/capistrano/configuration/null_filter.rb +9 -0
  41. data/lib/capistrano/configuration/plugin_installer.rb +51 -0
  42. data/lib/capistrano/configuration/question.rb +31 -9
  43. data/lib/capistrano/configuration/role_filter.rb +29 -0
  44. data/lib/capistrano/configuration/scm_resolver.rb +149 -0
  45. data/lib/capistrano/configuration/server.rb +30 -62
  46. data/lib/capistrano/configuration/servers.rb +38 -12
  47. data/lib/capistrano/configuration/validated_variables.rb +110 -0
  48. data/lib/capistrano/configuration/variables.rb +112 -0
  49. data/lib/capistrano/defaults.rb +26 -4
  50. data/lib/capistrano/deploy.rb +1 -2
  51. data/lib/capistrano/doctor.rb +6 -0
  52. data/lib/capistrano/doctor/environment_doctor.rb +19 -0
  53. data/lib/capistrano/doctor/gems_doctor.rb +45 -0
  54. data/lib/capistrano/doctor/output_helpers.rb +79 -0
  55. data/lib/capistrano/doctor/servers_doctor.rb +105 -0
  56. data/lib/capistrano/doctor/variables_doctor.rb +72 -0
  57. data/lib/capistrano/dotfile.rb +1 -2
  58. data/lib/capistrano/dsl.rb +49 -18
  59. data/lib/capistrano/dsl/env.rb +16 -46
  60. data/lib/capistrano/dsl/paths.rb +11 -25
  61. data/lib/capistrano/dsl/stages.rb +14 -2
  62. data/lib/capistrano/dsl/task_enhancements.rb +7 -12
  63. data/lib/capistrano/framework.rb +1 -1
  64. data/lib/capistrano/i18n.rb +32 -24
  65. data/lib/capistrano/immutable_task.rb +30 -0
  66. data/lib/capistrano/install.rb +1 -1
  67. data/lib/capistrano/plugin.rb +95 -0
  68. data/lib/capistrano/proc_helpers.rb +13 -0
  69. data/lib/capistrano/scm.rb +7 -20
  70. data/lib/capistrano/scm/git.rb +100 -0
  71. data/lib/capistrano/scm/hg.rb +55 -0
  72. data/lib/capistrano/scm/plugin.rb +13 -0
  73. data/lib/capistrano/scm/svn.rb +56 -0
  74. data/lib/capistrano/scm/tasks/git.rake +73 -0
  75. data/lib/capistrano/scm/tasks/hg.rake +53 -0
  76. data/lib/capistrano/scm/tasks/svn.rake +53 -0
  77. data/lib/capistrano/setup.rb +20 -6
  78. data/lib/capistrano/tasks/console.rake +4 -8
  79. data/lib/capistrano/tasks/deploy.rake +105 -74
  80. data/lib/capistrano/tasks/doctor.rake +24 -0
  81. data/lib/capistrano/tasks/framework.rake +13 -14
  82. data/lib/capistrano/tasks/install.rake +14 -15
  83. data/lib/capistrano/templates/Capfile +22 -11
  84. data/lib/capistrano/templates/deploy.rb.erb +18 -27
  85. data/lib/capistrano/templates/stage.rb.erb +36 -20
  86. data/lib/capistrano/upload_task.rb +1 -1
  87. data/lib/capistrano/version.rb +1 -1
  88. data/lib/capistrano/version_validator.rb +5 -10
  89. data/spec/integration/dsl_spec.rb +311 -289
  90. data/spec/integration_spec_helper.rb +3 -5
  91. data/spec/lib/capistrano/application_spec.rb +23 -39
  92. data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
  93. data/spec/lib/capistrano/configuration/filter_spec.rb +83 -79
  94. data/spec/lib/capistrano/configuration/host_filter_spec.rb +71 -0
  95. data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
  96. data/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
  97. data/spec/lib/capistrano/configuration/question_spec.rb +58 -26
  98. data/spec/lib/capistrano/configuration/role_filter_spec.rb +80 -0
  99. data/spec/lib/capistrano/configuration/scm_resolver_spec.rb +55 -0
  100. data/spec/lib/capistrano/configuration/server_spec.rb +124 -100
  101. data/spec/lib/capistrano/configuration/servers_spec.rb +143 -123
  102. data/spec/lib/capistrano/configuration_spec.rb +231 -59
  103. data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
  104. data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +67 -0
  105. data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
  106. data/spec/lib/capistrano/doctor/servers_doctor_spec.rb +86 -0
  107. data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +89 -0
  108. data/spec/lib/capistrano/dsl/paths_spec.rb +201 -42
  109. data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +57 -37
  110. data/spec/lib/capistrano/dsl_spec.rb +84 -11
  111. data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
  112. data/spec/lib/capistrano/plugin_spec.rb +84 -0
  113. data/spec/lib/capistrano/scm/git_spec.rb +184 -0
  114. data/spec/lib/capistrano/scm/hg_spec.rb +109 -0
  115. data/spec/lib/capistrano/scm/svn_spec.rb +137 -0
  116. data/spec/lib/capistrano/scm_spec.rb +7 -8
  117. data/spec/lib/capistrano/upload_task_spec.rb +7 -7
  118. data/spec/lib/capistrano/version_validator_spec.rb +61 -46
  119. data/spec/lib/capistrano_spec.rb +2 -3
  120. data/spec/spec_helper.rb +21 -8
  121. data/spec/support/Vagrantfile +18 -8
  122. data/spec/support/tasks/database.rake +3 -3
  123. data/spec/support/tasks/fail.rake +4 -3
  124. data/spec/support/tasks/failed.rake +2 -2
  125. data/spec/support/tasks/plugin.rake +6 -0
  126. data/spec/support/tasks/root.rake +11 -0
  127. data/spec/support/test_app.rb +63 -39
  128. metadata +121 -44
  129. data/features/remote_file_task.feature +0 -14
  130. data/lib/capistrano/git.rb +0 -46
  131. data/lib/capistrano/hg.rb +0 -43
  132. data/lib/capistrano/svn.rb +0 -38
  133. data/lib/capistrano/tasks/git.rake +0 -81
  134. data/lib/capistrano/tasks/hg.rake +0 -52
  135. data/lib/capistrano/tasks/svn.rake +0 -52
  136. data/spec/lib/capistrano/git_spec.rb +0 -81
  137. data/spec/lib/capistrano/hg_spec.rb +0 -81
  138. data/spec/lib/capistrano/svn_spec.rb +0 -79
@@ -0,0 +1,109 @@
1
+ require "spec_helper"
2
+
3
+ require "capistrano/scm/hg"
4
+
5
+ module Capistrano
6
+ describe SCM::Hg do
7
+ subject { Capistrano::SCM::Hg.new }
8
+
9
+ # This allows us to easily use `set`, `fetch`, etc. in the examples.
10
+ let(:env) { Capistrano::Configuration.env }
11
+
12
+ # Stub the SSHKit backend so we can set up expectations without the plugin
13
+ # actually executing any commands.
14
+ let(:backend) { stub }
15
+ before { SSHKit::Backend.stubs(:current).returns(backend) }
16
+
17
+ # Mimic the deploy flow tasks so that the plugin can register its hooks.
18
+ before do
19
+ Rake::Task.define_task("deploy:new_release_path")
20
+ Rake::Task.define_task("deploy:check")
21
+ Rake::Task.define_task("deploy:set_current_revision")
22
+ end
23
+
24
+ # Clean up any tasks or variables that the plugin defined.
25
+ after do
26
+ Rake::Task.clear
27
+ Capistrano::Configuration.reset!
28
+ end
29
+
30
+ describe "#hg" do
31
+ it "should call execute hg in the context, with arguments" do
32
+ backend.expects(:execute).with(:hg, :init)
33
+ subject.hg(:init)
34
+ end
35
+ end
36
+
37
+ describe "#repo_mirror_exists?" do
38
+ it "should call test for repo HEAD" do
39
+ env.set(:repo_path, "/path/to/repo")
40
+ backend.expects(:test).with " [ -d /path/to/repo/.hg ] "
41
+
42
+ subject.repo_mirror_exists?
43
+ end
44
+ end
45
+
46
+ describe "#check_repo_is_reachable" do
47
+ it "should test the repo url" do
48
+ env.set(:repo_url, :url)
49
+ backend.expects(:execute).with(:hg, "id", :url)
50
+
51
+ subject.check_repo_is_reachable
52
+ end
53
+ end
54
+
55
+ describe "#clone_repo" do
56
+ it "should run hg clone" do
57
+ env.set(:repo_url, :url)
58
+ env.set(:repo_path, "path")
59
+
60
+ backend.expects(:execute).with(:hg, "clone", "--noupdate", :url, "path")
61
+
62
+ subject.clone_repo
63
+ end
64
+ end
65
+
66
+ describe "#update_mirror" do
67
+ it "should run hg update" do
68
+ backend.expects(:execute).with(:hg, "pull")
69
+
70
+ subject.update_mirror
71
+ end
72
+ end
73
+
74
+ describe "#archive_to_release_path" do
75
+ it "should run hg archive without a subtree" do
76
+ env.set(:branch, :branch)
77
+ env.set(:release_path, "path")
78
+
79
+ backend.expects(:execute).with(:hg, "archive", "path", "--rev", :branch)
80
+
81
+ subject.archive_to_release_path
82
+ end
83
+
84
+ it "should run hg archive with a subtree" do
85
+ env.set(:repo_tree, "tree")
86
+ env.set(:branch, :branch)
87
+ env.set(:release_path, "path")
88
+ env.set(:tmp_dir, "/tmp")
89
+
90
+ SecureRandom.stubs(:hex).with(10).returns("random")
91
+ backend.expects(:execute).with(:hg, "archive -p . -I", "tree", "--rev", :branch, "/tmp/random.tar")
92
+ backend.expects(:execute).with(:mkdir, "-p", "path")
93
+ backend.expects(:execute).with(:tar, "-x --strip-components 1 -f", "/tmp/random.tar", "-C", "path")
94
+ backend.expects(:execute).with(:rm, "/tmp/random.tar")
95
+
96
+ subject.archive_to_release_path
97
+ end
98
+ end
99
+
100
+ describe "#fetch_revision" do
101
+ it "should capture hg log" do
102
+ env.set(:branch, :branch)
103
+ backend.expects(:capture).with(:hg, "log --rev branch --template \"{node}\n\"").returns("01abcde")
104
+ revision = subject.fetch_revision
105
+ expect(revision).to eq("01abcde")
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,137 @@
1
+ require "spec_helper"
2
+
3
+ require "capistrano/scm/svn"
4
+
5
+ module Capistrano
6
+ describe SCM::Svn do
7
+ subject { Capistrano::SCM::Svn.new }
8
+
9
+ # This allows us to easily use `set`, `fetch`, etc. in the examples.
10
+ let(:env) { Capistrano::Configuration.env }
11
+
12
+ # Stub the SSHKit backend so we can set up expectations without the plugin
13
+ # actually executing any commands.
14
+ let(:backend) { stub }
15
+ before { SSHKit::Backend.stubs(:current).returns(backend) }
16
+
17
+ # Mimic the deploy flow tasks so that the plugin can register its hooks.
18
+ before do
19
+ Rake::Task.define_task("deploy:new_release_path")
20
+ Rake::Task.define_task("deploy:check")
21
+ Rake::Task.define_task("deploy:set_current_revision")
22
+ end
23
+
24
+ # Clean up any tasks or variables that the plugin defined.
25
+ after do
26
+ Rake::Task.clear
27
+ Capistrano::Configuration.reset!
28
+ end
29
+
30
+ describe "#svn" do
31
+ it "should call execute svn in the context, with arguments" do
32
+ env.set(:svn_username, "someuser")
33
+ env.set(:svn_password, "somepassword")
34
+ backend.expects(:execute).with(:svn, :init, "--username someuser", "--password somepassword")
35
+ subject.svn(:init)
36
+ end
37
+ end
38
+
39
+ describe "#repo_mirror_exists?" do
40
+ it "should call test for repo HEAD" do
41
+ env.set(:repo_path, "/path/to/repo")
42
+ backend.expects(:test).with " [ -d /path/to/repo/.svn ] "
43
+
44
+ subject.repo_mirror_exists?
45
+ end
46
+ end
47
+
48
+ describe "#check_repo_is_reachable" do
49
+ it "should test the repo url" do
50
+ env.set(:repo_url, :url)
51
+ env.set(:svn_username, "someuser")
52
+ env.set(:svn_password, "somepassword")
53
+ backend.expects(:test).with(:svn, :info, :url, "--username someuser", "--password somepassword").returns(true)
54
+
55
+ subject.check_repo_is_reachable
56
+ end
57
+ end
58
+
59
+ describe "#clone_repo" do
60
+ it "should run svn checkout" do
61
+ env.set(:repo_url, :url)
62
+ env.set(:repo_path, "path")
63
+ env.set(:svn_username, "someuser")
64
+ env.set(:svn_password, "somepassword")
65
+
66
+ backend.expects(:execute).with(:svn, :checkout, :url, "path", "--username someuser", "--password somepassword")
67
+
68
+ subject.clone_repo
69
+ end
70
+ end
71
+
72
+ describe "#update_mirror" do
73
+ it "should run svn update" do
74
+ env.set(:repo_url, "url")
75
+ env.set(:repo_path, "path")
76
+ backend.expects(:capture).with(:svn, :info, "path").returns("URL: url\n")
77
+
78
+ env.set(:svn_username, "someuser")
79
+ env.set(:svn_password, "somepassword")
80
+ backend.expects(:execute).with(:svn, :update, "--username someuser", "--password somepassword")
81
+
82
+ subject.update_mirror
83
+ end
84
+
85
+ context "for specific revision" do
86
+ it "should run svn update" do
87
+ env.set(:repo_url, "url")
88
+ env.set(:repo_path, "path")
89
+ backend.expects(:capture).with(:svn, :info, "path").returns("URL: url\n")
90
+
91
+ env.set(:svn_username, "someuser")
92
+ env.set(:svn_password, "somepassword")
93
+ env.set(:svn_revision, "12345")
94
+ backend.expects(:execute).with(:svn, :update, "--username someuser", "--password somepassword", "--revision 12345")
95
+
96
+ subject.update_mirror
97
+ end
98
+ end
99
+
100
+ it "should run svn switch if repo_url is changed" do
101
+ env.set(:repo_url, "url")
102
+ env.set(:repo_path, "path")
103
+ backend.expects(:capture).with(:svn, :info, "path").returns("URL: old_url\n")
104
+
105
+ env.set(:svn_username, "someuser")
106
+ env.set(:svn_password, "somepassword")
107
+ backend.expects(:execute).with(:svn, :switch, "url", "--username someuser", "--password somepassword")
108
+ backend.expects(:execute).with(:svn, :update, "--username someuser", "--password somepassword")
109
+
110
+ subject.update_mirror
111
+ end
112
+ end
113
+
114
+ describe "#archive_to_release_path" do
115
+ it "should run svn export" do
116
+ env.set(:release_path, "path")
117
+ env.set(:svn_username, "someuser")
118
+ env.set(:svn_password, "somepassword")
119
+
120
+ backend.expects(:execute).with(:svn, :export, "--force", ".", "path", "--username someuser", "--password somepassword")
121
+
122
+ subject.archive_to_release_path
123
+ end
124
+ end
125
+
126
+ describe "#fetch_revision" do
127
+ it "should capture svn version" do
128
+ env.set(:repo_path, "path")
129
+
130
+ backend.expects(:capture).with(:svnversion, "path").returns("12345")
131
+
132
+ revision = subject.fetch_revision
133
+ expect(revision).to eq("12345")
134
+ end
135
+ end
136
+ end
137
+ end
@@ -1,13 +1,13 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- require 'capistrano/scm'
3
+ require "capistrano/scm"
4
4
 
5
5
  module RaiseNotImplementedMacro
6
6
  def raise_not_implemented_on(method)
7
7
  it "should raise NotImplemented on #{method}" do
8
- expect {
8
+ expect do
9
9
  subject.send(method)
10
- }.to raise_error(NotImplementedError)
10
+ end.to raise_error(NotImplementedError)
11
11
  end
12
12
  end
13
13
  end
@@ -26,7 +26,7 @@ module BlindStrategy; end
26
26
 
27
27
  module Capistrano
28
28
  describe SCM do
29
- let(:context) { Class.new.new }
29
+ let(:context) { mock }
30
30
 
31
31
  describe "#initialize" do
32
32
  subject { Capistrano::SCM.new(context, DummyStrategy) }
@@ -63,8 +63,8 @@ module Capistrano
63
63
 
64
64
  describe "#release_path" do
65
65
  it "should return the release path according to the context" do
66
- context.expects(:release_path).returns('/path/to/nowhere')
67
- expect(subject.release_path).to eq('/path/to/nowhere')
66
+ context.expects(:release_path).returns("/path/to/nowhere")
67
+ expect(subject.release_path).to eq("/path/to/nowhere")
68
68
  end
69
69
  end
70
70
 
@@ -101,4 +101,3 @@ module Capistrano
101
101
  end
102
102
  end
103
103
  end
104
-
@@ -1,19 +1,19 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Capistrano::UploadTask do
4
4
  let(:app) { Rake.application = Rake::Application.new }
5
5
 
6
- subject(:upload_task) { described_class.define_task('path/file.yml') }
6
+ subject(:upload_task) { described_class.define_task("path/file.yml") }
7
7
 
8
8
  it { is_expected.to be_a(Rake::FileCreationTask) }
9
9
  it { is_expected.to be_needed }
10
10
 
11
- context 'inside namespace' do
12
- let(:normal_task) { Rake::Task.define_task('path/other_file.yml') }
11
+ context "inside namespace" do
12
+ let(:normal_task) { Rake::Task.define_task("path/other_file.yml") }
13
13
 
14
- around { |ex| app.in_namespace('namespace', &ex) }
14
+ around { |ex| app.in_namespace("namespace", &ex) }
15
15
 
16
- it { expect(upload_task.name).to eq('path/file.yml') }
17
- it { expect(upload_task.scope.path).to eq('namespace') }
16
+ it { expect(upload_task.name).to eq("path/file.yml") }
17
+ it { expect(upload_task.scope.path).to eq("namespace") }
18
18
  end
19
19
  end
@@ -1,19 +1,18 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Capistrano
4
-
5
4
  describe VersionValidator do
6
5
  let(:validator) { VersionValidator.new(version) }
7
6
  let(:version) { stub }
8
7
 
9
- describe '#new' do
10
- it 'takes a version' do
8
+ describe "#new" do
9
+ it "takes a version" do
11
10
  expect(validator)
12
11
  end
13
12
  end
14
13
 
15
- describe '#verify' do
16
- let(:current_version) { '3.0.1' }
14
+ describe "#verify" do
15
+ let(:current_version) { "3.0.1" }
17
16
 
18
17
  subject { validator.verify }
19
18
 
@@ -21,83 +20,99 @@ module Capistrano
21
20
  validator.stubs(:current_version).returns(current_version)
22
21
  end
23
22
 
24
- context 'with exact version' do
25
- context 'valid' do
26
- let(:version) { '3.0.1' }
23
+ context "with exact version" do
24
+ context "valid" do
25
+ let(:version) { "3.0.1" }
27
26
  it { expect(subject).to be_truthy }
28
27
  end
29
28
 
30
- context 'invalid - lower' do
31
- let(:version) { '3.0.0' }
29
+ context "invalid - lower" do
30
+ let(:version) { "3.0.0" }
32
31
 
33
- it 'fails' do
34
- expect { subject }.to raise_error
32
+ it "fails" do
33
+ expect { subject }.to raise_error(RuntimeError)
35
34
  end
36
35
  end
37
36
 
38
- context 'invalid - higher' do
39
- let(:version) { '3.0.2' }
37
+ context "invalid - higher" do
38
+ let(:version) { "3.0.2" }
40
39
 
41
- it 'fails' do
42
- expect { subject }.to raise_error
40
+ it "fails" do
41
+ expect { subject }.to raise_error(RuntimeError)
43
42
  end
44
43
  end
45
-
46
44
  end
47
45
 
48
- context 'with optimistic versioning' do
49
- context 'valid' do
50
- let(:version) { '>= 3.0.0' }
46
+ context "with optimistic versioning" do
47
+ context "valid" do
48
+ let(:version) { ">= 3.0.0" }
51
49
  it { expect(subject).to be_truthy }
52
50
  end
53
51
 
54
- context 'invalid - lower' do
55
- let(:version) { '<= 2.0.0' }
52
+ context "invalid - lower" do
53
+ let(:version) { "<= 2.0.0" }
56
54
 
57
- it 'fails' do
58
- expect { subject }.to raise_error
55
+ it "fails" do
56
+ expect { subject }.to raise_error(RuntimeError)
59
57
  end
60
58
  end
61
59
  end
62
60
 
63
-
64
-
65
- context 'with pessimistic versioning' do
66
- context '2 decimal places' do
67
- context 'valid' do
68
- let(:version) { '~> 3.0.0' }
61
+ context "with pessimistic versioning" do
62
+ context "2 decimal places" do
63
+ context "valid" do
64
+ let(:version) { "~> 3.0.0" }
69
65
  it { expect(subject).to be_truthy }
70
66
  end
71
67
 
72
- context 'invalid' do
73
- let(:version) { '~> 3.1.0' }
68
+ context "invalid" do
69
+ let(:version) { "~> 3.1.0" }
74
70
 
75
- it 'fails' do
76
- expect { subject }.to raise_error
71
+ it "fails" do
72
+ expect { subject }.to raise_error(RuntimeError)
77
73
  end
78
74
  end
79
75
  end
80
76
 
81
- context '1 decimal place' do
82
- let(:current_version) { '3.5.0' }
77
+ context "1 decimal place" do
78
+ let(:current_version) { "3.5.0" }
83
79
 
84
- context 'valid' do
85
- let(:version) { '~> 3.1' }
80
+ context "valid" do
81
+ let(:version) { "~> 3.1" }
86
82
  it { expect(subject).to be_truthy }
87
83
  end
88
84
 
89
- context 'invalid' do
90
- let(:version) { '~> 3.6' }
91
- it 'fails' do
92
- expect { subject }.to raise_error
85
+ context "invalid" do
86
+ let(:version) { "~> 3.6" }
87
+ it "fails" do
88
+ expect { subject }.to raise_error(RuntimeError)
93
89
  end
94
90
  end
95
91
  end
96
92
 
97
- end
93
+ context "with multiple versions" do
94
+ let(:current_version) { "3.5.9" }
98
95
 
99
- end
96
+ context "valid" do
97
+ let(:version) { [">= 3.5.0", "< 3.5.10"] }
98
+ it { is_expected.to be_truthy }
99
+ end
100
100
 
101
- end
101
+ context "invalid" do
102
+ let(:version) { [">= 3.5.0", "< 3.5.8"] }
103
+ it "fails" do
104
+ expect { subject }.to raise_error(RuntimeError)
105
+ end
106
+ end
102
107
 
108
+ context "invalid" do
109
+ let(:version) { ["> 3.5.9", "< 3.5.13"] }
110
+ it "fails" do
111
+ expect { subject }.to raise_error(RuntimeError)
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
103
118
  end