braintree / runbook

A framework for gradual system automation
MIT License
730 stars 43 forks source link

Ruby 3 compatibility issue? :into keyword in `ask?` #40

Open fwolfst opened 3 years ago

fwolfst commented 3 years ago

When invoking ask in a runbook which is executed with ruby 3.0 (3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]), following errors are thrown:

/home/felix/.rvm/gems/ruby-3.0.0/gems/runbook-1.0.0/lib/runbook/statements/ask.rb:5:in `initialize': wrong number of arguments (given 2, expected 1; required keyword: into) (ArgumentError)

The invocation seems correct, like ask 'E-Mail-Address of user:', into: 'email' and works in older ruby versions.

I assume this has to do with how keyword arguments are handled in ruby 3.

Other specs also do not pass with ruby 3 (and manually loosened bundler constraint).

E.g. a similar case as for the "ask" case fails like this:

34) Runbook::Runner shared variables capture_all command captures cmd on all hosts
      Failure/Error:
        def initialize(cmd, into:, ssh_config: nil, raw: false, strip: true)
          @cmd = cmd
          @into = into
          @ssh_config = ssh_config
          @raw = raw
          @strip = strip
        end

      ArgumentError:
        wrong number of arguments (given 2, expected 1; required keyword: into)
      # ./lib/runbook/statements/capture_all.rb:5:in `initialize'
      # ./lib/runbook/extensions/statements.rb:6:in `new'
      # ./lib/runbook/extensions/statements.rb:6:in `method_missing'
      # ./spec/runner_spec.rb:1036:in `block (7 levels) in <top (required)>'
      # ./lib/runbook/extensions/steps.rb:16:in `instance_eval'
      # ./lib/runbook/extensions/steps.rb:16:in `block in step'
      # <internal:kernel>:90:in `tap'
      # ./lib/runbook/extensions/steps.rb:14:in `step'
      # ./spec/runner_spec.rb:1033:in `block (6 levels) in <top (required)>'
      # ./lib/runbook/extensions/sections.rb:11:in `instance_eval'
      # ./lib/runbook/extensions/sections.rb:11:in `block in section'
      # <internal:kernel>:90:in `tap'
      # ./lib/runbook/extensions/sections.rb:9:in `section'
      # ./spec/runner_spec.rb:1032:in `block (5 levels) in <top (required)>'
      # ./lib/runbook.rb:96:in `instance_eval'
      # ./lib/runbook.rb:96:in `block in book'
      # <internal:kernel>:90:in `tap'
      # ./lib/runbook.rb:95:in `book'
      # ./spec/runner_spec.rb:1031:in `block (4 levels) in <top (required)>'
      # ./spec/runner_spec.rb:30:in `block (2 levels) in <top (required)>'
      # ./spec/runner_spec.rb:1060:in `block (4 levels) in <top (required)>'
      # /home/felix/.rvm/gems/ruby-3.0.0/gems/aruba-0.14.14/lib/aruba/rspec.rb:22:in `block (2 levels) in <top (required)>'
fwolfst commented 3 years ago

Pretty sure it has to do with mandatory keyword argument splatting in lib/runbook/extensions/statements.rb#method_missing .

coopergillan commented 2 years ago

@fwolfst - have you been able to confirm that the latest release resolves this issue? Version 1.1.0 includes support for Ruby 3.0.