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

Update aruba dependency #2609

Merged
merged 17 commits into from
Mar 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ end

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

gem 'contracts', '< 0.16' if RUBY_VERSION < '1.9.0'

eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom')
2 changes: 1 addition & 1 deletion features/formatters/configurable_colors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: Configurable colors
Colors are specified as symbols. Options are `:black`, `:red`, `:green`,
`:yellow`, `:blue`, `:magenta`, `:cyan`, and `:white`.

@ansi
@keep-ansi-escape-sequences
Scenario: Customizing the failure color
Given a file named "custom_failure_color_spec.rb" with:
"""ruby
Expand Down
44 changes: 18 additions & 26 deletions features/step_definitions/additional_cli_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Then /^the output should contain all of these:$/ do |table|
table.raw.flatten.each do |string|
assert_partial_output(string, all_output)
expect(all_output).to include(string)
end
end

Expand All @@ -28,11 +28,6 @@
step %q{the exit status should be 0}
end

Then /^it should pass with "(.*?)"$/ do |string|
step %Q{the output should contain "#{string}"}
step %q{the exit status should be 0}
end

Then /^the example(?:s)? should(?: all)? fail$/ do
step %q{the output should not contain "0 examples"}
step %q{the output should not contain "0 failures"}
Expand Down Expand Up @@ -98,24 +93,23 @@
end

Given /^I have a brand new project with no files$/ do
in_current_dir do
cd('.') do
expect(Dir["**/*"]).to eq([])
end
end

Given /^I have run `([^`]*)`$/ do |cmd|
fail_on_error = true
run_simple(unescape(cmd), fail_on_error)
run_command_and_stop(sanitize_text(cmd), :fail_on_error => true)
end

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

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

Expand All @@ -138,20 +132,16 @@
end

When(/^I fix "(.*?)" by replacing "(.*?)" with "(.*?)"$/) do |file_name, original, replacement|
in_current_dir do
cd('.') do
contents = File.read(file_name)
expect(contents).to include(original)
fixed = contents.sub(original, replacement)
File.open(file_name, "w") { |f| f.write(fixed) }
end
end

Then(/^it should fail with "(.*?)"$/) do |snippet|
assert_failing_with(snippet)
end

Given(/^I have not configured `example_status_persistence_file_path`$/) do
in_current_dir do
cd('.') do
return unless File.exist?("spec/spec_helper.rb")
return unless File.read("spec/spec_helper.rb").include?("example_status_persistence_file_path")
File.open("spec/spec_helper.rb", "w") { |f| f.write("") }
Expand All @@ -173,10 +163,10 @@
end

Then(/^bisect should (succeed|fail) with output like:$/) do |succeed, expected_output|
last_process = only_processes.last
last_process = all_commands.last
expected_status = succeed == "succeed" ? 0 : 1
expect(last_exit_status).to eq(expected_status),
"Expected exit status of #{expected_status} but got #{last_exit_status} \n\n" \
expect(last_process.exit_status).to eq(expected_status),
"Expected exit status of #{expected_status} but got #{last_process.exit_status} \n\n" \
"Output:\n\n#{last_process.stdout}"

expected = normalize_durations(expected_output)
Expand All @@ -191,7 +181,7 @@
end

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

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

expect(all_output).not_to match(/nested/i)
expect(all_output).not_to match(/inf/i)
expect(all_output).not_to match(/\b0 examples/i)
output = all_output

expect(output).not_to match(/nested/i)
expect(output).not_to match(/inf/i)
expect(output).not_to match(/\b0 examples/i)

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

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

Given(/^I have changed `([^`]+)` to `([^`]+)` in "(.*?)"$/) do |old_code, new_code, file_name|
in_current_dir do
cd('.') do
file_content = File.read(file_name)
expect(file_content).to include(old_code)
new_file_content = file_content.sub(old_code, new_code)
Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/core_standalone_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
if RUBY_VERSION.to_f >= 1.9 # --disable-gems is invalid on 1.8.7
# Ensure the gem versions of rspec-mocks and rspec-expectations
# won't be loaded if available on the developers machine.
set_env('RUBYOPT', ENV['RUBYOPT'] + ' --disable-gems')
set_environment_variable('RUBYOPT', ENV['RUBYOPT'] + ' --disable-gems')
end

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

Given(/^rspec-expectations is not installed$/) do
Expand Down
18 changes: 13 additions & 5 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Before do
# Force ids to be printed unquoted for consistency
set_env('SHELL', '/usr/bin/bash')
set_environment_variable('SHELL', '/usr/bin/bash')

if RUBY_PLATFORM =~ /java/ || defined?(Rubinius)
@aruba_timeout_seconds = 120
Expand All @@ -12,13 +12,21 @@
end

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

Aruba.configure do |config|
config.before_cmd do |cmd|
set_env('RBXOPT', "-Xint=true #{ENV['RBXOPT']}") # disable JIT since these processes are so short lived
config.before(:command) do |cmd|
set_environment_variable('RBXOPT', "-Xint=true #{ENV['RBXOPT']}") # disable JIT since these processes are so short lived
end
end if defined?(Rubinius)

module ArubaHelpers
def all_output
all_commands.map { |c| c.output }.join("\n")
end
end

World(ArubaHelpers)
4 changes: 2 additions & 2 deletions features/support/require_expect_syntax_in_aruba_specs.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
if defined?(Cucumber)
require 'shellwords'
Before('~@allow-should-syntax', '~@with-clean-spec-opts') do
set_env('SPEC_OPTS', "-r#{Shellwords.escape(__FILE__)}")
set_environment_variable('SPEC_OPTS', "-r#{Shellwords.escape(__FILE__)}")
end

Before('@oneliner-should') do
set_env('ALLOW_ONELINER_SHOULD', 'true')
set_environment_variable('ALLOW_ONELINER_SHOULD', 'true')
end
else
if ENV['REMOVE_OTHER_RSPEC_LIBS_FROM_LOAD_PATH']
Expand Down
2 changes: 1 addition & 1 deletion rspec-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Gem::Specification.new do |s|

s.add_development_dependency "cucumber", "~> 1.3"
s.add_development_dependency "minitest", "~> 5.3"
s.add_development_dependency "aruba", "~> 0.6.2" # 0.7 is broken on ruby 1.8.7
s.add_development_dependency "aruba", "~> 0.14.9"

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

Expand Down
6 changes: 3 additions & 3 deletions spec/integration/bisect_runners_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
module RSpec::Core
RSpec.shared_examples_for "a bisect runner" do
include_context "aruba support"
before { clean_current_dir }
before { setup_aruba }

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

def with_runner(&block)
handle_current_dir_change do
in_current_dir do
cd '.' do
options = ConfigurationOptions.new(shell_command.original_cli_args)
runner = Runner.new(options)
output = StringIO.new
Expand Down Expand Up @@ -124,7 +124,7 @@ def with_runner(&block)
runner.run(%w[ ./spec/a_spec.rb[1:1] ])
end

in_current_dir do
cd '.' do
expect(File.read('spec_helper_loads')).to eq(".")
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/fail_if_no_examples_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe 'Fail if no examples' do
include_context "aruba support"
before { clean_current_dir }
before { setup_aruba }

context 'when 1 passing example' do
def passing_example(fail_if_no_examples)
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/failed_line_detection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe 'Failed line detection' do
include_context "aruba support"
before { clean_current_dir }
before { setup_aruba }

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
write_file "the_spec.rb", "
Expand Down Expand Up @@ -32,7 +32,7 @@
end
"

file = in_current_dir { "#{Dir.pwd}/failing_spec.rb" }
file = cd('.') { "#{Dir.pwd}/failing_spec.rb" }
load file
run_command "passing_spec.rb"

Expand Down
4 changes: 2 additions & 2 deletions spec/integration/filtering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe 'Filtering' do
include_context "aruba support"
before { clean_current_dir }
before { setup_aruba }

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

# Using absolute paths...
spec_root = in_current_dir { File.expand_path("spec") }
spec_root = cd('.') { File.expand_path("spec") }
run_command "#{spec_root}/file_1_spec.rb[1:1,1:3] #{spec_root}/file_2_spec.rb[1:2]"
expect(last_cmd_stdout).to match(/3 examples, 0 failures/)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
end

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

it "overrides --order rand with --order defined" do
write_file '.rspec', '--order rand'
Expand All @@ -147,7 +147,7 @@
end

context 'when a custom order is configured' do
after { remove_file 'spec/custom_order_spec.rb' }
after { remove 'spec/custom_order_spec.rb' }

before do
write_file 'spec/custom_order_spec.rb', "
Expand Down
8 changes: 4 additions & 4 deletions spec/integration/output_stream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe 'Output stream' do
include_context 'aruba support'
before { clean_current_dir }
before { setup_aruba }

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

run_command ''
expect(last_cmd_stdout).to be_empty
in_current_dir do
cd '.' do
expect(File.read('saved_output')).to include('1 example, 0 failures')
end
end
Expand All @@ -42,7 +42,7 @@

run_command ''
expect(last_cmd_stdout).to be_empty
in_current_dir do
cd '.' do
expect(File.read('saved_output')).to include('1 example, 0 failures')
end
end
Expand All @@ -64,7 +64,7 @@

run_command ''
expect(last_cmd_stdout).to be_empty
in_current_dir do
cd '.' do
expect(File.read('saved_output')).to include('1 example, 0 failures')
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/persistence_failures_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe 'Persistence failures' do
include_context "aruba support"
before { clean_current_dir }
before { setup_aruba }

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

write_file_formatted "spec/examples.txt", ""
in_current_dir do
cd '.' do
FileUtils.chmod 0000, "spec/examples.txt"
end
end
Expand Down
8 changes: 2 additions & 6 deletions spec/integration/spec_file_load_errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@
end

before do
# get out of `aruba` sub-dir so that `filter_gems_from_backtrace 'aruba'`
# below does not filter out our spec file.
expect(dirs.pop).to eq "aruba"

clean_current_dir
setup_aruba

RSpec.configure do |c|
c.filter_gems_from_backtrace "aruba"
c.filter_gems_from_backtrace "gems/aruba"
c.backtrace_exclusion_patterns << %r{/rspec-core/spec/} << %r{rspec_with_simplecov}
c.failure_exit_code = failure_exit_code
end
Expand Down
8 changes: 2 additions & 6 deletions spec/integration/suite_hooks_errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@
end

before do
# get out of `aruba` sub-dir so that `filter_gems_from_backtrace 'aruba'`
# below does not filter out our spec file.
expect(dirs.pop).to eq "aruba"

clean_current_dir
setup_aruba

RSpec.configure do |c|
c.filter_gems_from_backtrace "aruba"
c.filter_gems_from_backtrace "gems/aruba"
c.backtrace_exclusion_patterns << %r{/rspec-core/spec/} << %r{rspec_with_simplecov}
c.failure_exit_code = failure_exit_code
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/aruba_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def run_command(cmd)
cmd_parts = Shellwords.split(cmd)

handle_current_dir_change do
in_current_dir do
cd '.' do
@last_cmd_exit_status = RSpec::Core::Runner.run(cmd_parts, temp_stderr, temp_stdout)
end
end
Expand Down