-
-
Notifications
You must be signed in to change notification settings - Fork 762
Make World.reset also reset example group counts #2723
Conversation
Can we get a spec for this? Something along the lines of creating a world, adding some examples and showing that the hash is not 0 unless reset? |
@JonRowe I was instead thinking something on a higher-level, like: require "rspec/core"
require "stringio"
# RSpec.describe "foo" do
# it "bar" do
# expect(true).to be true
# end
# end
def truncate_timings(output)
output.gsub(/Finished in.*\n/, '')
end
expected_output = StringIO.new
actual_output = StringIO.new
opts = RSpec::Core::ConfigurationOptions.new(["./foo_spec.rb[1:1]"])
RSpec::Core::Runner.new(opts).run(nil, $stderr)
expected_output = truncate_timings(expected_output.string)
RSpec.clear_examples
opts = RSpec::Core::ConfigurationOptions.new(["./foo_spec.rb[1:1]"])
# without the fix, the following invocation executes 0 examples
RSpec::Core::Runner.new(opts).run(nil, $stderr)
actual_output = truncate_timings(actual_output.string)
# expected_output == actual_output Thoughts? I think this way it's more apparent what the fix is about. If that seems good, could you point me to some similar specs from RSpec's codebase which I can follow as examples? That said, I don't really like the part with comparing the outputs, perhaps there's a more future-proof way of doing this? The point is to verify that the correct example ran once in each invocation. |
We have a bunch of integration specs in |
@JonRowe Added unit and integration specs (see #2723 (comment) though). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, some stylistic changes and a fix for your aruba issue.
If we don't reset example group counts in custom runners that run from the same process, example metadata end up being published with incorrect scoped IDs. World#example_group_counts_by_spec_file is merely added for testability. Fixes #2721
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I'll merge on green, thanks so much! 💜 ❤️ 💚 💛 🧡
Make World.reset also reset example group counts
That is fortunately only needed in rspec-core versions equal or less than 3.9.1, since 3.9.2 includes the relevant fix[1]. [1] rspec/rspec-core#2723
That is fortunately only needed in rspec-core versions equal or less than 3.9.1, since 3.9.2 includes the relevant fix[1]. [1] rspec/rspec-core#2723
This is fortunately only needed in rspec-core versions equal or less than 3.9.1, since 3.9.2 includes the relevant fix[1]. [1] rspec/rspec-core#2723
Make World.reset also reset example group counts
…-core#2721-world-reset Make World.reset also reset example group counts --- This commit was imported from rspec/rspec-core@16f21bd.
This commit was imported from rspec/rspec-core@a1b6ee2.
If we don't reset example group counts in custom runners that run from
the same process, example metadata end up being published with incorrect
scoped IDs.
World#example_group_counts_by_spec_file
is merely added for testability.Fixes #2721