File: integration_specs.rb

package info (click to toggle)
ruby-hashie 5.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 884 kB
  • sloc: ruby: 7,049; sh: 8; makefile: 6
file content (36 lines) | stat: -rw-r--r-- 1,226 bytes parent folder | download | duplicates (3)
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
29
30
31
32
33
34
35
36
# Generates the bundle command for running an integration test
#
# @param [String] integration the integration folder to run
# @param [String] command the command to run
# @return [String]
def integration_command(integration, command)
  "#{integration_gemfile(integration)} #{command}"
end

# Generates the Gemfile for an integration
#
# @param [String] integration the integration test name
# @return [String]
def integration_gemfile(integration)
  "BUNDLE_GEMFILE=#{integration_path(integration)}/Gemfile"
end

# Generates the path to the integration
#
# @param [String] integration the integration test name
# @return [String]
def integration_path(integration)
  "spec/integration/#{integration}"
end

# Runs all integration specs in their own environment
def run_all_integration_specs(handler: ->(_code) {}, logger: ->(_msg) {})
  Dir['spec/integration/*']
    .map { |directory| directory.split('/').last }
    .each do |integration|
      logger.call(%(Running "#{integration}" integration spec))
      system(integration_command(integration, 'bundle --quiet'))
      system(integration_command(integration, "bundle exec rspec #{integration_path(integration)}"))
      handler.call($CHILD_STATUS.exitstatus)
    end
end