Module: Testivai::Config
- Defined in:
- lib/testivai/config.rb
Overview
Reads .testivai/config.json, the same file every other TestivAI adapter
reads. Absent or malformed config falls back to defaults rather than
raising: a broken config should not fail somebody's test suite.
Constant Summary collapse
- DEFAULTS =
{ "stabilize" => true, "ignoreSelectors" => [], "baselinesDir" => nil }.freeze
Class Method Summary collapse
- .load(root) ⇒ Object
-
.project_root(start = Dir.pwd) ⇒ Object
Walk up from
startlooking for a.testivai/directory, the way Bundler finds a Gemfile.
Class Method Details
.load(root) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/testivai/config.rb', line 28 def self.load(root) path = Pathname.new(root).join(".testivai", "config.json") return DEFAULTS.dup unless path.file? DEFAULTS.merge(JSON.parse(path.read)) rescue JSON::ParserError, SystemCallError DEFAULTS.dup end |
.project_root(start = Dir.pwd) ⇒ Object
Walk up from start looking for a .testivai/ directory, the way
Bundler finds a Gemfile. Falls back to start so a first run in a
fresh project still writes somewhere sensible.
20 21 22 23 24 25 26 |
# File 'lib/testivai/config.rb', line 20 def self.project_root(start = Dir.pwd) current = Pathname.new(start). current.ascend do |dir| return dir if dir.join(".testivai").directory? end Pathname.new(start). end |