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 Caching #506

Open
taketo1113 opened this issue Mar 2, 2023 · 0 comments · May be fixed by #507
Open

Ruby 3.0 ArgumentError: wrong number of arguments error with Caching #506

taketo1113 opened this issue Mar 2, 2023 · 0 comments · May be fixed by #507

Comments

@taketo1113
Copy link

It raises the error of wrong number of arguments when exec Cell::Caching#render_state with conditionals helper method in ruby 3.0.

Steps to reproduce

ref: taketo1113@1fb75e0

  it "with cache condition helper method" do
    WithCondition = Class.new(Cell::ViewModel) do
      cache :show, if: :enable_cache?, expires_in: 10

      def show
        "Test"
      end

      def cache_store
        STORE
      end

      def enable_cache?
        true
      end
    end

    _(WithCondition.new.(:show)).must_equal("Test")
  end

Expected behavior

It will pass test WithCondition cell with keyword args.

Actual behavior

It raises the below error.

  1) Error:
CacheTest#test_0006_with cache condition helper method:
ArgumentError: wrong number of arguments (given 1, expected 0)
    /__path__/cells/test/cache_test.rb:126:in `enable_cache?'
    /__path__/cells/vendor/bundle/ruby/3.0.0/gems/trailblazer-option-0.1.2/lib/trailblazer/option.rb:9:in `call'
    /__path__/cells/vendor/bundle/ruby/3.0.0/gems/trailblazer-option-0.1.2/lib/trailblazer/option.rb:9:in `public_send'
    /__path__/cells/vendor/bundle/ruby/3.0.0/gems/trailblazer-option-0.1.2/lib/trailblazer/option.rb:9:in `call!'
    /__path__/cells/vendor/bundle/ruby/3.0.0/gems/trailblazer-option-0.1.2/lib/trailblazer/option.rb:36:in `evaluate_method'
    /__path__/cells/vendor/bundle/ruby/3.0.0/gems/trailblazer-option-0.1.2/lib/trailblazer/option.rb:50:in `call'
    /__path__/cells/vendor/bundle/ruby/3.0.0/gems/trailblazer-option-0.1.2/lib/trailblazer/option.rb:50:in `block in build'
    /__path__/cells/lib/cell/caching.rb:62:in `cache?'
    /__path__/cells/lib/cell/caching.rb:48:in `render_state'
    /__path__/cells/lib/cell/view_model.rb:92:in `call'
    /__path__/cells/test/cache_test.rb:131:in `block in <class:CacheTest>'

115 runs, 157 assertions, 0 failures, 1 errors, 0 skips

Focus on failing tests:
ruby test/cache_test.rb -l 114

It is empty hash value([{}]) in cache_filter_args at Cell::Caching#render_state.
Then call helper method with wrong args ([{}]) in Cell::Caching#cache?.

https://github.com/trailblazer/cells/blob/master/lib/cell/caching.rb#L46

      cache_filter_args = args + [kws]

# cache_filter_args => [{}]
# args => []
# kws => {}
# **kws =>

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