Top Level Namespace

Defined Under Namespace

Modules: FixtureLoading, Macmillan, RackTestHelper

Instance Method Summary collapse

Methods included from FixtureLoading

#load_json_data, #load_text_data, #load_yaml_data

Methods included from RackTestHelper

#env_for, #req_for

Instance Method Details

#check_config_file(filename) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/macmillan/utils/rspec/rspec_defaults.rb', line 3

def check_config_file(filename)
  # ASSUMPTION: We are running the RSpec suite from the root of a project tree
  update_config     = true
  local_config_file = File.join(Dir.getwd, filename)

  if File.exist?(local_config_file)
    @message ||= []

    latest_conf_path = File.expand_path("../../../../../#{filename}", __FILE__)
    latest_conf      = File.read(latest_conf_path)
    @message << "macmillan-utils config file = #{latest_conf_path}"

    current_conf = File.read(local_config_file)
    @message << "current repo config file = #{local_config_file}"

    update_config = false if current_conf == latest_conf
  end

  File.open(local_config_file, 'w') { |file| file.print(latest_conf) } if update_config

  update_config
end