class Rspec::Rotten::ExampleStore
Constants
- ROTTEN_DURATION
1 year duration when AS is not available
Attributes
file_path[RW]
records[RW]
Public Class Methods
new()
click to toggle source
# File lib/rspec/rotten/example_store.rb, line 14 def initialize() @file_path = Rspec::Rotten::Configuration.results_file @records = File.exists?(@file_path) ? JSON.parse(read_example_data) : [] end
Public Instance Methods
delete(example)
click to toggle source
# File lib/rspec/rotten/example_store.rb, line 23 def delete(example) @records.delete example end
find(example)
click to toggle source
# File lib/rspec/rotten/example_store.rb, line 19 def find(example) @records.find{ |x| x['id'] == example.id } end
notify_rotten()
click to toggle source
# File lib/rspec/rotten/example_store.rb, line 40 def notify_rotten if @rotten.any? @message = %Q{ \n\nYou have #{@rotten.count} specs that haven't failed for extended period of time.\n\t \n\nYou may want to consider removing them:\n\t #{@records.map {|example| example['description'] + " - " + example['location'] }.join("\n\t")} \n } RSpec::Core::Formatters::ConsoleCodes.wrap(@message, :pending) end end
rotten()
click to toggle source
use config for date
# File lib/rspec/rotten/example_store.rb, line 35 def rotten rotten_duration = Rspec::Rotten::Configuration.time_to_rotten || ROTTEN_TIME @rotten ||= @records.select {|x| !x['date'].nil? && x['date'] < Time.now() - rotten_duration } end
save()
click to toggle source
# File lib/rspec/rotten/example_store.rb, line 27 def save f = File.open(@file_path,"w") f.truncate(0) f.write(@records.to_json) f.close end
Private Instance Methods
read_example_data()
click to toggle source
# File lib/rspec/rotten/example_store.rb, line 54 def read_example_data if File.exists? @file_path f = File.open(@file_path, 'r') data = f.read f.close data end end