summaryrefslogtreecommitdiff
path: root/features/step_definitions/config_steps.rb
blob: 1fc67f50b237bbcd35cde12854e4cdbceda062e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# use with @tempfile, @config
Given /there is a config for the (.*)$/ do |config|
  @dummy_config = {dummy_config_for: config}.to_json
  @tempfile = Tempfile.new("#{config}.json")
  @tempfile.write @dummy_config
  @tempfile.close
  if config == 'provider'
    StaticConfigController::PROVIDER_JSON = @tempfile.path
  else
    @orig_config ||= APP_CONFIG.dup
    APP_CONFIG[:config_file_paths].merge! "#{config}-service" => @tempfile.path
  end
end

# use with @config
Given /^"([^"]*)" is (enabled|disabled|"[^"]") in the config$/ do |key, value|
  @orig_config ||= APP_CONFIG.dup
  value = case value
          when 'disabled' then false
          when 'enabled' then true
          else value.gsub('"', '')
          end
  APP_CONFIG.merge! key => value
end

Then /^the response should be that config$/ do
  assert_equal @dummy_config, last_response.body
end