capistrano 3.4.0 → 3.17.1

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/.circleci/config.yml +129 -0
  3. data/.github/issue_template.md +19 -0
  4. data/.github/pull_request_template.md +22 -0
  5. data/.github/release-drafter.yml +17 -0
  6. data/.github/workflows/push.yml +12 -0
  7. data/.gitignore +8 -5
  8. data/.rubocop.yml +62 -0
  9. data/CHANGELOG.md +1 -307
  10. data/CONTRIBUTING.md +63 -93
  11. data/DEVELOPMENT.md +127 -0
  12. data/Dangerfile +1 -0
  13. data/Gemfile +40 -3
  14. data/LICENSE.txt +1 -1
  15. data/README.md +127 -44
  16. data/RELEASING.md +17 -0
  17. data/Rakefile +13 -2
  18. data/UPGRADING-3.7.md +86 -0
  19. data/bin/cap +1 -1
  20. data/capistrano.gemspec +21 -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/stage_failure.feature +9 -0
  25. data/features/step_definitions/assertions.rb +51 -18
  26. data/features/step_definitions/cap_commands.rb +9 -0
  27. data/features/step_definitions/setup.rb +53 -9
  28. data/features/subdirectory.feature +9 -0
  29. data/features/support/env.rb +5 -5
  30. data/features/support/remote_command_helpers.rb +12 -6
  31. data/features/support/vagrant_helpers.rb +17 -11
  32. data/lib/Capfile +1 -1
  33. data/lib/capistrano/all.rb +10 -10
  34. data/lib/capistrano/application.rb +47 -34
  35. data/lib/capistrano/configuration/empty_filter.rb +9 -0
  36. data/lib/capistrano/configuration/filter.rb +17 -47
  37. data/lib/capistrano/configuration/host_filter.rb +29 -0
  38. data/lib/capistrano/configuration/null_filter.rb +9 -0
  39. data/lib/capistrano/configuration/plugin_installer.rb +51 -0
  40. data/lib/capistrano/configuration/question.rb +31 -9
  41. data/lib/capistrano/configuration/role_filter.rb +29 -0
  42. data/lib/capistrano/configuration/scm_resolver.rb +149 -0
  43. data/lib/capistrano/configuration/server.rb +29 -23
  44. data/lib/capistrano/configuration/servers.rb +21 -14
  45. data/lib/capistrano/configuration/validated_variables.rb +110 -0
  46. data/lib/capistrano/configuration/variables.rb +112 -0
  47. data/lib/capistrano/configuration.rb +91 -44
  48. data/lib/capistrano/defaults.rb +26 -4
  49. data/lib/capistrano/deploy.rb +1 -1
  50. data/lib/capistrano/doctor/environment_doctor.rb +19 -0
  51. data/lib/capistrano/doctor/gems_doctor.rb +45 -0
  52. data/lib/capistrano/doctor/output_helpers.rb +79 -0
  53. data/lib/capistrano/doctor/servers_doctor.rb +105 -0
  54. data/lib/capistrano/doctor/variables_doctor.rb +74 -0
  55. data/lib/capistrano/doctor.rb +6 -0
  56. data/lib/capistrano/dotfile.rb +1 -2
  57. data/lib/capistrano/dsl/env.rb +9 -47
  58. data/lib/capistrano/dsl/paths.rb +11 -25
  59. data/lib/capistrano/dsl/stages.rb +14 -2
  60. data/lib/capistrano/dsl/task_enhancements.rb +7 -12
  61. data/lib/capistrano/dsl.rb +47 -16
  62. data/lib/capistrano/framework.rb +1 -1
  63. data/lib/capistrano/i18n.rb +32 -24
  64. data/lib/capistrano/immutable_task.rb +30 -0
  65. data/lib/capistrano/install.rb +1 -1
  66. data/lib/capistrano/plugin.rb +95 -0
  67. data/lib/capistrano/proc_helpers.rb +13 -0
  68. data/lib/capistrano/scm/git.rb +100 -0
  69. data/lib/capistrano/scm/hg.rb +55 -0
  70. data/lib/capistrano/scm/plugin.rb +13 -0
  71. data/lib/capistrano/scm/svn.rb +56 -0
  72. data/lib/capistrano/scm/tasks/git.rake +73 -0
  73. data/lib/capistrano/scm/tasks/hg.rake +53 -0
  74. data/lib/capistrano/scm/tasks/svn.rake +53 -0
  75. data/lib/capistrano/scm.rb +7 -20
  76. data/lib/capistrano/setup.rb +20 -6
  77. data/lib/capistrano/tasks/console.rake +4 -8
  78. data/lib/capistrano/tasks/deploy.rake +105 -73
  79. data/lib/capistrano/tasks/doctor.rake +24 -0
  80. data/lib/capistrano/tasks/framework.rake +13 -14
  81. data/lib/capistrano/tasks/install.rake +14 -15
  82. data/lib/capistrano/templates/Capfile +21 -10
  83. data/lib/capistrano/templates/deploy.rb.erb +17 -26
  84. data/lib/capistrano/templates/stage.rb.erb +9 -9
  85. data/lib/capistrano/upload_task.rb +1 -1
  86. data/lib/capistrano/version.rb +1 -1
  87. data/lib/capistrano/version_validator.rb +5 -10
  88. data/spec/integration/dsl_spec.rb +289 -240
  89. data/spec/integration_spec_helper.rb +3 -5
  90. data/spec/lib/capistrano/application_spec.rb +23 -39
  91. data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
  92. data/spec/lib/capistrano/configuration/filter_spec.rb +83 -85
  93. data/spec/lib/capistrano/configuration/host_filter_spec.rb +71 -0
  94. data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
  95. data/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
  96. data/spec/lib/capistrano/configuration/question_spec.rb +58 -26
  97. data/spec/lib/capistrano/configuration/role_filter_spec.rb +80 -0
  98. data/spec/lib/capistrano/configuration/scm_resolver_spec.rb +55 -0
  99. data/spec/lib/capistrano/configuration/server_spec.rb +106 -113
  100. data/spec/lib/capistrano/configuration/servers_spec.rb +129 -145
  101. data/spec/lib/capistrano/configuration_spec.rb +224 -63
  102. data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
  103. data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +67 -0
  104. data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
  105. data/spec/lib/capistrano/doctor/servers_doctor_spec.rb +86 -0
  106. data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +89 -0
  107. data/spec/lib/capistrano/dsl/paths_spec.rb +97 -59
  108. data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +57 -37
  109. data/spec/lib/capistrano/dsl_spec.rb +84 -11
  110. data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
  111. data/spec/lib/capistrano/plugin_spec.rb +84 -0
  112. data/spec/lib/capistrano/scm/git_spec.rb +184 -0
  113. data/spec/lib/capistrano/scm/hg_spec.rb +109 -0
  114. data/spec/lib/capistrano/scm/svn_spec.rb +137 -0
  115. data/spec/lib/capistrano/scm_spec.rb +7 -8
  116. data/spec/lib/capistrano/upload_task_spec.rb +7 -7
  117. data/spec/lib/capistrano/version_validator_spec.rb +61 -46
  118. data/spec/lib/capistrano_spec.rb +2 -3
  119. data/spec/spec_helper.rb +21 -8
  120. data/spec/support/Vagrantfile +9 -10
  121. data/spec/support/tasks/database.rake +3 -3
  122. data/spec/support/tasks/fail.rake +4 -3
  123. data/spec/support/tasks/failed.rake +2 -2
  124. data/spec/support/tasks/plugin.rake +6 -0
  125. data/spec/support/tasks/root.rake +4 -4
  126. data/spec/support/test_app.rb +64 -39
  127. metadata +100 -55
  128. data/.travis.yml +0 -13
  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,80 @@
1
+ require "spec_helper"
2
+
3
+ module Capistrano
4
+ class Configuration
5
+ describe RoleFilter do
6
+ subject(:role_filter) { RoleFilter.new(values) }
7
+
8
+ let(:available) do
9
+ [
10
+ Server.new("server1").add_roles(%i(web db)),
11
+ Server.new("server2").add_role(:web),
12
+ Server.new("server3").add_role(:redis),
13
+ Server.new("server4").add_role(:db),
14
+ Server.new("server5").add_role(:stageweb),
15
+ Server.new("server6").add_role(:"db.new")
16
+ ]
17
+ end
18
+
19
+ shared_examples "it filters roles correctly" do |expected_size, expected|
20
+ it "filters correctly" do
21
+ set = role_filter.filter(available)
22
+ expect(set.size).to eq(expected_size)
23
+ expect(set.map(&:hostname)).to eq(expected)
24
+ end
25
+ end
26
+
27
+ describe "#filter" do
28
+ context "with a single role string" do
29
+ let(:values) { "web" }
30
+ it_behaves_like "it filters roles correctly", 2, %w{server1 server2}
31
+ end
32
+
33
+ context "with a single role" do
34
+ let(:values) { [:web] }
35
+ it_behaves_like "it filters roles correctly", 2, %w{server1 server2}
36
+ end
37
+
38
+ context "with multiple roles in a string" do
39
+ let(:values) { "web,db" }
40
+ it_behaves_like "it filters roles correctly", 3, %w{server1 server2 server4}
41
+ end
42
+
43
+ context "with multiple roles" do
44
+ let(:values) { %i(web db) }
45
+ it_behaves_like "it filters roles correctly", 3, %w{server1 server2 server4}
46
+ end
47
+
48
+ context "with a regex" do
49
+ let(:values) { /red/ }
50
+ it_behaves_like "it filters roles correctly", 1, %w{server3}
51
+ end
52
+
53
+ context "with a regex string" do
54
+ let(:values) { "/red|web/" }
55
+ it_behaves_like "it filters roles correctly", 4, %w{server1 server2 server3 server5}
56
+ end
57
+
58
+ context "with both a string and regex" do
59
+ let(:values) { "db,/red/" }
60
+ it_behaves_like "it filters roles correctly", 3, %w{server1 server3 server4}
61
+ end
62
+
63
+ context "with a dot wildcard" do
64
+ let(:values) { "db.*" }
65
+ it_behaves_like "it filters roles correctly", 0, %w{}
66
+ end
67
+
68
+ context "with a dot" do
69
+ let(:values) { "db.new" }
70
+ it_behaves_like "it filters roles correctly", 1, %w{server6}
71
+ end
72
+
73
+ context "with a dot wildcard regex" do
74
+ let(:values) { "/db.*/" }
75
+ it_behaves_like "it filters roles correctly", 3, %w{server1 server4 server6}
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,55 @@
1
+ require "spec_helper"
2
+ require "capistrano/scm"
3
+
4
+ module Capistrano
5
+ class Configuration
6
+ describe SCMResolver do
7
+ include Capistrano::DSL
8
+
9
+ let(:resolver) { SCMResolver.new }
10
+
11
+ before do
12
+ Rake::Task.define_task("deploy:check")
13
+ Rake::Task.define_task("deploy:new_release_path")
14
+ Rake::Task.define_task("deploy:set_current_revision")
15
+ set :scm, SCMResolver::DEFAULT_GIT
16
+ end
17
+
18
+ after do
19
+ Rake::Task.clear
20
+ Capistrano::Configuration.reset!
21
+ end
22
+
23
+ context "default scm, no plugin installed" do
24
+ it "emits a warning" do
25
+ expect { resolver.resolve }.to output(/will not load the git scm/i).to_stderr
26
+ end
27
+
28
+ it "activates the git scm", capture_io: true do
29
+ resolver.resolve
30
+ expect(Rake::Task["git:wrapper"]).not_to be_nil
31
+ end
32
+
33
+ it "sets :scm to :git", capture_io: true do
34
+ resolver.resolve
35
+ expect(fetch(:scm)).to eq(:git)
36
+ end
37
+ end
38
+
39
+ context "default scm, git plugin installed" do
40
+ before do
41
+ install_plugin Capistrano::SCM::Git
42
+ end
43
+
44
+ it "emits no warning" do
45
+ expect { resolver.resolve }.not_to output.to_stderr
46
+ end
47
+
48
+ it "deletes :scm" do
49
+ resolver.resolve
50
+ expect(fetch(:scm)).to be_nil
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,141 +1,139 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Capistrano
4
4
  class Configuration
5
5
  describe Server do
6
- let(:server) { Server.new('root@hostname:1234') }
6
+ let(:server) { Server.new("root@hostname:1234") }
7
7
 
8
- describe 'adding a role' do
8
+ describe "adding a role" do
9
9
  subject { server.add_role(:test) }
10
- it 'adds the role' do
11
- expect{subject}.to change{server.roles.size}.from(0).to(1)
10
+ it "adds the role" do
11
+ expect { subject }.to change { server.roles.size }.from(0).to(1)
12
12
  end
13
13
  end
14
14
 
15
- describe 'adding roles' do
16
- subject { server.add_roles([:things, :stuff]) }
17
- it 'adds the roles' do
18
- expect{subject}.to change{server.roles.size}.from(0).to(2)
15
+ describe "adding roles" do
16
+ subject { server.add_roles(%i(things stuff)) }
17
+ it "adds the roles" do
18
+ expect { subject }.to change { server.roles.size }.from(0).to(2)
19
19
  end
20
20
  end
21
21
 
22
-
23
- describe 'checking roles' do
22
+ describe "checking roles" do
24
23
  subject { server.has_role?(:test) }
25
24
 
26
25
  before do
27
26
  server.add_role(:test)
28
27
  end
29
28
 
30
- it 'adds the role' do
29
+ it "adds the role" do
31
30
  expect(subject).to be_truthy
32
31
  end
33
32
  end
34
33
 
35
- describe 'comparing identity' do
34
+ describe "comparing identity" do
36
35
  subject { server.hostname == Server[hostname].hostname }
37
36
 
38
- context 'with the same user, hostname and port' do
39
- let(:hostname) { 'root@hostname:1234' }
37
+ context "with the same user, hostname and port" do
38
+ let(:hostname) { "root@hostname:1234" }
40
39
  it { expect(subject).to be_truthy }
41
40
  end
42
41
 
43
- context 'with a different user' do
44
- let(:hostname) { 'deployer@hostname:1234' }
42
+ context "with a different user" do
43
+ let(:hostname) { "deployer@hostname:1234" }
45
44
  it { expect(subject).to be_truthy }
46
45
  end
47
46
 
48
- context 'with a different port' do
49
- let(:hostname) { 'root@hostname:5678' }
47
+ context "with a different port" do
48
+ let(:hostname) { "root@hostname:5678" }
50
49
  it { expect(subject).to be_truthy }
51
50
  end
52
51
 
53
- context 'with a different hostname' do
54
- let(:hostname) { 'root@otherserver:1234' }
52
+ context "with a different hostname" do
53
+ let(:hostname) { "root@otherserver:1234" }
55
54
  it { expect(subject).to be_falsey }
56
55
  end
57
56
  end
58
57
 
59
- describe 'identifying as primary' do
58
+ describe "identifying as primary" do
60
59
  subject { server.primary }
61
- context 'server is primary' do
60
+ context "server is primary" do
62
61
  before do
63
62
  server.set(:primary, true)
64
63
  end
65
- it 'returns self' do
64
+ it "returns self" do
66
65
  expect(subject).to eq server
67
66
  end
68
67
  end
69
68
 
70
- context 'server is not primary' do
71
- it 'is falesy' do
69
+ context "server is not primary" do
70
+ it "is falesy" do
72
71
  expect(subject).to be_falsey
73
72
  end
74
73
  end
75
74
  end
76
75
 
77
- describe 'assigning properties' do
78
-
76
+ describe "assigning properties" do
79
77
  before do
80
78
  server.with(properties)
81
79
  end
82
80
 
83
- context 'properties contains roles' do
84
- let(:properties) { {roles: [:clouds]} }
81
+ context "properties contains roles" do
82
+ let(:properties) { { roles: [:clouds] } }
85
83
 
86
- it 'adds the roles' do
84
+ it "adds the roles" do
87
85
  expect(server.roles.first).to eq :clouds
88
86
  end
89
87
  end
90
88
 
91
- context 'properties contains user' do
92
- let(:properties) { {user: 'tomc'} }
89
+ context "properties contains user" do
90
+ let(:properties) { { user: "tomc" } }
93
91
 
94
- it 'sets the user' do
95
- expect(server.user).to eq 'tomc'
92
+ it "sets the user" do
93
+ expect(server.user).to eq "tomc"
96
94
  end
97
95
 
98
- it 'sets the netssh_options user' do
99
- expect(server.netssh_options[:user]).to eq 'tomc'
96
+ it "sets the netssh_options user" do
97
+ expect(server.netssh_options[:user]).to eq "tomc"
100
98
  end
101
99
  end
102
100
 
103
- context 'properties contains port' do
104
- let(:properties) { {port: 2222} }
101
+ context "properties contains port" do
102
+ let(:properties) { { port: 2222 } }
105
103
 
106
- it 'sets the port' do
104
+ it "sets the port" do
107
105
  expect(server.port).to eq 2222
108
106
  end
109
107
  end
110
108
 
111
- context 'properties contains key' do
112
- let(:properties) { {key: '/key'} }
109
+ context "properties contains key" do
110
+ let(:properties) { { key: "/key" } }
113
111
 
114
- it 'adds the key' do
115
- expect(server.keys).to include '/key'
112
+ it "adds the key" do
113
+ expect(server.keys).to include "/key"
116
114
  end
117
115
  end
118
116
 
119
- context 'properties contains password' do
120
- let(:properties) { {password: 'supersecret'} }
117
+ context "properties contains password" do
118
+ let(:properties) { { password: "supersecret" } }
121
119
 
122
- it 'adds the key' do
123
- expect(server.password).to eq 'supersecret'
120
+ it "adds the key" do
121
+ expect(server.password).to eq "supersecret"
124
122
  end
125
123
  end
126
124
 
127
- context 'new properties' do
125
+ context "new properties" do
128
126
  let(:properties) { { webscales: 5 } }
129
127
 
130
- it 'adds the properties' do
128
+ it "adds the properties" do
131
129
  expect(server.properties.webscales).to eq 5
132
130
  end
133
131
  end
134
132
 
135
- context 'existing properties' do
133
+ context "existing properties" do
136
134
  let(:properties) { { webscales: 6 } }
137
135
 
138
- it 'keeps the existing properties' do
136
+ it "keeps the existing properties" do
139
137
  expect(server.properties.webscales).to eq 6
140
138
  server.properties.webscales = 5
141
139
  expect(server.properties.webscales).to eq 5
@@ -143,7 +141,7 @@ module Capistrano
143
141
  end
144
142
  end
145
143
 
146
- describe '#include?' do
144
+ describe "#include?" do
147
145
  let(:options) { {} }
148
146
 
149
147
  subject { server.select?(options) }
@@ -152,162 +150,157 @@ module Capistrano
152
150
  server.properties.active = true
153
151
  end
154
152
 
155
- context 'options are empty' do
153
+ context "options are empty" do
156
154
  it { expect(subject).to be_truthy }
157
155
  end
158
156
 
159
- context 'value is a symbol' do
160
- context 'value matches server property' do
161
-
162
- context 'with :filter' do
163
- let(:options) { { filter: :active }}
157
+ context "value is a symbol" do
158
+ context "value matches server property" do
159
+ context "with :filter" do
160
+ let(:options) { { filter: :active } }
164
161
  it { expect(subject).to be_truthy }
165
162
  end
166
163
 
167
- context 'with :select' do
168
- let(:options) { { select: :active }}
164
+ context "with :select" do
165
+ let(:options) { { select: :active } }
169
166
  it { expect(subject).to be_truthy }
170
167
  end
171
168
 
172
- context 'with :exclude' do
173
- let(:options) { { exclude: :active }}
169
+ context "with :exclude" do
170
+ let(:options) { { exclude: :active } }
174
171
  it { expect(subject).to be_falsey }
175
172
  end
176
173
  end
177
174
 
178
- context 'value does not match server properly' do
179
- context 'with :active true' do
180
- let(:options) { { active: true }}
175
+ context "value does not match server properly" do
176
+ context "with :active true" do
177
+ let(:options) { { active: true } }
181
178
  it { expect(subject).to be_truthy }
182
179
  end
183
180
 
184
- context 'with :active false' do
185
- let(:options) { { active: false }}
181
+ context "with :active false" do
182
+ let(:options) { { active: false } }
186
183
  it { expect(subject).to be_falsey }
187
184
  end
188
185
  end
189
186
 
190
- context 'value does not match server properly' do
191
- context 'with :filter' do
192
- let(:options) { { filter: :inactive }}
187
+ context "value does not match server properly" do
188
+ context "with :filter" do
189
+ let(:options) { { filter: :inactive } }
193
190
  it { expect(subject).to be_falsey }
194
191
  end
195
192
 
196
- context 'with :select' do
197
- let(:options) { { select: :inactive }}
193
+ context "with :select" do
194
+ let(:options) { { select: :inactive } }
198
195
  it { expect(subject).to be_falsey }
199
196
  end
200
197
 
201
- context 'with :exclude' do
202
- let(:options) { { exclude: :inactive }}
198
+ context "with :exclude" do
199
+ let(:options) { { exclude: :inactive } }
203
200
  it { expect(subject).to be_truthy }
204
201
  end
205
202
  end
206
203
  end
207
204
 
208
- context 'key is a property' do
209
- context 'with :active true' do
210
- let(:options) { { active: true }}
205
+ context "key is a property" do
206
+ context "with :active true" do
207
+ let(:options) { { active: true } }
211
208
  it { expect(subject).to be_truthy }
212
209
  end
213
210
 
214
- context 'with :active false' do
215
- let(:options) { { active: false }}
211
+ context "with :active false" do
212
+ let(:options) { { active: false } }
216
213
  it { expect(subject).to be_falsey }
217
214
  end
218
215
  end
219
216
 
220
- context 'value is a proc' do
221
- context 'value matches server property' do
222
-
223
- context 'with :filter' do
217
+ context "value is a proc" do
218
+ context "value matches server property" do
219
+ context "with :filter" do
224
220
  let(:options) { { filter: ->(s) { s.properties.active } } }
225
221
  it { expect(subject).to be_truthy }
226
222
  end
227
223
 
228
- context 'with :select' do
224
+ context "with :select" do
229
225
  let(:options) { { select: ->(s) { s.properties.active } } }
230
226
  it { expect(subject).to be_truthy }
231
227
  end
232
228
 
233
- context 'with :exclude' do
229
+ context "with :exclude" do
234
230
  let(:options) { { exclude: ->(s) { s.properties.active } } }
235
231
  it { expect(subject).to be_falsey }
236
232
  end
237
-
238
233
  end
239
234
 
240
- context 'value does not match server properly' do
241
- context 'with :filter' do
235
+ context "value does not match server properly" do
236
+ context "with :filter" do
242
237
  let(:options) { { filter: ->(s) { s.properties.inactive } } }
243
238
  it { expect(subject).to be_falsey }
244
239
  end
245
240
 
246
- context 'with :select' do
241
+ context "with :select" do
247
242
  let(:options) { { select: ->(s) { s.properties.inactive } } }
248
243
  it { expect(subject).to be_falsey }
249
244
  end
250
245
 
251
- context 'with :exclude' do
246
+ context "with :exclude" do
252
247
  let(:options) { { exclude: ->(s) { s.properties.inactive } } }
253
248
  it { expect(subject).to be_truthy }
254
249
  end
255
-
256
250
  end
257
251
  end
258
-
259
252
  end
260
253
 
261
- describe 'assign ssh_options' do
262
- let(:server) { Server.new('user_name@hostname') }
254
+ describe "assign ssh_options" do
255
+ let(:server) { Server.new("user_name@hostname") }
263
256
 
264
- context 'defaults' do
265
- it 'forward agent' do
257
+ context "defaults" do
258
+ it "forward agent" do
266
259
  expect(server.netssh_options[:forward_agent]).to eq true
267
260
  end
268
- it 'contains user' do
269
- expect(server.netssh_options[:user]).to eq 'user_name'
261
+ it "contains user" do
262
+ expect(server.netssh_options[:user]).to eq "user_name"
270
263
  end
271
264
  end
272
265
 
273
- context 'custom' do
266
+ context "custom" do
274
267
  let(:properties) do
275
268
  { ssh_options: {
276
- user: 'another_user',
269
+ user: "another_user",
277
270
  keys: %w(/home/another_user/.ssh/id_rsa),
278
271
  forward_agent: false,
279
- auth_methods: %w(publickey password) } }
272
+ auth_methods: %w(publickey password)
273
+ } }
280
274
  end
281
275
 
282
276
  before do
283
277
  server.with(properties)
284
278
  end
285
279
 
286
- it 'not forward agent' do
280
+ it "not forward agent" do
287
281
  expect(server.netssh_options[:forward_agent]).to eq false
288
282
  end
289
- it 'contains correct user' do
290
- expect(server.netssh_options[:user]).to eq 'another_user'
283
+ it "contains correct user" do
284
+ expect(server.netssh_options[:user]).to eq "another_user"
291
285
  end
292
- it 'does not affect server user in host' do
293
- expect(server.user).to eq 'user_name'
286
+ it "does not affect server user in host" do
287
+ expect(server.user).to eq "user_name"
294
288
  end
295
- it 'contains keys' do
289
+ it "contains keys" do
296
290
  expect(server.netssh_options[:keys]).to eq %w(/home/another_user/.ssh/id_rsa)
297
291
  end
298
- it 'contains auth_methods' do
292
+ it "contains auth_methods" do
299
293
  expect(server.netssh_options[:auth_methods]).to eq %w(publickey password)
300
294
  end
301
295
  end
302
-
303
296
  end
304
297
 
305
298
  describe ".[]" do
306
- it 'creates a server if its argument is not already a server' do
307
- expect(Server['hostname:1234']).to be_a Server
299
+ it "creates a server if its argument is not already a server" do
300
+ expect(Server["hostname:1234"]).to be_a Server
308
301
  end
309
302
 
310
- it 'returns its argument if it is already a server' do
303
+ it "returns its argument if it is already a server" do
311
304
  expect(Server[server]).to be server
312
305
  end
313
306
  end