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

Commit 473e3ed

Browse files
committed
Fix flickering test.
Profile example group ordering no longer relies on `example.clock`. It relies directly on `RSpec::Core::Time.now` so we have to update the spec to make it consistent.
1 parent bc11555 commit 473e3ed

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

spec/rspec/core/formatters/json_formatter_spec.rb

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,19 @@ def profile *groups
163163

164164
context "with multiple example groups", :slow do
165165
before do
166-
example_clock = class_double(RSpec::Core::Time, :now => RSpec::Core::Time.now + 5)
166+
start = Time.utc(2015, 6, 10, 12, 30)
167+
now = start
168+
169+
allow(RSpec::Core::Time).to receive(:now) { now }
167170

168171
group1 = RSpec.describe("slow group") do
169-
example("example") do |example|
170-
# make it look slow without actually taking up precious time
171-
example.clock = example_clock
172-
end
172+
example("example") { }
173+
after { now += 100 }
173174
end
174175
group2 = RSpec.describe("fast group") do
175176
example("example 1") { }
176177
example("example 2") { }
178+
after { now += 1 }
177179
end
178180
profile group1, group2
179181
end
@@ -187,14 +189,6 @@ def profile *groups
187189
end
188190

189191
it "ranks the example groups by average time" do |ex|
190-
if ENV['TRAVIS'] && RSpec::Support::Ruby.mri? && RUBY_VERSION == '2.0.0' &&
191-
$original_rspec_configuration.loaded_spec_files.to_a == [File.expand_path(__FILE__)]
192-
RSpec.current_example = ex # necessary due to sandboxing so that `skip` works.
193-
skip "This spec fails on Travis on MRI 2.0.0 only when this spec file runs " \
194-
"individually. It passes on Travis when run as part of the entire suite " \
195-
"and I can't repro locally, so we are skipping it for this case."
196-
end
197-
198192
expect(formatter.output_hash[:profile][:groups].first[:description]).to eq("slow group")
199193
end
200194
end

0 commit comments

Comments
 (0)