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

Updating usage of Aruba. #2459

Closed
wants to merge 3 commits into from
Closed
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
4 changes: 2 additions & 2 deletions features/command_line/only_failures.feature
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ Feature: Only Failures

Scenario: Running `rspec --only-failures` with spec files that pass doesn't run anything
When I run `rspec spec/passing_spec.rb --only-failures`
Then it should pass with "0 examples, 0 failures"
Then it should pass with output "0 examples, 0 failures"

Scenario: Clear error given when using `--only-failures` without configuring `example_status_persistence_file_path`
Given I have not configured `example_status_persistence_file_path`
When I run `rspec --only-failures`
Then it should fail with "To use `--only-failures`, you must first set `config.example_status_persistence_file_path`."
Then it should fail with output "To use `--only-failures`, you must first set `config.example_status_persistence_file_path`."
4 changes: 2 additions & 2 deletions features/configuration/fail_if_no_examples.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Feature: fail if no examples

Scenario: Examples file name is not matched by RSpec pattern, thus there are no examples run
When I run `rspec`
Then it should fail with "0 examples, 0 failures"
Then it should fail with output "0 examples, 0 failures"

Scenario: Examples file name is matched by RSpec pattern, 1 example is run
When I run `rspec --pattern spec/**/*.spec.rb`
Then it should pass with "1 example, 0 failures"
Then it should pass with output "1 example, 0 failures"
6 changes: 3 additions & 3 deletions features/filtering/filter_run_when_matching.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Feature: filter_run_when_matching

Scenario: The filter is ignored when nothing is focused
When I run `rspec --format doc`
Then it should pass with "2 examples, 0 failures"
Then it should pass with output "2 examples, 0 failures"
And the output should contain:
"""
A group
Expand All @@ -56,7 +56,7 @@ Feature: filter_run_when_matching
Scenario: Examples can be focused with `fit`
Given I have changed `it "has a passing example"` to `fit "has a passing example"` in "spec/example_spec.rb"
When I run `rspec --format doc`
Then it should pass with "1 example, 0 failures"
Then it should pass with output "1 example, 0 failures"
And the output should contain:
"""
A group
Expand All @@ -66,7 +66,7 @@ Feature: filter_run_when_matching
Scenario: Groups can be focused with `fdescribe` or `fcontext`
Given I have changed `context` to `fcontext` in "spec/example_spec.rb"
When I run `rspec --format doc`
Then it should pass with "1 example, 0 failures"
Then it should pass with output "1 example, 0 failures"
And the output should contain:
"""
A group
Expand Down
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
57 changes: 31 additions & 26 deletions features/step_definitions/additional_cli_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

Then /^the output should contain all of these:$/ do |table|
table.raw.flatten.each do |string|
assert_partial_output(string, all_output)
expect(all_commands.map { |c| c.output }.join("\n")).to include(string)
end
end

Then /^the output should not contain any of these:$/ do |table|
table.raw.flatten.each do |string|
expect(all_output).not_to include(string)
expect(all_commands.map { |c| c.output }.join("\n")).not_to include(string)
end
end

Then /^the output should contain one of the following:$/ do |table|
matching_output = table.raw.flatten.select do |string|
all_output.include?(string)
all_commands.map { |c| c.output }.join("\n").include?(string)
end

expect(matching_output.count).to eq(1)
Expand All @@ -28,7 +28,7 @@
step %q{the exit status should be 0}
end

Then /^it should pass with "(.*?)"$/ do |string|
Then /^it should pass with output "(.*?)"$/ do |string|
step %Q{the output should contain "#{string}"}
step %q{the exit status should be 0}
end
Expand All @@ -37,7 +37,9 @@
step %q{the output should not contain "0 examples"}
step %q{the output should not contain "0 failures"}
step %q{the exit status should be 1}
example_summary = /(\d+) examples?, (\d+) failures?/.match(all_output)
example_summary = /(\d+) examples?, (\d+) failures?/.match(
all_commands.map { |c| c.output }.join("\n")
)
example_count, failure_count = example_summary.captures
expect(failure_count).to eq(example_count)
end
Expand Down Expand Up @@ -69,7 +71,7 @@
Then /^the backtrace\-normalized output should contain:$/ do |partial_output|
# ruby 1.9 includes additional stuff in the backtrace,
# so we need to normalize it to compare it with our expected output.
normalized_output = all_output.split("\n").map do |line|
normalized_output = all_commands.map { |c| c.output }.map do |line|
line =~ /(^\s+# [^:]+:\d+)/ ? $1 : line # http://rubular.com/r/zDD7DdWyzF
end.join("\n")

Expand All @@ -84,7 +86,7 @@
Then /^the failing example is printed in magenta$/ do
# \e[35m = enable magenta
# \e[0m = reset colors
expect(all_output).to include("\e[35m" + "F" + "\e[0m")
expect(all_commands.map { |c| c.output }.join("\n")).to include("\e[35m" + "F" + "\e[0m")
end

Then /^the output from `([^`]+)` should contain "(.*?)"$/ do |cmd, expected_output|
Expand All @@ -98,24 +100,24 @@
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_simple(sanitize_text(cmd), fail_on_error)
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 +140,21 @@
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)
Then(/^it should fail with output "(.*?)"$/) do |snippet|
expect(all_commands).not_to include_an_object(be_successfully_executed)
expect(all_commands.map { |c| c.output }.join("\n")).to include(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 +176,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 @@ -186,18 +189,18 @@
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

Then(/^it should fail and list all the failures:$/) do |string|
step %q{the exit status should not be 0}
expect(normalize_failure_output(all_output)).to include(normalize_failure_output(string))
expect(normalize_failure_output(all_commands.map { |c| c.output }.join("\n"))).to include(normalize_failure_output(string))
end

Then(/^it should pass and list all the pending examples:$/) do |string|
step %q{the exit status should be 0}
expect(normalize_failure_output(all_output)).to include(normalize_failure_output(string))
expect(normalize_failure_output(all_commands.map { |c| c.output }.join("\n"))).to include(normalize_failure_output(string))
end

Then(/^the output should report "slow before context hook" as the slowest example group$/) do
Expand All @@ -213,19 +216,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_commands.map { |c| c.output }.join("\n")

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
10 changes: 5 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,13 @@
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)
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
3 changes: 2 additions & 1 deletion rspec-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ 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.2" # 0.7 is broken on ruby 1.8.7
s.add_development_dependency "contracts", "< 0.16" # 0.16 does not work with Ruby 1.8.7

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

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
Loading