Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
taketo1113 opened this issue Feb 7, 2023 · 0 comments

Comments

@taketo1113
Copy link

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant