class CypressRails::Init
Constants
- DEFAULT_CONFIG
Public Instance Methods
call(dir = Dir.pwd)
click to toggle source
# File lib/cypress-rails/init.rb, line 9 def call(dir = Dir.pwd) config_path = File.join(dir, "cypress.json") json = JSON.pretty_generate(determine_new_config(config_path)) File.write(config_path, json) puts "Cypress config (re)initialized in #{config_path}" end
Private Instance Methods
determine_new_config(config_path)
click to toggle source
# File lib/cypress-rails/init.rb, line 18 def determine_new_config(config_path) if File.exist?(config_path) merge_existing_with_defaults(config_path) else DEFAULT_CONFIG end end
merge_existing_with_defaults(json_path)
click to toggle source
# File lib/cypress-rails/init.rb, line 26 def merge_existing_with_defaults(json_path) JSON.parse(File.read(json_path)).merge(DEFAULT_CONFIG).sort.to_h end