Skip to content

Commit 8014aa9

Browse files
authored
[NO-TICKET] Fix failing "Ruby gem scaffolding" CI (#1153)
* Fix specs failing due to slightly changed behavior on ruby-master Some of our tests use ```ruby let(:temporary_directory) { "does/not/exist" } ``` and in ruby/fileutils#132 the behavior of `FileUtils.remove_dir` was tweaked to change the exception that gets raised when doing `FileUtils.remove_dir` with a directory that doesn't exist. I've updated the test clean-up hook with the new exception as well. * Minor: Add `irb` to development dependencies May come in handy sometimes (and does not affect what we ship to customers). * Minor: Refresh rspec configuration As per https://ivoanjo.me/blog/2016/09/25/why-you-should-regenerate-your-spec-helper/
1 parent b596807 commit 8014aa9

File tree

3 files changed

+57
-4
lines changed

3 files changed

+57
-4
lines changed

ruby/gems.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
gem "pry"
1212
gem "pry-byebug" unless RUBY_VERSION > "3.1"
1313
gem "rubygems-await" unless RUBY_VERSION < "3.1"
14+
gem "irb"

ruby/spec/libdatadog_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
after do
2626
begin
2727
FileUtils.remove_dir(temporary_directory)
28-
rescue Errno::ENOENT => _e
28+
rescue Errno::ENOENT, Errno::ENOTDIR
2929
# Do nothing, it's ok
3030
end
3131
end

ruby/spec/spec_helper.rb

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,66 @@
44

55
require "libdatadog"
66

7+
# This file was generated by the `rspec --init` command + manually tweaked.
8+
#
9+
# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
710
RSpec.configure do |config|
8-
# Enable flags like --only-failures and --next-failure
11+
config.expect_with :rspec do |expectations|
12+
# This option will default to `true` in RSpec 4.
13+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
14+
end
15+
16+
config.mock_with :rspec do |mocks|
17+
# This will default to `true` in RSpec 4.
18+
mocks.verify_partial_doubles = true
19+
end
20+
21+
# This option will default to `:apply_to_host_groups` in RSpec 4.
22+
config.shared_context_metadata_behavior = :apply_to_host_groups
23+
24+
# This allows you to limit a spec run to individual examples or groups
25+
# you care about by tagging them with `:focus` metadata. When nothing
26+
# is tagged with `:focus`, all examples get run. RSpec also provides
27+
# aliases for `it`, `describe`, and `context` that include `:focus`
28+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
29+
config.filter_run_when_matching :focus
30+
31+
# Allows RSpec to persist some state between runs in order to support
32+
# the `--only-failures` and `--next-failure` CLI options. We recommend
33+
# you configure your source control system to ignore this file.
934
config.example_status_persistence_file_path = ".rspec_status"
1035

1136
# Disable RSpec exposing methods globally on `Module` and `main`
1237
config.disable_monkey_patching!
1338

14-
config.expect_with :rspec do |c|
15-
c.syntax = :expect
39+
# This setting enables warnings. It's recommended, but in some cases may
40+
# be too noisy due to issues in dependencies.
41+
config.warnings = true
42+
43+
# Many RSpec users commonly either run the entire suite or an individual
44+
# file, and it's useful to allow more verbose output when running an
45+
# individual spec file.
46+
if config.files_to_run.one?
47+
# Use the documentation formatter for detailed output,
48+
# unless a formatter has already been configured
49+
# (e.g. via a command-line flag).
50+
config.default_formatter = "doc"
1651
end
52+
53+
# Print the 10 slowest examples and example groups at the
54+
# end of the spec run, to help surface which specs are running
55+
# particularly slow.
56+
config.profile_examples = 10
57+
58+
# Run specs in random order to surface order dependencies. If you find an
59+
# order dependency and want to debug it, you can fix the order by providing
60+
# the seed, which is printed after each run.
61+
# --seed 1234
62+
config.order = :random
63+
64+
# Seed global randomization in this process using the `--seed` CLI option.
65+
# Setting this allows you to use `--seed` to deterministically reproduce
66+
# test failures related to randomization by passing the same `--seed` value
67+
# as the one that triggered the failure.
68+
Kernel.srand config.seed
1769
end

0 commit comments

Comments
 (0)