Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 0b4c98d

Browse files
mvzJonRowe
authored andcommitted
Update aruba dependency (#2609)
* Depend on latest Aruba release * Aruba has deprecated `in_current_directory` fix that * Remove remaining use of in_current_dir * Replace use of clean_current_dir with setup_aruba * Remove use of deprecated #dirs method * Replace #remove_file with #remove * Replace #set_env with #set_environment_variable * Replace call to #run_simple with #run_command_and_stop * Remove custom fail-with-output step * Remove custom pass-with-output step * DRY up output checks by reintroducing all_output helper
1 parent f17a414 commit 0b4c98d

17 files changed

+60
-66
lines changed

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,6 @@ end
6464

6565
gem 'test-unit', '~> 3.0' if RUBY_VERSION.to_f >= 2.2
6666

67+
gem 'contracts', '< 0.16' if RUBY_VERSION < '1.9.0'
68+
6769
eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom')

features/formatters/configurable_colors.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Feature: Configurable colors
1212
Colors are specified as symbols. Options are `:black`, `:red`, `:green`,
1313
`:yellow`, `:blue`, `:magenta`, `:cyan`, and `:white`.
1414

15-
@ansi
15+
@keep-ansi-escape-sequences
1616
Scenario: Customizing the failure color
1717
Given a file named "custom_failure_color_spec.rb" with:
1818
"""ruby

features/step_definitions/additional_cli_steps.rb

+18-26
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Then /^the output should contain all of these:$/ do |table|
66
table.raw.flatten.each do |string|
7-
assert_partial_output(string, all_output)
7+
expect(all_output).to include(string)
88
end
99
end
1010

@@ -28,11 +28,6 @@
2828
step %q{the exit status should be 0}
2929
end
3030

31-
Then /^it should pass with "(.*?)"$/ do |string|
32-
step %Q{the output should contain "#{string}"}
33-
step %q{the exit status should be 0}
34-
end
35-
3631
Then /^the example(?:s)? should(?: all)? fail$/ do
3732
step %q{the output should not contain "0 examples"}
3833
step %q{the output should not contain "0 failures"}
@@ -98,24 +93,23 @@
9893
end
9994

10095
Given /^I have a brand new project with no files$/ do
101-
in_current_dir do
96+
cd('.') do
10297
expect(Dir["**/*"]).to eq([])
10398
end
10499
end
105100

106101
Given /^I have run `([^`]*)`$/ do |cmd|
107-
fail_on_error = true
108-
run_simple(unescape(cmd), fail_on_error)
102+
run_command_and_stop(sanitize_text(cmd), :fail_on_error => true)
109103
end
110104

111105
Given(/^a vendored gem named "(.*?)" containing a file named "(.*?)" with:$/) do |gem_name, file_name, file_contents|
112106
gem_dir = "vendor/#{gem_name}-1.2.3"
113107
step %Q{a file named "#{gem_dir}/#{file_name}" with:}, file_contents
114-
set_env('RUBYOPT', ENV['RUBYOPT'] + " -I#{gem_dir}/lib")
108+
set_environment_variable('RUBYOPT', ENV['RUBYOPT'] + " -I#{gem_dir}/lib")
115109
end
116110

117111
When "I accept the recommended settings by removing `=begin` and `=end` from `spec/spec_helper.rb`" do
118-
in_current_dir do
112+
cd('.') do
119113
spec_helper = File.read("spec/spec_helper.rb")
120114
expect(spec_helper).to include("=begin", "=end")
121115

@@ -138,20 +132,16 @@
138132
end
139133

140134
When(/^I fix "(.*?)" by replacing "(.*?)" with "(.*?)"$/) do |file_name, original, replacement|
141-
in_current_dir do
135+
cd('.') do
142136
contents = File.read(file_name)
143137
expect(contents).to include(original)
144138
fixed = contents.sub(original, replacement)
145139
File.open(file_name, "w") { |f| f.write(fixed) }
146140
end
147141
end
148142

149-
Then(/^it should fail with "(.*?)"$/) do |snippet|
150-
assert_failing_with(snippet)
151-
end
152-
153143
Given(/^I have not configured `example_status_persistence_file_path`$/) do
154-
in_current_dir do
144+
cd('.') do
155145
return unless File.exist?("spec/spec_helper.rb")
156146
return unless File.read("spec/spec_helper.rb").include?("example_status_persistence_file_path")
157147
File.open("spec/spec_helper.rb", "w") { |f| f.write("") }
@@ -173,10 +163,10 @@
173163
end
174164

175165
Then(/^bisect should (succeed|fail) with output like:$/) do |succeed, expected_output|
176-
last_process = only_processes.last
166+
last_process = all_commands.last
177167
expected_status = succeed == "succeed" ? 0 : 1
178-
expect(last_exit_status).to eq(expected_status),
179-
"Expected exit status of #{expected_status} but got #{last_exit_status} \n\n" \
168+
expect(last_process.exit_status).to eq(expected_status),
169+
"Expected exit status of #{expected_status} but got #{last_process.exit_status} \n\n" \
180170
"Output:\n\n#{last_process.stdout}"
181171

182172
expected = normalize_durations(expected_output)
@@ -191,7 +181,7 @@
191181
end
192182

193183
When(/^I run `([^`]+)` and abort in the middle with ctrl\-c$/) do |cmd|
194-
set_env('RUBYOPT', ENV['RUBYOPT'] + " -r#{File.expand_path("../../support/send_sigint_during_bisect.rb", __FILE__)}")
184+
set_environment_variable('RUBYOPT', ENV['RUBYOPT'] + " -r#{File.expand_path("../../support/send_sigint_during_bisect.rb", __FILE__)}")
195185
step "I run `#{cmd}`"
196186
end
197187

@@ -218,19 +208,21 @@
218208
# - "Nested" group listed (it should be the outer group)
219209
# - The example group class name is listed (it should be the location)
220210

221-
expect(all_output).not_to match(/nested/i)
222-
expect(all_output).not_to match(/inf/i)
223-
expect(all_output).not_to match(/\b0 examples/i)
211+
output = all_output
212+
213+
expect(output).not_to match(/nested/i)
214+
expect(output).not_to match(/inf/i)
215+
expect(output).not_to match(/\b0 examples/i)
224216

225217
seconds = '\d+(?:\.\d+)? seconds'
226218

227-
expect(all_output).to match(
219+
expect(output).to match(
228220
%r{Top 1 slowest example groups?:\n\s+slow before context hook\n\s+#{seconds} average \(#{seconds} / 1 example\) \./spec/example_spec\.rb:1}
229221
)
230222
end
231223

232224
Given(/^I have changed `([^`]+)` to `([^`]+)` in "(.*?)"$/) do |old_code, new_code, file_name|
233-
in_current_dir do
225+
cd('.') do
234226
file_content = File.read(file_name)
235227
expect(file_content).to include(old_code)
236228
new_file_content = file_content.sub(old_code, new_code)

features/step_definitions/core_standalone_steps.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
if RUBY_VERSION.to_f >= 1.9 # --disable-gems is invalid on 1.8.7
33
# Ensure the gem versions of rspec-mocks and rspec-expectations
44
# won't be loaded if available on the developers machine.
5-
set_env('RUBYOPT', ENV['RUBYOPT'] + ' --disable-gems')
5+
set_environment_variable('RUBYOPT', ENV['RUBYOPT'] + ' --disable-gems')
66
end
77

88
# This will make `require_expect_syntax_in_aruba_specs.rb` (loaded
99
# automatically when the specs run) remove rspec-mocks and
1010
# rspec-expectations from the load path.
11-
set_env('REMOVE_OTHER_RSPEC_LIBS_FROM_LOAD_PATH', 'true')
11+
set_environment_variable('REMOVE_OTHER_RSPEC_LIBS_FROM_LOAD_PATH', 'true')
1212
end
1313

1414
Given(/^rspec-expectations is not installed$/) do

features/support/env.rb

+13-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Before do
44
# Force ids to be printed unquoted for consistency
5-
set_env('SHELL', '/usr/bin/bash')
5+
set_environment_variable('SHELL', '/usr/bin/bash')
66

77
if RUBY_PLATFORM =~ /java/ || defined?(Rubinius)
88
@aruba_timeout_seconds = 120
@@ -12,13 +12,21 @@
1212
end
1313

1414
Aruba.configure do |config|
15-
config.before_cmd do |cmd|
16-
set_env('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}") # disable JIT since these processes are so short lived
15+
config.before(:command) do |cmd|
16+
set_environment_variable('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}") # disable JIT since these processes are so short lived
1717
end
1818
end if RUBY_PLATFORM == 'java'
1919

2020
Aruba.configure do |config|
21-
config.before_cmd do |cmd|
22-
set_env('RBXOPT', "-Xint=true #{ENV['RBXOPT']}") # disable JIT since these processes are so short lived
21+
config.before(:command) do |cmd|
22+
set_environment_variable('RBXOPT', "-Xint=true #{ENV['RBXOPT']}") # disable JIT since these processes are so short lived
2323
end
2424
end if defined?(Rubinius)
25+
26+
module ArubaHelpers
27+
def all_output
28+
all_commands.map { |c| c.output }.join("\n")
29+
end
30+
end
31+
32+
World(ArubaHelpers)

features/support/require_expect_syntax_in_aruba_specs.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
if defined?(Cucumber)
22
require 'shellwords'
33
Before('~@allow-should-syntax', '~@with-clean-spec-opts') do
4-
set_env('SPEC_OPTS', "-r#{Shellwords.escape(__FILE__)}")
4+
set_environment_variable('SPEC_OPTS', "-r#{Shellwords.escape(__FILE__)}")
55
end
66

77
Before('@oneliner-should') do
8-
set_env('ALLOW_ONELINER_SHOULD', 'true')
8+
set_environment_variable('ALLOW_ONELINER_SHOULD', 'true')
99
end
1010
else
1111
if ENV['REMOVE_OTHER_RSPEC_LIBS_FROM_LOAD_PATH']

rspec-core.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Gem::Specification.new do |s|
4747

4848
s.add_development_dependency "cucumber", "~> 1.3"
4949
s.add_development_dependency "minitest", "~> 5.3"
50-
s.add_development_dependency "aruba", "~> 0.6.2" # 0.7 is broken on ruby 1.8.7
50+
s.add_development_dependency "aruba", "~> 0.14.9"
5151

5252
s.add_development_dependency "coderay", "~> 1.1.1"
5353

spec/integration/bisect_runners_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
module RSpec::Core
77
RSpec.shared_examples_for "a bisect runner" do
88
include_context "aruba support"
9-
before { clean_current_dir }
9+
before { setup_aruba }
1010

1111
let(:shell_command) { Bisect::ShellCommand.new([]) }
1212

1313
def with_runner(&block)
1414
handle_current_dir_change do
15-
in_current_dir do
15+
cd '.' do
1616
options = ConfigurationOptions.new(shell_command.original_cli_args)
1717
runner = Runner.new(options)
1818
output = StringIO.new
@@ -124,7 +124,7 @@ def with_runner(&block)
124124
runner.run(%w[ ./spec/a_spec.rb[1:1] ])
125125
end
126126

127-
in_current_dir do
127+
cd '.' do
128128
expect(File.read('spec_helper_loads')).to eq(".")
129129
end
130130
end

spec/integration/fail_if_no_examples_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.describe 'Fail if no examples' do
44
include_context "aruba support"
5-
before { clean_current_dir }
5+
before { setup_aruba }
66

77
context 'when 1 passing example' do
88
def passing_example(fail_if_no_examples)

spec/integration/failed_line_detection_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.describe 'Failed line detection' do
44
include_context "aruba support"
5-
before { clean_current_dir }
5+
before { setup_aruba }
66

77
it "finds the source of a failure in a spec file that is defined at the current directory instead of in the normal `spec` subdir" do
88
write_file "the_spec.rb", "
@@ -32,7 +32,7 @@
3232
end
3333
"
3434

35-
file = in_current_dir { "#{Dir.pwd}/failing_spec.rb" }
35+
file = cd('.') { "#{Dir.pwd}/failing_spec.rb" }
3636
load file
3737
run_command "passing_spec.rb"
3838

spec/integration/filtering_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.describe 'Filtering' do
44
include_context "aruba support"
5-
before { clean_current_dir }
5+
before { setup_aruba }
66

77
it 'prints a rerun command for shared examples in external files that works to rerun' do
88
write_file "spec/support/shared_examples.rb", "
@@ -205,7 +205,7 @@ def run_rerun_command_for_failing_spec
205205
expect(last_cmd_stdout).to match(/3 examples, 0 failures/)
206206

207207
# Using absolute paths...
208-
spec_root = in_current_dir { File.expand_path("spec") }
208+
spec_root = cd('.') { File.expand_path("spec") }
209209
run_command "#{spec_root}/file_1_spec.rb[1:1,1:3] #{spec_root}/file_2_spec.rb[1:2]"
210210
expect(last_cmd_stdout).to match(/3 examples, 0 failures/)
211211
end

spec/integration/order_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
end
132132

133133
describe '--order defined on CLI with --order rand in .rspec' do
134-
after { remove_file '.rspec' }
134+
after { remove '.rspec' }
135135

136136
it "overrides --order rand with --order defined" do
137137
write_file '.rspec', '--order rand'
@@ -147,7 +147,7 @@
147147
end
148148

149149
context 'when a custom order is configured' do
150-
after { remove_file 'spec/custom_order_spec.rb' }
150+
after { remove 'spec/custom_order_spec.rb' }
151151

152152
before do
153153
write_file 'spec/custom_order_spec.rb', "

spec/integration/output_stream_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.describe 'Output stream' do
44
include_context 'aruba support'
5-
before { clean_current_dir }
5+
before { setup_aruba }
66

77
context 'when a formatter set in a configure block' do
88
it 'writes to the right output stream' do
@@ -21,7 +21,7 @@
2121

2222
run_command ''
2323
expect(last_cmd_stdout).to be_empty
24-
in_current_dir do
24+
cd '.' do
2525
expect(File.read('saved_output')).to include('1 example, 0 failures')
2626
end
2727
end
@@ -42,7 +42,7 @@
4242

4343
run_command ''
4444
expect(last_cmd_stdout).to be_empty
45-
in_current_dir do
45+
cd '.' do
4646
expect(File.read('saved_output')).to include('1 example, 0 failures')
4747
end
4848
end
@@ -64,7 +64,7 @@
6464

6565
run_command ''
6666
expect(last_cmd_stdout).to be_empty
67-
in_current_dir do
67+
cd '.' do
6868
expect(File.read('saved_output')).to include('1 example, 0 failures')
6969
end
7070
end

spec/integration/persistence_failures_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.describe 'Persistence failures' do
44
include_context "aruba support"
5-
before { clean_current_dir }
5+
before { setup_aruba }
66

77
context "when `config.example_status_persistence_file_path` is configured" do
88
context "to an invalid file path (e.g. spec/spec_helper.rb/examples.txt)" do
@@ -38,7 +38,7 @@
3838
"
3939

4040
write_file_formatted "spec/examples.txt", ""
41-
in_current_dir do
41+
cd '.' do
4242
FileUtils.chmod 0000, "spec/examples.txt"
4343
end
4444
end

spec/integration/spec_file_load_errors_spec.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@
1818
end
1919

2020
before do
21-
# get out of `aruba` sub-dir so that `filter_gems_from_backtrace 'aruba'`
22-
# below does not filter out our spec file.
23-
expect(dirs.pop).to eq "aruba"
24-
25-
clean_current_dir
21+
setup_aruba
2622

2723
RSpec.configure do |c|
28-
c.filter_gems_from_backtrace "aruba"
24+
c.filter_gems_from_backtrace "gems/aruba"
2925
c.backtrace_exclusion_patterns << %r{/rspec-core/spec/} << %r{rspec_with_simplecov}
3026
c.failure_exit_code = failure_exit_code
3127
end

spec/integration/suite_hooks_errors_spec.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@
1818
end
1919

2020
before do
21-
# get out of `aruba` sub-dir so that `filter_gems_from_backtrace 'aruba'`
22-
# below does not filter out our spec file.
23-
expect(dirs.pop).to eq "aruba"
24-
25-
clean_current_dir
21+
setup_aruba
2622

2723
RSpec.configure do |c|
28-
c.filter_gems_from_backtrace "aruba"
24+
c.filter_gems_from_backtrace "gems/aruba"
2925
c.backtrace_exclusion_patterns << %r{/rspec-core/spec/} << %r{rspec_with_simplecov}
3026
c.failure_exit_code = failure_exit_code
3127
end

spec/support/aruba_support.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def run_command(cmd)
2323
cmd_parts = Shellwords.split(cmd)
2424

2525
handle_current_dir_change do
26-
in_current_dir do
26+
cd '.' do
2727
@last_cmd_exit_status = RSpec::Core::Runner.run(cmd_parts, temp_stderr, temp_stdout)
2828
end
2929
end

0 commit comments

Comments
 (0)