Skip to content

Ruby 3.0 ArgumentError: wrong number of arguments error with keyword args for Cell::Testing #504

@taketo1113

Description

@taketo1113

It raises the error of wrong number of arguments when exec Cell::Testing#call with keyword args in ruby 3.0.

Steps to reproduce

ref: taketo1113@4505a53

# test/testing_test.rb
class CapybaraTest < MiniTest::Spec
  class CapybaraCell < Cell::ViewModel
    def show_with_keyargs(text: '')
      "<p>text</p>"
    end
  end

  describe "capybara support" do
    subject { cell("capybara_test/capybara", nil) }

    it { _(subject.(:show_with_keyargs, text: 'with keyargs').has_selector?('p')).must_equal true }
  end
end

Expected behavior

It will pass test show_with_keyargs cell with keyword args.

Actual behavior

It raises the below error.

  1) Error:
capybara support#test_0002_anonymous:
ArgumentError: wrong number of arguments (given 1, expected 0)
    /path/cells/test/testing_test.rb:50:in `show_with_keyargs'
    /path/cells/lib/cell/view_model.rb:114:in `render_state'
    /path/cells/lib/cell/caching.rb:48:in `render_state'
    /path/cells/lib/cell/view_model.rb:92:in `call'
    /path/cells/lib/cell/testing.rb:47:in `call'
    /path/cells/test/testing_test.rb:63:in `block (2 levels) in <class:CapybaraTest>'

114 runs, 156 assertions, 0 failures, 1 errors, 0 skips

Focus on failing tests:
ruby test/testing_test.rb -l 63

It can't get show_with_keyargs args of keyword args in CapybaraCell#show_with_keyargs.
Because Cell::Testing#call does not support keyword args.

https://github.com/trailblazer/cells/blob/master/lib/cell/testing.rb#L46-L48

System configuration

  • ruby: 3.0.5
  • cells: (github master branch)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions