Class: Bake::Test::Integration::Controller
- Inherits:
-
Object
- Object
- Bake::Test::Integration::Controller
- Defined in:
- lib/bake/test/integration/controller.rb
Overview
Runs Docker Compose integration test scenarios.
Constant Summary collapse
- COMPOSE_FILE =
"docker-compose.yaml"- DEFAULT_COMMAND =
["docker", "compose"].freeze
Instance Method Summary collapse
-
#initialize(root = Dir.pwd, command: DEFAULT_COMMAND, runner: Kernel.method(:system)) ⇒ Controller
constructor
Initialize a controller for the given project root.
-
#run(name: nil, path: "integration", service: "tests", build: true) ⇒ Object
Run one or all integration test scenarios.
-
#scenarios(path: "integration") ⇒ Object
Enumerate integration test scenario directories in deterministic order.
Constructor Details
#initialize(root = Dir.pwd, command: DEFAULT_COMMAND, runner: Kernel.method(:system)) ⇒ Controller
Initialize a controller for the given project root.
20 21 22 23 24 |
# File 'lib/bake/test/integration/controller.rb', line 20 def initialize(root = Dir.pwd, command: DEFAULT_COMMAND, runner: Kernel.method(:system)) @root = Pathname.new(root) @command = command @runner = runner end |
Instance Method Details
#run(name: nil, path: "integration", service: "tests", build: true) ⇒ Object
Run one or all integration test scenarios.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/bake/test/integration/controller.rb', line 39 def run(name: nil, path: "integration", service: "tests", build: true) scenarios = self.scenarios(path: path) if name scenarios.select!{|scenario| scenario.basename.to_s == name.to_s} end if scenarios.empty? raise ArgumentError, "No integration test scenarios found#{" for #{name.inspect}" if name}!" end scenarios.each do |scenario| run_scenario(scenario, service: service, build: build) end end |
#scenarios(path: "integration") ⇒ Object
Enumerate integration test scenario directories in deterministic order.
29 30 31 |
# File 'lib/bake/test/integration/controller.rb', line 29 def scenarios(path: "integration") @root.join(path).glob("*/#{COMPOSE_FILE}").sort.map(&:dirname) end |