Skip to content

Commit

Permalink
Add --rails-command option
Browse files Browse the repository at this point in the history
  • Loading branch information
palkan committed Sep 14, 2024
1 parent 84a2558 commit 5f2c3c2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/anyt/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ def parse_options!(args)
configure_rails_command!
end

cli.on("--rails-command=COMMAND", "A custom command to run Rails server") do |cmd|
configure_rails_command!(cmd)
Anyt.config.custom_action_cable = true
end

cli.on("--only test1,test2,test3", Array, "Run only specified tests") do |only_tests|
Anyt.config.only_tests = only_tests
end
Expand Down Expand Up @@ -196,8 +201,8 @@ def parse_options!(args)
exit 1
end

def configure_rails_command!
Anyt.config.command = RAILS_COMMAND
def configure_rails_command!(cmd = RAILS_COMMAND)
Anyt.config.command = cmd % {config: DUMMY_ROOT}
Anyt.config.use_action_cable = true
end

Expand Down
1 change: 1 addition & 0 deletions lib/anyt/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def restart
AnyCable.logger.debug "Restarting command PID: #{process.pid}"

stop

process.wait

run
Expand Down
1 change: 1 addition & 0 deletions lib/anyt/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Config < Anyway::Config
:tests_relative_path,
remote_control_port: 8919,
use_action_cable: false,
custom_action_cable: false,
target_url: "ws://localhost:9292/cable",
wait_command: 2,
timeout_multiplier: 1
Expand Down
2 changes: 1 addition & 1 deletion lib/anyt/ext/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def build_client(**args)
end

def restart_server!
if Anyt.config.use_action_cable
if Anyt.config.use_action_cable && !Anyt.config.custom_action_cable
remote_client.restart_action_cable
else
Command.restart
Expand Down

0 comments on commit 5f2c3c2

Please sign in to comment.