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

Fix ArgumentError: wrong number of arguments for Cell::Testing #505

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
444b6c4
Add concise #inpsect to ViewModel
May 13, 2016
fafbe0a
Refactor #inspect to a modular extensible solution
May 14, 2016
834aae9
Fix inspect_test.rb to work with ruby 2.0.0
May 14, 2016
d0ed61b
bump cells-erb dev dependency to >= 0.1.0
george-carlin May 11, 2017
91e6315
Merge pull request #452 from georgemillo/cells-erb-dev-dependency
apotonick May 11, 2017
27c62c1
README: Build badge point to trailblazer [ci skip]
olleolleolle Sep 12, 2017
7c1cf8d
Merge pull request #457 from olleolleolle/patch-1
apotonick Sep 12, 2017
c4e6b9d
Update tested Ruby version
iGEL Mar 19, 2018
3df9f32
Merge pull request #466 from iGEL/travis
george-carlin Mar 24, 2018
a0f1336
Merge pull request #399 from shvetsovdm/concise_cell_inspect
george-carlin Mar 27, 2018
9ea1ee8
fix warning for undefined instance variable
seuros Apr 24, 2018
2313a8e
Merge pull request #469 from trailblazer/fix-warning
seuros Apr 24, 2018
036dea8
Use Tilt::Cache instead of our own cache implementation
Scharrels Apr 27, 2018
ee8133d
Split file lookup and template parsing
Scharrels Apr 27, 2018
1e4ec99
Merge pull request #470 from Quarantainenet/tilt-cache
timoschilling Apr 27, 2018
0c9f655
Drop support for old rubies
seuros Jul 20, 2018
e9f7f87
remove OutputBuffer Module from cells
seuros Jul 20, 2018
2d33ad0
Merge pull request #475 from trailblazer/ruby-upgrade
seuros Jul 28, 2018
9d7ed5b
CI: Drop unused Travis sudo: false directive
olleolleolle Jul 29, 2019
e29d693
Merge pull request #481 from olleolleolle/patch-1
seuros Jul 29, 2019
4501202
update minitest syntax
seuros Jul 20, 2020
7b2a52d
Merge pull request #486 from trailblazer/upMinitest
seuros Jul 21, 2020
bbbaffa
Update documentation links
th1988 Oct 2, 2020
595baa7
Setup GH action CI
yogeshjain999 May 30, 2021
3942762
Merge pull request #489 from th1988/patch-1
yogeshjain999 May 30, 2021
e20413e
Use trailblazer-option over declarative-option and upgrade declarativ…
yogeshjain999 Jun 11, 2021
3070404
Add Ruby 3.1 to CI (#495)
petergoldstein Jan 18, 2022
8eae3a1
Expect {*args, **kws} everywhere so this code is *really* Ruby 3 safe.
apotonick Feb 1, 2022
88796e3
two versions of `#render_state` for Ruby <2.7 and after.
apotonick Feb 1, 2022
b7c4b1f
Forward args in ruby3 style after cache hit (#497)
yogeshjain999 Jun 7, 2022
93add13
fix Gemfile
seuros Dec 6, 2022
b437c5b
CI: add Ruby 3.2 to the test matrix
orien Jan 16, 2023
19e6f88
Merge pull request #500 from orien/ruby3.2
apotonick Jan 17, 2023
75bbcc0
Add project metadata to the gemspec
orien Jan 16, 2023
7f620b4
Merge pull request #501 from orien/gem-metadata
apotonick Jan 17, 2023
4505a53
Fixed ArgumentError: wrong number of arguments for testing
taketo1113 Feb 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: CI
on: [push, pull_request]
jobs:
test:
strategy:
fail-fast: false
matrix:
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
ruby: [2.5, 2.6, 2.7, '3.0', 3.1, 3.2, head]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- run: bundle exec rake
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 4.5.0

* Drop support for rubies prior 2.2.10

## 4.1.8

* Fix ruby warning with undefined instance variable in codebase

## 4.1.7

* `Collection#join` can now be called without a block.
Expand Down
10 changes: 7 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
source "https://rubygems.org"

gem "minitest", "~> 5.2"
gem "cells-erb"#, path: "../cells-erb"
gem "benchmark-ips"
gem "minitest-line"

gemspec

# gem "uber", path: "../uber"
case ENV["GEMS_SOURCE"]
when "local"
gem "cells-erb", path: "../cells-erb"
# gem "erbse", path: "../erbse"
when "github"
gem "cells-erb", github: "trailblazer/cells-erb"
end
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

*View Components for Ruby and Rails.*

[![Gitter Chat](https://badges.gitter.im/trailblazer/chat.svg)](https://gitter.im/trailblazer/chat)
[![TRB Newsletter](https://img.shields.io/badge/TRB-newsletter-lightgrey.svg)](http://trailblazer.to/newsletter/)
[![Zulip Chat](https://badges.gitter.im/trailblazer/chat.svg)](https://trailblazer.zulipchat.com/login/)
[![TRB Newsletter](https://img.shields.io/badge/TRB-newsletter-lightgrey.svg)](https://trailblazer.to/2.0/newsletter.html)
[![Build
Status](https://travis-ci.org/apotonick/cells.svg)](https://travis-ci.org/apotonick/cells)
Status](https://travis-ci.org/trailblazer/cells.svg)](https://travis-ci.org/trailblazer/cells)
[![Gem Version](https://badge.fury.io/rb/cells.svg)](http://badge.fury.io/rb/cells)

## Overview

Cells allow you to encapsulate parts of your UI into components into _view models_. View models, or cells, are simple ruby classes that can render templates.

Nevertheless, a cell gives you more than just a template renderer. They allow proper OOP, polymorphic builders, [nesting](#nested-cells), view inheritance, using Rails helpers, [asset packaging](http://trailblazer.to/gems/cells/rails.html#asset-pipeline) to bundle JS, CSS or images, simple distribution via gems or Rails engines, encapsulated testing, [caching](#caching), and [integrate with Trailblazer](https://github.com/trailblazer/trailblazer-cells).
Nevertheless, a cell gives you more than just a template renderer. They allow proper OOP, polymorphic builders, [nesting](#nested-cells), view inheritance, using Rails helpers, [asset packaging](https://trailblazer.to/2.1/docs/cells.html#cells-rails-asset-pipeline) to bundle JS, CSS or images, simple distribution via gems or Rails engines, encapsulated testing, [caching](#caching), and [integrate with Trailblazer](https://github.com/trailblazer/trailblazer-cells).

## Full Documentation

Cells is part of the Trailblazer framework. [Full documentation](http://trailblazer.to/gems/cells) is available on the project site.
Cells is part of the Trailblazer framework. [Full documentation](https://trailblazer.to/2.1/docs/cells.html) is available on the project site.

Cells is completely decoupled from Rails. However, Rails-specific functionality is to be found [here](http://trailblazer.to/gems/cells/rails.html).
Cells is completely decoupled from Rails. However, Rails-specific functionality is to be found [here](https://trailblazer.to/2.1/docs/cells.html#cells-rails).

## Rendering Cells

Expand Down Expand Up @@ -151,7 +151,7 @@ Capybara.string(html).must_have_css "h3"

It is completely up to you how you test, whether it's RSpec, MiniTest or whatever. All the cell does is return HTML.

[In Rails, there's support](http://trailblazer.to/gems/cells/testing.html) for TestUnit, MiniTest and RSpec available, along with Capybara integration.
[In Rails, there's support](https://trailblazer.to/2.1/docs/cells.html#cells-testing) for TestUnit, MiniTest and RSpec available, along with Capybara integration.

## Properties

Expand Down Expand Up @@ -182,7 +182,7 @@ song.title #=> "<script>Dangerous</script>"
Comment::Cell.(song).title #=> &lt;script&gt;Dangerous&lt;/script&gt;
```

Properties and escaping are [documented here](http://trailblazer.to/gems/cells/api.html#html-escaping).
Properties and escaping are [documented here](https://trailblazer.to/2.1/docs/cells.html#cells-api-html-escaping).

## Installation

Expand Down Expand Up @@ -270,7 +270,7 @@ end

## Asset Packaging

Cells can easily ship with their own JavaScript, CSS and more and be part of Rails' asset pipeline. Bundling assets into a cell allows you to implement super encapsulated widgets that are stand-alone. Asset pipeline is [documented here](http://trailblazer.to/gems/cells/rails.html#asset-pipeline).
Cells can easily ship with their own JavaScript, CSS and more and be part of Rails' asset pipeline. Bundling assets into a cell allows you to implement super encapsulated widgets that are stand-alone. Asset pipeline is [documented here](https://trailblazer.to/2.1/docs/cells.html#cells-rails-asset-pipeline).

## Render API

Expand Down Expand Up @@ -344,7 +344,7 @@ This works both in cell views and on the instance, in states.

## View Inheritance

You can not only inherit code across cell classes, but also views. This is extremely helpful if you want to override parts of your UI, only. It's [documented here](http://trailblazer.to/gems/cells/api.html#view-inheritance).
You can not only inherit code across cell classes, but also views. This is extremely helpful if you want to override parts of your UI, only. It's [documented here](https://trailblazer.to/2.1/docs/cells.html#cells-api-view-inheritance).

## Collections

Expand All @@ -357,7 +357,7 @@ cell(:comment, collection: comments).()

This will invoke `cell(:comment, comment).()` three times and concatenate the rendered output automatically.

Learn more [about collections here](http://trailblazer.to/gems/cells/api.html#collection).
Learn more [about collections here](https://trailblazer.to/2.1/docs/cells.html#cells-api-collection).


## Builder
Expand All @@ -382,7 +382,7 @@ The `#cell` helper takes care of instantiating the right cell class for you.
cell(:comment, Post.find(1)) #=> creates a PostCell.
```

Learn more [about builders here](http://trailblazer.to/gems/cells/api.html#builder).
Learn more [about builders here](https://trailblazer.to/2.1/docs/cells.html#cells-api-builder).

## Caching

Expand All @@ -401,7 +401,7 @@ The `::cache` method will forward options to the caching engine.
cache :show, expires_in: 10.minutes
```

You can also compute your own cache key, use dynamic keys, cache tags, and conditionals using `:if`. Caching is documented [here](http://trailblazer.to/gems/cells/api.html#caching) and in chapter 8 of the [Trailblazer book](http://leanpub.com/trailblazer).
You can also compute your own cache key, use dynamic keys, cache tags, and conditionals using `:if`. Caching is documented [here](https://trailblazer.to/2.1/docs/cells.html#cells-api-caching) and in chapter 8 of the [Trailblazer book](http://leanpub.com/trailblazer).


## The Book
Expand All @@ -422,11 +422,11 @@ The book picks up where the README leaves off. Go grab a copy and support us - i

## This is not Cells 3.x!

Temporary note: This is the README and API for Cells 4. Many things have improved. If you want to upgrade, [follow this guide](https://github.com/apotonick/cells/wiki/From-Cells-3-to-Cells-4---Upgrading-Guide). When in trouble, join the [Gitter channel](https://gitter.im/trailblazer/chat).
Temporary note: This is the README and API for Cells 4. Many things have improved. If you want to upgrade, [follow this guide](https://github.com/apotonick/cells/wiki/From-Cells-3-to-Cells-4---Upgrading-Guide). When in trouble, join the [Zulip channel](https://trailblazer.zulipchat.com/login/).

## LICENSE

Copyright (c) 2007-2015, Nick Sutterer
Copyright (c) 2007-2020, Nick Sutterer

Copyright (c) 2007-2008, Solide ICT by Peter Bex and Bob Leers

Expand Down
37 changes: 0 additions & 37 deletions benchmarks/class_builder.rb

This file was deleted.

47 changes: 0 additions & 47 deletions benchmarks/collection.rb

This file was deleted.

46 changes: 26 additions & 20 deletions cells.gemspec
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
lib = File.expand_path("../lib/", __FILE__)
$:.unshift lib unless $:.include?(lib)
# frozen_string_literal: true

require "cell/version"
require_relative 'lib/cell/version'

Gem::Specification.new do |spec|
spec.name = "cells"
spec.name = 'cells'
spec.version = Cell::VERSION
spec.platform = Gem::Platform::RUBY
spec.authors = ["Nick Sutterer"]
spec.email = ["[email protected]"]
spec.homepage = "https://github.com/apotonick/cells"
spec.summary = %q{View Models for Ruby and Rails.}
spec.description = %q{View Models for Ruby and Rails, replacing helpers and partials while giving you a clean view architecture with proper encapsulation.}
spec.license = "MIT"
spec.authors = ['Nick Sutterer']
spec.email = ['[email protected]']
spec.homepage = 'https://github.com/trailblazer/cells'
spec.summary = 'View Models for Ruby and Rails.'
spec.description = 'View Models for Ruby and Rails, replacing helpers and partials while giving you a clean view architecture with proper encapsulation.'
spec.license = 'MIT'

spec.metadata['bug_tracker_uri'] = "#{spec.homepage}/issues"
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/HEAD/CHANGES.md"
spec.metadata['documentation_uri'] = 'https://trailblazer.to/2.1/docs/cells'
spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = spec.homepage
spec.metadata['wiki_uri'] = "#{spec.homepage}/wiki"

spec.files = `git ls-files`.split("\n")
spec.test_files = `git ls-files -- {test}/*`.split("\n")
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.require_paths = ['lib']
spec.required_ruby_version = '>= 2.2.10'

spec.add_dependency "uber", "< 0.2.0"
spec.add_dependency "declarative-option", "< 0.2.0"
spec.add_dependency "declarative-builder", "< 0.2.0"
spec.add_dependency "tilt", ">= 1.4", "< 3"
spec.add_dependency 'declarative-builder', '~> 0.2.0'
spec.add_dependency 'tilt', '>= 1.4', '< 3'
spec.add_dependency 'trailblazer-option', '~> 0.1.0'
spec.add_dependency 'uber', '< 0.2.0'

spec.add_development_dependency "rake"
spec.add_development_dependency "capybara"
spec.add_development_dependency "cells-erb", ">= 0.0.4"
spec.add_development_dependency 'capybara'
spec.add_development_dependency 'cells-erb', '>= 0.1.0'
spec.add_development_dependency 'minitest'
spec.add_development_dependency 'rake'
end
2 changes: 1 addition & 1 deletion lib/cell.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require "tilt"
require "uber/inheritable_attr"
require "cell/version"

module Cell
autoload :Testing, "cell/testing"
Expand All @@ -18,6 +17,7 @@ def initialize(prefixes, view)
require "cell/templates"
require "cell/abstract"
require "cell/util"
require "cell/inspect"
require "cell/view_model"
require "cell/concept"
require "cell/escaped"
Expand Down
2 changes: 1 addition & 1 deletion lib/cell/abstract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ def abstract!
end

def abstract?
@abstract
@abstract if defined?(@abstract)
end
end
29 changes: 16 additions & 13 deletions lib/cell/caching.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "declarative/options"
require "cell/option"

module Cell
module Caching
Expand All @@ -17,12 +17,10 @@ def self.included(includer)
end

module ClassMethods
def cache(state, *args, &block)
options = args.last.is_a?(Hash) ? args.pop : {} # I have to admit, Array#extract_options is a brilliant tool.

conditional_procs[state] = Declarative::Option(options.delete(:if) || true, instance_exec: true)
version_procs[state] = Declarative::Option(args.first || block, instance_exec: true)
cache_options[state] = Declarative::Options(options, instance_exec: true)
def cache(state, *args, **kws, &block)
conditional_procs[state] = Cell::Option(kws.delete(:if) || true)
version_procs[state] = Cell::Option(args.first || block)
cache_options[state] = Cell::Options(kws)
end

# Computes the complete, namespaced cache key for +state+.
Expand All @@ -41,22 +39,27 @@ def expand_cache_key(key)
end
end

def render_state(state, *args)
def render_state(state, *args, **kws)
state = state.to_sym
return super(state, *args) unless cache?(state, *args)

key = self.class.state_cache_key(state, self.class.version_procs[state].(self, *args))
options = self.class.cache_options[state].(self, *args)
# Before Ruby 3.0, this wasn't necessary, but since cache filters don't receive kwargs as per the "old" (existing cells version) implementation, we can make it one array.
cache_filter_args = args + [kws]

return super(state, *args, **kws) unless cache?(state, *cache_filter_args)


key = self.class.state_cache_key(state, self.class.version_procs[state].(*cache_filter_args, exec_context: self))
options = self.class.cache_options[state].(*cache_filter_args, exec_context: self)

fetch_from_cache_for(key, options) { super(state, *args) }
fetch_from_cache_for(key, options) { super(state, *args, **kws) }
end

def cache_store # we want to use DI to set a cache store in cell/rails.
raise "No cache store has been set."
end

def cache?(state, *args)
perform_caching? and state_cached?(state) and self.class.conditional_procs[state].(self, *args)
perform_caching? and state_cached?(state) and self.class.conditional_procs[state].(*args, exec_context: self)
end

private
Expand Down
Loading