stairs 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -36
  3. data/.travis.yml +6 -2
  4. data/Guardfile +2 -2
  5. data/Rakefile +4 -4
  6. data/bin/stairs +10 -10
  7. data/lib/stairs.rb +13 -13
  8. data/lib/stairs/env_adapters.rb +6 -6
  9. data/lib/stairs/env_adapters/dotenv.rb +3 -3
  10. data/lib/stairs/env_adapters/rbenv.rb +3 -3
  11. data/lib/stairs/env_adapters/rvm.rb +3 -3
  12. data/lib/stairs/interactive_configuration.rb +11 -11
  13. data/lib/stairs/railtie.rb +1 -1
  14. data/lib/stairs/runner.rb +2 -2
  15. data/lib/stairs/step.rb +20 -17
  16. data/lib/stairs/steps.rb +3 -3
  17. data/lib/stairs/steps/facebook.rb +6 -6
  18. data/lib/stairs/steps/postgresql.rb +11 -11
  19. data/lib/stairs/steps/secret_key_base.rb +4 -4
  20. data/lib/stairs/tasks.rb +2 -2
  21. data/lib/stairs/util.rb +2 -2
  22. data/lib/stairs/util/cli.rb +3 -4
  23. data/lib/stairs/util/file_mutation.rb +10 -10
  24. data/lib/stairs/version.rb +1 -1
  25. data/spec/lib/configuration_spec.rb +8 -8
  26. data/spec/lib/stairs/env_adapters/dotenv_spec.rb +20 -20
  27. data/spec/lib/stairs/env_adapters/rbenv_spec.rb +22 -22
  28. data/spec/lib/stairs/env_adapters/rvm_spec.rb +22 -22
  29. data/spec/lib/stairs/env_adapters_spec.rb +12 -14
  30. data/spec/lib/stairs/interactive_configuration_spec.rb +27 -20
  31. data/spec/lib/stairs/runner_spec.rb +18 -14
  32. data/spec/lib/stairs/script_spec.rb +13 -14
  33. data/spec/lib/stairs/step_spec.rb +225 -189
  34. data/spec/lib/stairs/steps/secret_key_base_spec.rb +7 -5
  35. data/spec/lib/stairs/util/cli_spec.rb +29 -29
  36. data/spec/lib/stairs/util/file_mutation_spec.rb +46 -46
  37. data/spec/spec_helper.rb +6 -8
  38. data/stairs.gemspec +28 -23
  39. metadata +22 -23
  40. data/spec/support/configuration_helper.rb +0 -5
@@ -1,51 +1,58 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Stairs::InteractiveConfiguration do
4
4
  subject { described_class.new }
5
5
 
6
- describe "metadata" do
7
- it "has a title" do
6
+ describe 'metadata' do
7
+ it 'has a title' do
8
8
  expect(described_class.step_title).not_to be_nil
9
9
  end
10
10
 
11
- it "has a description" do
11
+ it 'has a description' do
12
12
  expect(described_class.step_description).not_to be_nil
13
13
  end
14
14
  end
15
15
 
16
- describe "#run!" do
16
+ describe '#run!' do
17
17
  before do
18
- Stairs::EnvAdapters.stub recommended_adapter: Stairs::EnvAdapters::Rbenv
18
+ allow(Stairs::EnvAdapters)
19
+ .to receive(:recommended_adapter).and_return(Stairs::EnvAdapters::Rbenv)
19
20
  end
20
21
 
21
- it "recommends an adapter" do
22
- output = follow_prompts("Y") { subject.run! }
22
+ it 'recommends an adapter' do
23
+ output = follow_prompts('Y') { subject.run! }
23
24
  expect(output).to include "you're using rbenv"
24
25
  end
25
26
 
26
- it "sets the adapter" do
27
- follow_prompts("Y") { subject.run! }
28
- expect(Stairs.configuration.env_adapter).to be_a Stairs::EnvAdapters::Rbenv
27
+ it 'sets the adapter' do
28
+ follow_prompts('Y') { subject.run! }
29
+ expect(Stairs.configuration.env_adapter)
30
+ .to be_a Stairs::EnvAdapters::Rbenv
29
31
  end
30
32
 
31
- it "allows for specifying your desired adapter" do
32
- follow_prompts("N", "dotenv") { subject.run! }
33
- expect(Stairs.configuration.env_adapter).to be_a Stairs::EnvAdapters::Dotenv
33
+ it 'allows for specifying your desired adapter' do
34
+ follow_prompts('N', 'dotenv') { subject.run! }
35
+ expect(Stairs.configuration.env_adapter)
36
+ .to be_a Stairs::EnvAdapters::Dotenv
34
37
  end
35
38
 
36
- context "when Stairs is configured to use defaults" do
39
+ context 'when Stairs is configured to use defaults' do
37
40
  before { Stairs.configuration.use_defaults = true }
38
41
 
39
- it "uses the default adapter without asking" do
42
+ it 'uses the default adapter without asking' do
40
43
  subject.run!
41
- expect(Stairs.configuration.env_adapter).to be_a Stairs::EnvAdapters::Rbenv
44
+ expect(Stairs.configuration.env_adapter)
45
+ .to be_a Stairs::EnvAdapters::Rbenv
42
46
  end
43
47
  end
44
48
 
45
- context "when no adapter can be found to recommend" do
46
- before { Stairs::EnvAdapters.stub recommended_adapter: nil }
49
+ context 'when no adapter can be found to recommend' do
50
+ before do
51
+ allow(Stairs::EnvAdapters)
52
+ .to receive(:recommended_adapter).and_return(nil)
53
+ end
47
54
 
48
- it "aborts" do
55
+ it 'aborts' do
49
56
  expect { subject.run! }.to raise_error SystemExit
50
57
  end
51
58
  end
@@ -1,36 +1,40 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Stairs::Runner do
4
4
  let(:groups) { nil }
5
5
  let(:subject) { described_class.new(groups) }
6
6
 
7
- describe "#run!" do
8
- let(:script_double) { double("script", run!: true) }
7
+ describe '#run!' do
8
+ let(:script_double) { double('script', run!: true) }
9
9
 
10
10
  before do
11
11
  # Stub things as to not block IO
12
- Stairs::InteractiveConfiguration.any_instance.stub :run!
13
- Stairs::Script.any_instance.stub :run!
14
- Stairs::Script.stub(:new).and_return(script_double)
12
+ allow_any_instance_of(Stairs::InteractiveConfiguration).to receive(:run!)
13
+ allow_any_instance_of(Stairs::Script).to receive(:run!)
14
+ allow(Stairs::Script).to receive(:new).and_return(script_double)
15
15
  end
16
16
 
17
- it "runs the interactive configuration" do
18
- Stairs::InteractiveConfiguration.any_instance.should_receive(:run!)
17
+ it 'runs the interactive configuration' do
18
+ expect_any_instance_of(Stairs::InteractiveConfiguration)
19
+ .to receive(:run!)
20
+
19
21
  subject.run!
20
22
  end
21
23
 
22
- it "runs all groups in the setup.rb script" do
23
- Stairs::Script.should_receive(:new).with("setup.rb", groups).and_return(script_double)
24
- script_double.should_receive(:run!)
24
+ it 'runs all groups in the setup.rb script' do
25
+ expect(Stairs::Script)
26
+ .to receive(:new).with('setup.rb', groups).and_return(script_double)
27
+
28
+ expect(script_double).to receive(:run!)
25
29
 
26
30
  subject.run!
27
31
  end
28
32
 
29
- context "with groups provided" do
33
+ context 'with groups provided' do
30
34
  let(:groups) { [:reset] }
31
35
 
32
- it "passes the specified groups to the script" do
33
- Stairs::Script.should_receive(:new).with("setup.rb", groups)
36
+ it 'passes the specified groups to the script' do
37
+ expect(Stairs::Script).to receive(:new).with('setup.rb', groups)
34
38
  subject.run!
35
39
  end
36
40
  end
@@ -1,38 +1,37 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Stairs::Script do
4
- let(:filename) { "setup.rb" }
4
+ let(:filename) { 'setup.rb' }
5
5
  let(:groups) { [:reset] }
6
6
  subject { described_class.new(filename, groups) }
7
7
 
8
-
9
- context "with a script present" do
8
+ context 'with a script present' do
10
9
  before do
11
- File.open(filename, "w") do |file|
12
- file.write("self.class")
10
+ File.open(filename, 'w') do |file|
11
+ file.write('self.class')
13
12
  end
14
13
  end
15
14
 
16
15
  after { File.delete(filename) }
17
16
 
18
- describe "initialize" do
19
- it "receives groups" do
17
+ describe 'initialize' do
18
+ it 'receives groups' do
20
19
  expect { described_class.new(filename, groups) }.not_to raise_error
21
20
  end
22
21
  end
23
22
 
24
- describe "#run!" do
25
- it "outputs running message" do
23
+ describe '#run!' do
24
+ it 'outputs running message' do
26
25
  output = capture_stdout { subject.run! }
27
- expect(output).to include "= Running script setup.rb"
26
+ expect(output).to include '= Running script setup.rb'
28
27
  end
29
28
 
30
- it "passes groups to the new instance of Step" do
31
- Stairs::Step.should_receive(:new).with(groups)
29
+ it 'passes groups to the new instance of Step' do
30
+ expect(Stairs::Step).to receive(:new).with(groups)
32
31
  subject.run!
33
32
  end
34
33
 
35
- it "evaluates the script in the context of an instance of Step" do
34
+ it 'evaluates the script in the context of an instance of Step' do
36
35
  # because our test setup.rb only contains `self.class` we can check
37
36
  # this way:
38
37
  expect(subject.run!).to eq Stairs::Step
@@ -1,349 +1,378 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Stairs::Step do
4
4
  let(:anon_step) { Class.new(described_class) }
5
5
  let(:groups) { nil }
6
6
  subject { anon_step.new(groups) }
7
7
 
8
- describe "metadata" do
9
- describe "step_title" do
10
- it "can be set on the class using title class DSL" do
11
- anon_step.title "Class Step Name"
12
- expect(subject.step_title).to eq "Class Step Name"
8
+ describe 'metadata' do
9
+ describe 'step_title' do
10
+ it 'can be set on the class using title class DSL' do
11
+ anon_step.title 'Class Step Name'
12
+ expect(subject.step_title).to eq 'Class Step Name'
13
13
  end
14
14
 
15
- it "can be set on the instance" do
16
- subject.step_title = "Instance Step Name"
17
- expect(subject.step_title).to eq "Instance Step Name"
15
+ it 'can be set on the instance' do
16
+ subject.step_title = 'Instance Step Name'
17
+ expect(subject.step_title).to eq 'Instance Step Name'
18
18
  end
19
19
 
20
- it "prefers the value set on instance" do
21
- anon_step.title "Class Step Name"
22
- subject.step_title = "Instance Step Name"
23
- expect(subject.step_title).to eq "Instance Step Name"
20
+ it 'prefers the value set on instance' do
21
+ anon_step.title 'Class Step Name'
22
+ subject.step_title = 'Instance Step Name'
23
+ expect(subject.step_title).to eq 'Instance Step Name'
24
24
  end
25
25
  end
26
26
 
27
- describe "step_description" do
28
- it "can be set on the class using description class DSL" do
29
- anon_step.description "Class Step Description"
30
- expect(subject.step_description).to eq "Class Step Description"
27
+ describe 'step_description' do
28
+ it 'can be set on the class using description class DSL' do
29
+ anon_step.description 'Class Step Description'
30
+ expect(subject.step_description).to eq 'Class Step Description'
31
31
  end
32
32
 
33
- it "can be set on the instance" do
34
- subject.step_description = "Instance Step Description"
35
- expect(subject.step_description).to eq "Instance Step Description"
33
+ it 'can be set on the instance' do
34
+ subject.step_description = 'Instance Step Description'
35
+ expect(subject.step_description).to eq 'Instance Step Description'
36
36
  end
37
37
 
38
- it "prefers the value set on instance" do
39
- anon_step.title "Class Step Description"
40
- subject.step_description = "Instance Step Description"
41
- expect(subject.step_description).to eq "Instance Step Description"
38
+ it 'prefers the value set on instance' do
39
+ anon_step.title 'Class Step Description'
40
+ subject.step_description = 'Instance Step Description'
41
+ expect(subject.step_description).to eq 'Instance Step Description'
42
42
  end
43
43
  end
44
44
  end
45
45
 
46
- describe "#initialize" do
47
- describe "options" do
48
- describe "default options" do
49
- it "is required" do
50
- expect(subject.options[:required]).to be_true
46
+ describe '#initialize' do
47
+ describe 'options' do
48
+ describe 'default options' do
49
+ it 'is required' do
50
+ expect(subject.options[:required]).to eq true
51
51
  end
52
52
  end
53
53
 
54
- context "with options" do
55
- let(:options) { { something: "cool" } }
54
+ context 'with options' do
55
+ let(:options) { { something: 'cool' } }
56
56
  subject { anon_step.new(options) }
57
57
 
58
- it "exposes options on the instance" do
59
- expect(subject.options[:something]).to eq "cool"
58
+ it 'exposes options on the instance' do
59
+ expect(subject.options[:something]).to eq 'cool'
60
60
  end
61
61
  end
62
62
  end
63
63
 
64
- it "exposes supplied groups on the instance" do
64
+ it 'exposes supplied groups on the instance' do
65
65
  expect(subject.groups).to eq groups
66
66
  end
67
67
  end
68
68
 
69
- describe "#run!" do
70
- before { subject.stub run: true }
71
- before { anon_step.title "Step Name" }
69
+ describe '#run!' do
70
+ before { allow(subject).to receive(:run).and_return(true) }
71
+ before { anon_step.title 'Step Name' }
72
72
 
73
- it "outputs lead-in message" do
73
+ it 'outputs lead-in message' do
74
74
  output = capture_stdout { subject.run! }
75
- expect(output).to include "== Running Step Name"
75
+ expect(output).to include '== Running Step Name'
76
76
  end
77
77
 
78
- it "calls #run where the implementation lives" do
79
- subject.should_receive(:run)
78
+ it 'calls #run where the implementation lives' do
79
+ expect(subject).to receive(:run)
80
80
  subject.run!
81
81
  end
82
82
 
83
- it "outputs completed message" do
83
+ it 'outputs completed message' do
84
84
  output = capture_stdout { subject.run! }
85
- expect(output).to include "== Completed Step Name"
85
+ expect(output).to include '== Completed Step Name'
86
86
  end
87
87
 
88
- context "when the step is not required" do
88
+ context 'when the step is not required' do
89
89
  subject { anon_step.new required: false }
90
- before { subject.stub run: true }
90
+ before { allow(subject).to receive(:run).and_return(true) }
91
91
 
92
- it "prompts the user to decide if we should run the step" do
93
- output = follow_prompts("Y") { subject.run! }
94
- expect(output).to include "This step is optional, would you like to perform it? (Y/N): "
92
+ it 'prompts the user to decide if we should run the step' do
93
+ output = follow_prompts('Y') { subject.run! }
94
+ expect(output).to include 'This step is optional, would you like to ' \
95
+ 'perform it? (Y/N): '
95
96
  end
96
97
 
97
- context "user says yes" do
98
- it "runs the step" do
99
- subject.should_receive :run
100
- follow_prompts("Y") { subject.run! }
98
+ context 'user says yes' do
99
+ it 'runs the step' do
100
+ expect(subject).to receive(:run)
101
+ follow_prompts('Y') { subject.run! }
101
102
  end
102
103
  end
103
104
 
104
- context "user says no" do
105
+ context 'user says no' do
105
106
  it "doesn't run the step" do
106
- subject.should_not_receive :run
107
- follow_prompts("N") { subject.run! }
107
+ expect(subject).not_to receive(:run)
108
+ follow_prompts('N') { subject.run! }
108
109
  end
109
110
  end
110
111
  end
111
112
  end
112
113
 
113
- describe "#provide" do
114
- it "prompts the user to provide input" do
115
- output = follow_prompts("here") { subject.provide "Gimme" }
116
- expect(output).to include "Gimme: "
114
+ describe '#provide' do
115
+ it 'prompts the user to provide input' do
116
+ output = follow_prompts('here') { subject.provide 'Gimme' }
117
+ expect(output).to include 'Gimme: '
117
118
  end
118
119
 
119
- it "returns the input" do
120
- follow_prompts("here") do
121
- expect(subject.provide("Gimme")).to eq "here"
120
+ it 'returns the input' do
121
+ follow_prompts('here') do
122
+ expect(subject.provide('Gimme')).to eq 'here'
122
123
  end
123
124
  end
124
125
 
125
- it "requires user input" do
126
- follow_prompts "", "", "", "finally" do
127
- expect(subject.provide("Gimme")).to eq "finally"
126
+ it 'requires user input' do
127
+ follow_prompts '', '', '', 'finally' do
128
+ expect(subject.provide('Gimme')).to eq 'finally'
128
129
  end
129
130
  end
130
131
 
131
- context "Stairs is configured to use defaults automatically" do
132
+ context 'Stairs is configured to use defaults automatically' do
132
133
  before { Stairs.configuration.use_defaults = true }
133
134
 
134
- context "but no default is provided" do
135
- it "prompts for input as usual" do
136
- follow_prompts "here ya go" do
137
- expect(subject.provide("Gimme")).to eq "here ya go"
135
+ context 'but no default is provided' do
136
+ it 'prompts for input as usual' do
137
+ follow_prompts 'here ya go' do
138
+ expect(subject.provide('Gimme')).to eq 'here ya go'
138
139
  end
139
140
  end
140
141
  end
141
142
 
142
- context "and a default is provided" do
143
- it "returns the default without prompting" do
144
- expect(subject.provide("Gimme", default: "adefault")).to eq "adefault"
143
+ context 'and a default is provided' do
144
+ it 'returns the default without prompting' do
145
+ expect(subject.provide('Gimme', default: 'adefault')).to eq 'adefault'
145
146
  end
146
147
  end
147
148
  end
148
149
 
149
- context "with a default" do
150
+ context 'with a default' do
150
151
  def call_method
151
- subject.provide "Gimme", default: "adefault"
152
+ subject.provide 'Gimme', default: 'adefault'
152
153
  end
153
154
 
154
- it "does not require input" do
155
- output = follow_prompts("here") { call_method }
155
+ it 'does not require input (this test would hang if it did)' do
156
+ follow_prompts('here') { call_method }
156
157
  end
157
158
 
158
- context "and required" do
159
- it "does not require input" do
160
- follow_prompts "" do
161
- expect(subject.provide("Gimme", required: true, default: "adefault")).to eq "adefault"
159
+ context 'and required' do
160
+ it 'does not require input' do
161
+ follow_prompts '' do
162
+ expect(
163
+ subject.provide('Gimme', required: true, default: 'adefault')
164
+ ).to eq 'adefault'
162
165
  end
163
166
  end
164
167
  end
165
168
 
166
- context "with no input" do
167
- it "returns the default" do
168
- follow_prompts("") do
169
- expect(call_method).to eq "adefault"
169
+ context 'with no input' do
170
+ it 'returns the default' do
171
+ follow_prompts('') do
172
+ expect(call_method).to eq 'adefault'
170
173
  end
171
174
  end
172
175
  end
173
176
 
174
- context "with input" do
175
- it "returns the input" do
176
- follow_prompts("here") do
177
- expect(call_method).to eq "here"
177
+ context 'with input' do
178
+ it 'returns the input' do
179
+ follow_prompts('here') do
180
+ expect(call_method).to eq 'here'
178
181
  end
179
182
  end
180
183
  end
181
184
  end
182
185
 
183
- context "optional" do
184
- it "does not require input" do
185
- follow_prompts "" do
186
- expect(subject.provide("Gimme", required: false)).to eq nil
186
+ context 'optional' do
187
+ it 'does not require input' do
188
+ follow_prompts '' do
189
+ expect(subject.provide('Gimme', required: false)).to eq nil
190
+ end
191
+ end
192
+ end
193
+
194
+ context 'with frozen string literals (in anticipation of ruby3)' do
195
+ it 'does not attempt to modify frozen string' do
196
+ follow_prompts 'here' do
197
+ expect { subject.provide('Gimme') }.not_to raise_error
187
198
  end
188
199
  end
189
200
  end
190
201
  end
191
202
 
192
- describe "#choice" do
193
- it "prompts the user to answer the question" do
194
- output = follow_prompts("Y") { subject.choice("Should I?") }
195
- expect(output).to include "Should I?"
203
+ describe '#choice' do
204
+ it 'prompts the user to answer the question' do
205
+ output = follow_prompts('Y') { subject.choice('Should I?') }
206
+ expect(output).to include 'Should I?'
196
207
  end
197
208
 
198
- it "defaults to a Y/N question" do
199
- output = follow_prompts("Y") { subject.choice("Should I?") }
200
- expect(output).to include "(Y/N)"
209
+ it 'defaults to a Y/N question' do
210
+ output = follow_prompts('Y') { subject.choice('Should I?') }
211
+ expect(output).to include '(Y/N)'
201
212
  end
202
213
 
203
- it "returns true for Y" do
204
- follow_prompts("Y") { expect(subject.choice("Should I?")).to be_true }
214
+ it 'returns true for Y' do
215
+ follow_prompts('Y') { expect(subject.choice('Should I?')).to eq true }
205
216
  end
206
217
 
207
- it "returns true for Y" do
208
- follow_prompts("N") { expect(subject.choice("Should I?")).to be_false }
218
+ it 'returns true for Y' do
219
+ follow_prompts('N') { expect(subject.choice('Should I?')).to eq false }
209
220
  end
210
221
 
211
- context "with available choices provided" do
212
- it "displays those choices" do
213
- output = follow_prompts("Nick") { subject.choice("What's your name?", ["Nick", "Brendan"]) }
214
- expect(output).to include "(Nick/Brendan)"
222
+ context 'with available choices provided' do
223
+ it 'displays those choices' do
224
+ output = follow_prompts('Nick') do
225
+ subject.choice("What's your name?", %w(Nick Brendan))
226
+ end
227
+
228
+ expect(output).to include '(Nick/Brendan)'
215
229
  end
216
230
 
217
231
  it "returns the user's choice" do
218
- follow_prompts("Nick") do
219
- expect(subject.choice("What's your name?", ["Nick", "Brendan"])).to eq "Nick"
232
+ follow_prompts('Nick') do
233
+ expect(subject.choice("What's your name?", %w(Nick Brendan)))
234
+ .to eq 'Nick'
220
235
  end
221
236
  end
222
237
 
223
- it "prompts repeatedly until it receives input in available choices" do
224
- follow_prompts("Sally", "Frank", "Nick") do
225
- expect(subject.choice("What's your name?", ["Nick", "Brendan"])).to eq "Nick"
238
+ it 'prompts repeatedly until it receives input in available choices' do
239
+ follow_prompts('Sally', 'Frank', 'Nick') do
240
+ expect(subject.choice("What's your name?", %w(Nick Brendan)))
241
+ .to eq 'Nick'
226
242
  end
227
243
  end
228
244
  end
229
245
 
230
- context "with a block" do
246
+ context 'with a block' do
231
247
  it "calls the block with the user's choice" do
232
- follow_prompts("Nick") do
248
+ follow_prompts('Nick') do
233
249
  expect do |block|
234
- subject.choice("What's your name?", ["Nick", "Brendan"], &block)
235
- end.to yield_with_args("Nick")
250
+ subject.choice("What's your name?", %w(Nick Brendan), &block)
251
+ end.to yield_with_args('Nick')
236
252
  end
237
253
  end
238
254
  end
239
255
  end
240
256
 
241
- describe "#rake" do
242
- before { subject.stub system: true }
257
+ describe '#rake' do
258
+ before { allow(subject).to receive(:system).and_return(true) }
243
259
 
244
- it "outputs lead-in message" do
245
- output = capture_stdout { subject.rake "the_task" }
246
- expect(output).to include "== Running the_task"
260
+ it 'outputs lead-in message' do
261
+ output = capture_stdout { subject.rake 'the_task' }
262
+ expect(output).to include '== Running the_task'
247
263
  end
248
264
 
249
- it "runs the rake task" do
250
- subject.should_receive(:system).with("rake the_task")
251
- subject.rake "the_task"
265
+ it 'runs the rake task' do
266
+ expect(subject).to receive(:system).with('rake the_task')
267
+ subject.rake 'the_task'
252
268
  end
253
269
 
254
- it "outputs completed message" do
255
- output = capture_stdout { subject.rake "the_task" }
256
- expect(output).to include "== Completed the_task"
270
+ it 'outputs completed message' do
271
+ output = capture_stdout { subject.rake 'the_task' }
272
+ expect(output).to include '== Completed the_task'
257
273
  end
258
274
  end
259
275
 
260
- describe "#env" do
261
- let(:adapter) { double("adapter", set: true) }
276
+ describe '#env' do
277
+ let(:adapter) { double('adapter', set: true) }
262
278
  before { Stairs.configuration.env_adapter = adapter }
263
279
 
264
280
  it "delegates to the adapter's set" do
265
- adapter.should_receive(:set).with("NAME", "value")
266
- subject.env "NAME", "value"
281
+ expect(adapter).to receive(:set).with('NAME', 'value')
282
+ subject.env 'NAME', 'value'
267
283
  end
268
284
 
269
- it "writes to ENV simultaneously so Rubyland can access without a reload" do
270
- ENV.should_receive(:[]=).with("NAME", "value")
271
- subject.env "NAME", "value"
285
+ it 'writes to ENV simultaneously so Rubyland can access without a reload' do
286
+ expect(ENV).to receive(:[]=).with('NAME', 'value')
287
+ subject.env 'NAME', 'value'
272
288
  end
273
289
 
274
- context "with no value" do
290
+ context 'with no value' do
275
291
  it "delegates to the adapter's unset" do
276
- adapter.should_receive(:unset).with("NAME")
277
- subject.env "NAME", nil
292
+ expect(adapter).to receive(:unset).with('NAME')
293
+ subject.env 'NAME', nil
278
294
  end
279
295
  end
280
296
  end
281
297
 
282
- describe "#write" do
283
- it "delegates to the well tested FileMutation util" do
284
- Stairs::Util::FileMutation.should_receive(:write).with("something", "file.txt")
285
- subject.write("something", "file.txt")
298
+ describe '#write' do
299
+ it 'delegates to the well tested FileMutation util' do
300
+ expect(Stairs::Util::FileMutation)
301
+ .to receive(:write).with('something', 'file.txt')
302
+
303
+ subject.write('something', 'file.txt')
286
304
  end
287
305
  end
288
306
 
289
- describe "#write_line" do
290
- it "delegates to the well tested FileMutation util" do
291
- Stairs::Util::FileMutation.should_receive(:write_line).with("something", "file.txt")
292
- subject.write_line("something", "file.txt")
307
+ describe '#write_line' do
308
+ it 'delegates to the well tested FileMutation util' do
309
+ expect(Stairs::Util::FileMutation)
310
+ .to receive(:write_line).with('something', 'file.txt')
311
+
312
+ subject.write_line('something', 'file.txt')
293
313
  end
294
314
  end
295
315
 
296
- describe "#finish" do
297
- it "outputs lead-in message" do
298
- output = capture_stdout { subject.finish "Message" }
299
- expect(output).to include "== All done!"
316
+ describe '#finish' do
317
+ it 'outputs lead-in message' do
318
+ output = capture_stdout { subject.finish 'Message' }
319
+ expect(output).to include '== All done!'
300
320
  end
301
321
 
302
- it "outputs supplied message" do
303
- output = capture_stdout { subject.finish "My message" }
304
- expect(output).to include "My message"
322
+ it 'outputs supplied message' do
323
+ output = capture_stdout { subject.finish 'My message' }
324
+ expect(output).to include 'My message'
305
325
  end
306
326
  end
307
327
 
308
- describe "#stairs_info" do
309
- it "outputs the message" do
310
- output = capture_stdout { subject.stairs_info "Ohai" }
311
- expect(output).to include "Ohai"
328
+ describe '#stairs_info' do
329
+ it 'outputs the message' do
330
+ output = capture_stdout { subject.stairs_info 'Ohai' }
331
+ expect(output).to include 'Ohai'
312
332
  end
313
333
  end
314
334
 
315
- describe "#setup" do
316
- context "with an invalid step_name" do
317
- it "raises when step_name cannot be resolved in Stairs::Steps" do
335
+ describe '#setup' do
336
+ context 'with an invalid step_name' do
337
+ it 'raises when step_name cannot be resolved in Stairs::Steps' do
318
338
  expect { subject.setup :blahblahbefkj }.to raise_error
319
339
  end
320
340
  end
321
341
 
322
- context "with a valid step_name" do
323
- let!(:mock_step_class) { Stairs::Steps::MockStep = Class.new(Stairs::Step) }
324
- before { mock_step_class.any_instance.stub run!: true }
342
+ context 'with a valid step_name' do
343
+ let!(:mock_step_class) do
344
+ Stairs::Steps::MockStep = Class.new(Stairs::Step)
345
+ end
346
+ before do
347
+ allow_any_instance_of(mock_step_class)
348
+ .to receive(:run!).and_return(true)
349
+ end
325
350
 
326
- it "instantiates and runs the step" do
327
- mock_step_class.any_instance.should_receive(:run!)
351
+ it 'instantiates and runs the step' do
352
+ expect_any_instance_of(mock_step_class).to receive(:run!)
328
353
  subject.setup :mock_step
329
354
  end
330
355
 
331
- it "passes groups to the step" do
332
- mock_step_class.should_receive(:new).with(groups, {}).and_call_original
356
+ it 'passes groups to the step' do
357
+ expect(mock_step_class)
358
+ .to receive(:new).with(groups, {}).and_call_original
359
+
333
360
  subject.setup :mock_step
334
361
  end
335
362
 
336
- context "with options" do
337
- let(:options) { { something: "cool" } }
363
+ context 'with options' do
364
+ let(:options) { { something: 'cool' } }
365
+
366
+ it 'passes options to the step' do
367
+ expect(mock_step_class)
368
+ .to receive(:new).with(groups, options).and_call_original
338
369
 
339
- it "passes options to the step" do
340
- mock_step_class.should_receive(:new).with(groups, options).and_call_original
341
370
  subject.setup :mock_step, options
342
371
  end
343
372
  end
344
373
  end
345
374
 
346
- context "with a block" do
375
+ context 'with a block' do
347
376
  def call_method
348
377
  subject.setup(:custom_step) { puts "I'm running in #{self.class}" }
349
378
  end
@@ -351,62 +380,69 @@ describe Stairs::Step do
351
380
  # Initialize primary subject before asserting against #new for the Step
352
381
  # it initializes
353
382
  def initialize_primary_subject
354
- instance = subject
383
+ subject
355
384
  end
356
385
 
357
386
  it "sets the new step's title to a titleized version of step_name" do
358
387
  output = capture_stdout { call_method }
359
- expect(output).to include "Custom Step"
388
+ expect(output).to include 'Custom Step'
360
389
  end
361
390
 
362
- it "runs the block in the context of the new step" do
391
+ it 'runs the block in the context of the new step' do
363
392
  output = capture_stdout { call_method }
364
393
  expect(output).to include "I'm running in Stairs::Step"
365
394
  end
366
395
 
367
- it "passes groups to the step" do
396
+ it 'passes groups to the step' do
368
397
  initialize_primary_subject
369
398
 
370
- described_class.should_receive(:new).with(groups, {}).and_call_original
399
+ expect(described_class)
400
+ .to receive(:new).with(groups, {}).and_call_original
401
+
371
402
  call_method
372
403
  end
373
404
 
374
- context "with options" do
375
- let(:options) { { something: "cool" } }
376
- before { described_class.any_instance.stub run!: true }
405
+ context 'with options' do
406
+ let(:options) { { something: 'cool' } }
407
+ before do
408
+ allow_any_instance_of(described_class)
409
+ .to receive(:run!).and_return(true)
410
+ end
377
411
 
378
- it "passes options to the step" do
412
+ it 'passes options to the step' do
379
413
  initialize_primary_subject
380
414
 
381
- described_class.should_receive(:new).with(groups, options).and_call_original
415
+ expect(described_class)
416
+ .to receive(:new).with(groups, options).and_call_original
417
+
382
418
  subject.setup(:custom_step, options) { true }
383
419
  end
384
420
  end
385
421
  end
386
422
  end
387
423
 
388
- describe "#group" do
424
+ describe '#group' do
389
425
  let(:name) { :reset }
390
426
 
391
- context "when the name is in the groups to run" do
427
+ context 'when the name is in the groups to run' do
392
428
  let(:groups) { [:reset, :init] }
393
429
 
394
- it "calls the supplied block" do
430
+ it 'calls the supplied block' do
395
431
  expect { |b| subject.group(name, &b) }.to yield_control
396
432
  end
397
433
  end
398
434
 
399
- context "when the name is not in the groups to run" do
435
+ context 'when the name is not in the groups to run' do
400
436
  let(:groups) { [:init] }
401
437
 
402
- it "does not call the supplied block" do
438
+ it 'does not call the supplied block' do
403
439
  expect { |b| subject.group(name, &b) }.not_to yield_control
404
440
  end
405
441
 
406
- context "but no groups to run are provided" do
442
+ context 'but no groups to run are provided' do
407
443
  let(:groups) { nil }
408
444
 
409
- it "calls the supplied block" do
445
+ it 'calls the supplied block' do
410
446
  expect { |b| subject.group(name, &b) }.to yield_control
411
447
  end
412
448
  end