cells 4.0.0.beta2 → 4.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/README.md +4 -4
- data/cells.gemspec +4 -0
- data/gemfiles/rails3.2.gemfile +1 -1
- data/gemfiles/rails4.2.gemfile +3 -3
- data/lib/cell/test_case.rb +2 -0
- data/lib/cell/testing.rb +33 -3
- data/lib/cell/version.rb +1 -1
- data/lib/cell/view_model.rb +20 -3
- data/test/test_case_test.rb +18 -3
- data/test/test_helper.rb +0 -2
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 442134126a42a17ae056d6fea0138663b6868801
|
4
|
+
data.tar.gz: 78b1ebe96cb15081e067f62a10208648a71388b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8278561d5102e21559df5a51c852d74c6bc2b017db2d35d933a504ec8d5c521851c1179f5c5ac0d2f8f950be764233c4b4bf26750b59103639c2da96c2b36886
|
7
|
+
data.tar.gz: a3ee11a160976a710b93ed9e2ca1705ef64d34c1bc1d0b8c303932cd6a2f22a62898814a25e5897ce757664fae84c9d9da070e5dcc4fe9e55a89b9e9ad8d0b42
|
data/CHANGES.md
CHANGED
@@ -18,6 +18,10 @@
|
|
18
18
|
|
19
19
|
* When using HAML, we do not use any of HAML's helper hacks to "fix" ActionView and XSS. While you might not note this, it removes tons of code from our stack.
|
20
20
|
|
21
|
+
## 4.0.0.beta3
|
22
|
+
|
23
|
+
* Introduce `Cell::Testing` for Rspec and MiniTest.
|
24
|
+
* Add ViewModel::OutputBuffer to be used in Erbse and soon in Haml.
|
21
25
|
|
22
26
|
## 3.11.2
|
23
27
|
|
data/README.md
CHANGED
@@ -20,9 +20,9 @@ Cells is part of the [Trailblazer project](https://github.com/apotonick/trailbla
|
|
20
20
|
![](https://raw.githubusercontent.com/apotonick/trailblazer/master/doc/trb.jpg)
|
21
21
|
</a>
|
22
22
|
|
23
|
-
* Basic view models, replacing helpers, and how to structure your view into cell components (chapter 2 and
|
24
|
-
* Advanced Cells API (chapter
|
25
|
-
* Testing Cells (chapter
|
23
|
+
* Basic view models, replacing helpers, and how to structure your view into cell components (chapter 2 and 4).
|
24
|
+
* Advanced Cells API (chapter 4 and 6).
|
25
|
+
* Testing Cells (chapter 4 and 6).
|
26
26
|
* Cells Pagination with AJAX (chapter 6).
|
27
27
|
* View Caching and Expiring (chapter 7).
|
28
28
|
|
@@ -862,7 +862,7 @@ This was mainly added to provide compatibility with 3rd-party gems like [Kaminar
|
|
862
862
|
|
863
863
|
## LICENSE
|
864
864
|
|
865
|
-
Copyright (c) 2007-
|
865
|
+
Copyright (c) 2007-2015, Nick Sutterer
|
866
866
|
|
867
867
|
Copyright (c) 2007-2008, Solide ICT by Peter Bex and Bob Leers
|
868
868
|
|
data/cells.gemspec
CHANGED
@@ -23,4 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency "uber", "~> 0.0.9"
|
24
24
|
spec.add_dependency 'tilt', '>= 1.4', '< 3'
|
25
25
|
spec.add_dependency 'disposable', '~> 0.0.8'
|
26
|
+
|
27
|
+
spec.add_dependency "capybara"
|
28
|
+
|
29
|
+
spec.add_development_dependency "cells-erb", ">= 0.0.2"
|
26
30
|
end
|
data/gemfiles/rails3.2.gemfile
CHANGED
data/gemfiles/rails4.2.gemfile
CHANGED
@@ -7,8 +7,8 @@ gem "pry-byebug", :platforms => [:mri_20, :mri_21]
|
|
7
7
|
gem "appraisal"
|
8
8
|
gem "rake"
|
9
9
|
gem "test_xml"
|
10
|
-
gem "railties",
|
11
|
-
gem "activemodel",
|
10
|
+
gem "railties", "~> 4.2.0"
|
11
|
+
gem "activemodel", "~> 4.2.0"
|
12
12
|
gem "minitest", "~> 5.2"
|
13
13
|
|
14
|
-
gemspec :path => "../"
|
14
|
+
gemspec :path => "../"
|
data/lib/cell/test_case.rb
CHANGED
data/lib/cell/testing.rb
CHANGED
@@ -1,14 +1,44 @@
|
|
1
|
-
# Used in rspec-cells, etc.
|
2
1
|
module Cell
|
2
|
+
# Builder methods and Capybara support.
|
3
|
+
# This gets included into Test::Unit, MiniTest::Spec, etc.
|
3
4
|
module Testing
|
4
5
|
def cell(name, *args)
|
5
|
-
|
6
|
+
cell_for(ViewModel, name, *args)
|
6
7
|
end
|
7
8
|
|
8
9
|
def concept(name, *args)
|
9
|
-
|
10
|
+
cell_for(Concept, name, *args)
|
10
11
|
end
|
11
12
|
|
13
|
+
private
|
14
|
+
def cell_for(baseclass, name, *args)
|
15
|
+
cell = baseclass.cell(name, controller, *args)
|
16
|
+
cell.extend(Capybara) if Cell::Testing.capybara? # leaving this here as most people use Capybara.
|
17
|
+
cell
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
# Set this to true if you have Capybara loaded. Happens automatically in Cell::TestCase.
|
22
|
+
def self.capybara=(value)
|
23
|
+
@capybara = value
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.capybara?
|
27
|
+
@capybara
|
28
|
+
end
|
29
|
+
|
30
|
+
# Extends ViewModel#call by injecting Capybara support.
|
31
|
+
module Capybara
|
32
|
+
module ToS
|
33
|
+
def to_s
|
34
|
+
native.to_s
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def call(*)
|
39
|
+
::Capybara.string(super).extend(ToS)
|
40
|
+
end
|
41
|
+
end
|
12
42
|
|
13
43
|
|
14
44
|
# Rails specific.
|
data/lib/cell/version.rb
CHANGED
data/lib/cell/view_model.rb
CHANGED
@@ -146,10 +146,27 @@ module Cell
|
|
146
146
|
include Rendering
|
147
147
|
include Caching
|
148
148
|
|
149
|
-
|
150
|
-
|
149
|
+
|
150
|
+
class OutputBuffer < Array
|
151
|
+
def encoding
|
152
|
+
"UTF-8"
|
153
|
+
end
|
154
|
+
|
155
|
+
def <<(string)
|
156
|
+
super
|
157
|
+
end
|
158
|
+
alias_method :safe_append=, :<<
|
159
|
+
alias_method :append=, :<<
|
160
|
+
|
161
|
+
def to_s # output_buffer is returned at the end of the precompiled template.
|
162
|
+
join
|
163
|
+
end
|
151
164
|
end
|
152
|
-
|
165
|
+
def output_buffer # called from the precompiled template. FIXME: this is currently not used in Haml.
|
166
|
+
@output_buffer ||= OutputBuffer.new
|
167
|
+
end
|
168
|
+
attr_writer :output_buffer # FIXME: where is that used? definitely not in Erbse.
|
169
|
+
|
153
170
|
|
154
171
|
module TemplateFor
|
155
172
|
def template_for(options)
|
data/test/test_case_test.rb
CHANGED
@@ -2,6 +2,9 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class TestCaseTest < MiniTest::Spec
|
4
4
|
class SongCell < Cell::ViewModel
|
5
|
+
def show
|
6
|
+
"Give It All!"
|
7
|
+
end
|
5
8
|
end
|
6
9
|
|
7
10
|
class Song
|
@@ -11,11 +14,14 @@ class TestCaseTest < MiniTest::Spec
|
|
11
14
|
|
12
15
|
let (:song) { Object.new }
|
13
16
|
|
17
|
+
# #cell returns the instance
|
14
18
|
describe "#cell" do
|
15
19
|
subject { cell("test_case_test/song", song) }
|
16
20
|
|
17
21
|
it { subject.must_be_instance_of SongCell }
|
18
22
|
it { subject.model.must_equal song }
|
23
|
+
|
24
|
+
it { cell("test_case_test/song", collection: [song, song]).must_equal "Give It All!Give It All!" }
|
19
25
|
end
|
20
26
|
|
21
27
|
|
@@ -25,9 +31,12 @@ class TestCaseTest < MiniTest::Spec
|
|
25
31
|
it { subject.must_be_instance_of Song::Cell }
|
26
32
|
it { subject.model.must_equal song }
|
27
33
|
end
|
34
|
+
end
|
28
35
|
|
36
|
+
# capybara support
|
37
|
+
require "capybara"
|
29
38
|
|
30
|
-
|
39
|
+
class CapybaraTest < MiniTest::Spec
|
31
40
|
class CapybaraCell < Cell::ViewModel
|
32
41
|
def show
|
33
42
|
"<b>Grunt</b>"
|
@@ -35,8 +44,14 @@ class TestCaseTest < MiniTest::Spec
|
|
35
44
|
end
|
36
45
|
|
37
46
|
describe "capybara support" do
|
38
|
-
subject { cell("
|
47
|
+
subject { cell("capybara_test/capybara", nil) }
|
48
|
+
|
49
|
+
before { Cell::Testing.capybara = true } # yes, a global switch!
|
50
|
+
after { Cell::Testing.capybara = false }
|
51
|
+
|
52
|
+
it { subject.(:show).has_selector?('b').must_equal true }
|
39
53
|
|
40
|
-
|
54
|
+
# FIXME: this kinda sucks, what if you want the string in a Capybara environment?
|
55
|
+
it { subject.(:show).to_s.must_match "<b>Grunt</b>" }
|
41
56
|
end
|
42
57
|
end
|
data/test/test_helper.rb
CHANGED
@@ -4,9 +4,7 @@ rescue LoadError
|
|
4
4
|
end
|
5
5
|
|
6
6
|
ENV['RAILS_ENV'] = 'test'
|
7
|
-
|
8
7
|
require_relative 'dummy/config/environment'
|
9
|
-
require 'tilt/erubis' if Gem::Version.new(ActiveSupport::VERSION::STRING) >= Gem::Version.new('4.2.0')
|
10
8
|
|
11
9
|
require 'minitest/autorun'
|
12
10
|
require 'test_xml/mini_test'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cells
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -72,6 +72,34 @@ dependencies:
|
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 0.0.8
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: capybara
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: cells-erb
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.0.2
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.0.2
|
75
103
|
description: Cells replace partials and helpers with OOP view models, giving you proper
|
76
104
|
encapsulation, inheritance, testability and a cleaner view architecture.
|
77
105
|
email:
|