Class: RSpec::Core::ExampleStatusPersister
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/example_status_persister.rb
Overview
Persists example ids and their statuses so that we can filter to just the ones that failed the last time they ran.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(examples, file_name) ⇒ ExampleStatusPersister
constructor
A new instance of ExampleStatusPersister.
- #persist ⇒ Object
Constructor Details
#initialize(examples, file_name) ⇒ ExampleStatusPersister
Returns a new instance of ExampleStatusPersister.
18 19 20 21 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/example_status_persister.rb', line 18 def initialize(examples, file_name) @examples = examples @file_name = file_name end |
Class Method Details
.load_from(file_name) ⇒ Object
9 10 11 12 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/example_status_persister.rb', line 9 def self.load_from(file_name) return [] unless File.exist?(file_name) ExampleStatusParser.parse(File.read(file_name)) end |
.persist(examples, file_name) ⇒ Object
14 15 16 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/example_status_persister.rb', line 14 def self.persist(examples, file_name) new(examples, file_name).persist end |
Instance Method Details
#persist ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/example_status_persister.rb', line 23 def persist RSpec::Support::DirectoryMaker.mkdir_p(File.dirname(@file_name)) File.open(@file_name, File::RDWR | File::CREAT) do |f| # lock the file while reading / persisting to avoid a race # condition where parallel or unrelated spec runs race to # update the same file f.flock(File::LOCK_EX) unparsed_previous_runs = f.read f.rewind f.write(dump_statuses(unparsed_previous_runs)) f.flush f.truncate(f.pos) end end |