cells 3.9.0 → 3.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGES.textile +5 -0
- data/README.md +14 -1
- data/cells.gemspec +2 -1
- data/gemfiles/Gemfile.rails3-0 +1 -0
- data/gemfiles/Gemfile.rails3-1 +1 -0
- data/gemfiles/Gemfile.rails3-2 +1 -0
- data/gemfiles/Gemfile.rails4-0 +5 -2
- data/gemfiles/Gemfile.rails4-1 +10 -0
- data/lib/cell/base.rb +23 -13
- data/lib/cell/rails/view_model.rb +3 -3
- data/lib/cell/rails3_0_strategy.rb +11 -9
- data/lib/cell/rails3_1_strategy.rb +9 -7
- data/lib/cell/rails4_0_strategy.rb +9 -8
- data/lib/cell/rails4_1_strategy.rb +40 -0
- data/lib/cell/test_case.rb +10 -0
- data/lib/cells/engines.rb +13 -11
- data/lib/cells/version.rb +1 -1
- data/lib/generators/cells/base.rb +4 -2
- data/test/app/cells/bassist_cell.rb +9 -0
- data/test/cell_generator_test.rb +5 -0
- data/test/cell_module_test.rb +6 -1
- data/test/cells_module_test.rb +4 -4
- data/test/deprecations_test.rb +23 -17
- data/test/dummy/label/app/cells/label/show.erb +1 -0
- data/test/dummy/label/app/cells/label_cell.rb +5 -0
- data/test/dummy/label/label.gemspec +20 -0
- data/test/dummy/label/lib/label.rb +4 -0
- data/test/dummy/label/lib/label/version.rb +3 -0
- data/test/helper_test.rb +1 -1
- data/test/rails/caching_test.rb +1 -1
- data/test/rails/cells_test.rb +2 -2
- data/test/rails/integration_test.rb +12 -0
- data/test/rails/render_test.rb +42 -45
- data/test/rails/router_test.rb +29 -34
- data/test/rails/view_model_test.rb +6 -5
- data/test/rails/view_test.rb +4 -4
- data/test/test_case_test.rb +119 -113
- data/test/test_helper.rb +13 -1
- metadata +25 -4
data/test/rails/router_test.rb
CHANGED
@@ -4,47 +4,42 @@ module ApplicationTests
|
|
4
4
|
class RouterTest < ActionController::TestCase
|
5
5
|
tests MusicianController
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
it "allow cells to use url_helpers" do
|
13
|
-
BassistCell.class_eval do
|
14
|
-
def promote; render; end
|
15
|
-
end
|
7
|
+
test "pass url_helpers to the cell instance" do
|
8
|
+
assert_equal "/musicians", BassistCell.new(@controller).musicians_path
|
9
|
+
end
|
16
10
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
11
|
+
test "allow cells to use url_helpers" do
|
12
|
+
get "index"
|
13
|
+
assert_response :success
|
14
|
+
assert_equal "Find me at <a href=\"/musicians\">vd.com</a>\n", @response.body
|
15
|
+
end
|
16
|
+
|
17
|
+
test "delegate #url_options to the parent_controller" do
|
18
|
+
@controller.instance_eval do
|
19
|
+
def default_url_options
|
20
|
+
{:host => "cells.rails.org"}
|
28
21
|
end
|
29
|
-
|
30
|
-
assert_equal "http://cells.rails.org/musicians", BassistCell.new(@controller).musicians_url
|
31
22
|
end
|
32
23
|
|
33
|
-
|
34
|
-
|
35
|
-
assert_response :success
|
36
|
-
assert_equal "Find me at <a href=\"http://test.host/musicians\">vd.com</a>\n", @response.body
|
37
|
-
end
|
24
|
+
assert_equal "http://cells.rails.org/musicians", BassistCell.new(@controller).musicians_url
|
25
|
+
end
|
38
26
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
27
|
+
test "allow cells to use *_url helpers when mixing in AC::UrlFor" do
|
28
|
+
get "promote"
|
29
|
+
assert_response :success
|
30
|
+
assert_equal "Find me at <a href=\"http://test.host/musicians\">vd.com</a>\n", @response.body
|
31
|
+
end
|
43
32
|
|
44
|
-
|
45
|
-
|
46
|
-
|
33
|
+
test "allow cells to use #config" do
|
34
|
+
BassistCell.class_eval do
|
35
|
+
def provoke; render; end
|
47
36
|
end
|
37
|
+
|
38
|
+
fix_relative_url_root
|
39
|
+
|
40
|
+
get "promotion"
|
41
|
+
assert_response :success
|
42
|
+
assert_equal "That's me, naked <img alt=\"Me\" src=\"/images/me.png\" />", @response.body
|
48
43
|
end
|
49
44
|
end
|
50
45
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'test_helper'
|
1
|
+
require 'test_helper'
|
2
2
|
require 'cell/rails/view_model'
|
3
3
|
|
4
4
|
class Song < OpenStruct
|
@@ -64,11 +64,12 @@ class ViewModelTest < MiniTest::Spec
|
|
64
64
|
|
65
65
|
class HitCell < Cell::Base
|
66
66
|
include Cell::Rails::ViewModel
|
67
|
-
property :title
|
67
|
+
property :title, :artist
|
68
68
|
end
|
69
69
|
|
70
|
-
let (:song) { Song.new(:title => "65") }
|
70
|
+
let (:song) { Song.new(:title => "65", artist: "Boss") }
|
71
71
|
it { HitCell.new(song).title.must_equal "65" }
|
72
|
+
it { HitCell.new(song).artist.must_equal "Boss" }
|
72
73
|
end
|
73
74
|
|
74
75
|
if Cell.rails3_2_or_more?
|
@@ -80,10 +81,10 @@ if Cell.rails3_2_or_more?
|
|
80
81
|
#let (:cell) { }
|
81
82
|
|
82
83
|
setup do
|
83
|
-
@cell = SongCell.build_for(@controller, :song => Song.new(:title => "Blindfold", :id => 1))
|
84
|
+
@cell = SongCell.build_for(@controller, :song => Song.new(:title => "Blindfold", :id => "1"))
|
84
85
|
|
85
86
|
@url = "/songs/1"
|
86
|
-
@url = "http://test.host/songs/1" if Cell.
|
87
|
+
@url = "http://test.host/songs/1" if Cell.rails4_0?
|
87
88
|
end
|
88
89
|
|
89
90
|
|
data/test/rails/view_test.rb
CHANGED
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class RailsViewTest < MiniTest::Spec
|
4
4
|
include Cell::TestCase::TestMethods
|
5
|
-
|
5
|
+
|
6
6
|
describe "A cell view" do
|
7
7
|
# DISCUSS: it we allow :partial from a state, too?
|
8
8
|
describe "calling render :partial" do
|
@@ -11,7 +11,7 @@ class RailsViewTest < MiniTest::Spec
|
|
11
11
|
render :partial => 'dii'
|
12
12
|
end)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "render the foreign cell partial in bad_guitarist/dii" do
|
16
16
|
assert_equal("Dooom", in_view(:bassist) do
|
17
17
|
render :partial => "bad_guitarist/dii"
|
@@ -28,13 +28,13 @@ class RailsViewTest < MiniTest::Spec
|
|
28
28
|
end)
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it "respond to render :state" do
|
33
33
|
assert_equal("Doo", in_view(:bassist) do
|
34
34
|
render :state => :play
|
35
35
|
end)
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
it "respond to render :state with options" do
|
39
39
|
BassistCell.class_eval do
|
40
40
|
def listen(*args)
|
data/test/test_case_test.rb
CHANGED
@@ -2,135 +2,141 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class TestCaseTest < Cell::TestCase
|
4
4
|
include ActiveSupport::Testing::Deprecation
|
5
|
-
|
6
|
-
|
7
|
-
before
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
|
6
|
+
class << self # FIXME: why use Minitest::Spec syntax here. how does C::TC work with that?
|
7
|
+
alias_method :before, :setup
|
8
|
+
alias_method :it, :test
|
9
|
+
|
10
|
+
def describe(msg, &block)
|
11
|
+
instance_exec &block
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
before do
|
16
|
+
@test = Cell::TestCase.new(:cell_test)
|
17
|
+
|
18
|
+
BassistCell.class_eval do
|
19
|
+
def play; render; end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#render_cell" do
|
24
|
+
it "invokes the state" do
|
25
|
+
assert_equal "Doo", render_cell(:bassist, :play)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "accept state args" do
|
29
|
+
assert_equal "*shouts* Listen!\n", render_cell(:bassist, :shout, :words => "Listen!")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "respond to #assert_selector with 3 args" do
|
34
|
+
assert_selector "p", "Doo", "<p>Doo</p>y"
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#cell" do
|
38
|
+
it "create a cell" do
|
39
|
+
assert_kind_of BassistCell, cell(:bassist)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "accept a block" do
|
43
|
+
assert_respond_to cell(:bassist){ def whatever; end }, :whatever
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#subject_cell" do
|
48
|
+
it "return the last rendered cell" do
|
49
|
+
render_cell(:bassist, :play)
|
50
|
+
assert_kind_of BassistCell, subject_cell
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
describe "#view_assigns" do
|
56
|
+
it "be emtpy when nothing was set" do
|
57
|
+
render_cell(:bassist, :play)
|
58
|
+
if Cell.rails3_0?
|
59
|
+
assert_equal([:lookup_context], view_assigns.keys)
|
60
|
+
else
|
61
|
+
assert_equal({}, view_assigns)
|
12
62
|
end
|
13
63
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
64
|
+
|
65
|
+
it "return the instance variables from the last #render_cell" do
|
66
|
+
BassistCell.class_eval do
|
67
|
+
def sleep
|
68
|
+
@duration = "8h"
|
69
|
+
end
|
18
70
|
end
|
19
|
-
|
20
|
-
|
21
|
-
assert_equal
|
71
|
+
render_cell(:bassist, :sleep)
|
72
|
+
if Cell.rails3_0?
|
73
|
+
assert_equal("8h", view_assigns[:duration])
|
74
|
+
else
|
75
|
+
assert_equal({:duration => "8h"}, view_assigns)
|
22
76
|
end
|
23
77
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "in declarative tests" do
|
81
|
+
it "respond to TestCase.tests" do
|
82
|
+
self.class.tests BassistCell
|
83
|
+
assert_equal BassistCell, self.class.controller_class
|
27
84
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
assert_kind_of BassistCell, cell(:bassist)
|
85
|
+
|
86
|
+
it "infer the cell name" do
|
87
|
+
class SingerCell < Cell::Rails
|
32
88
|
end
|
33
|
-
|
34
|
-
|
35
|
-
assert_respond_to cell(:bassist){ def whatever; end }, :whatever
|
89
|
+
|
90
|
+
class SingerCellTest < Cell::TestCase
|
36
91
|
end
|
92
|
+
|
93
|
+
assert_equal SingerCell, SingerCellTest.new(:cell_test).class.controller_class
|
37
94
|
end
|
38
|
-
|
39
|
-
describe "#
|
40
|
-
|
41
|
-
|
42
|
-
assert_kind_of BassistCell, subject_cell
|
95
|
+
|
96
|
+
describe "with #invoke" do
|
97
|
+
before do
|
98
|
+
self.class.tests BassistCell
|
43
99
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
describe "#view_assigns" do
|
48
|
-
it "be emtpy when nothing was set" do
|
49
|
-
render_cell(:bassist, :play)
|
50
|
-
if Cell.rails3_0?
|
51
|
-
assert_equal([:lookup_describe], view_assigns.keys)
|
52
|
-
else
|
53
|
-
assert_equal({}, view_assigns)
|
54
|
-
end
|
100
|
+
|
101
|
+
it "provide #invoke" do
|
102
|
+
assert_equal "Doo", invoke(:play)
|
55
103
|
end
|
56
|
-
|
57
|
-
it "
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
63
|
-
render_cell(:bassist, :sleep)
|
64
|
-
if Cell.rails3_0?
|
65
|
-
assert_equal([:lookup_describe, :duration], view_assigns.keys)
|
66
|
-
assert_equal("8h", view_assigns[:duration])
|
67
|
-
else
|
68
|
-
assert_equal({:duration => "8h"}, view_assigns)
|
69
|
-
end
|
104
|
+
|
105
|
+
it "provide #last_invoke" do
|
106
|
+
assert_equal nil, last_invoke
|
107
|
+
assert_equal "Doo", invoke(:play)
|
108
|
+
assert_equal "Doo", last_invoke
|
70
109
|
end
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
it "respond to TestCase.tests" do
|
75
|
-
self.class.tests BassistCell
|
76
|
-
assert_equal BassistCell, self.class.controller_class
|
110
|
+
|
111
|
+
it "provide #invoke accepting options" do
|
112
|
+
#assert_equal "Doo", invoke(:play)
|
77
113
|
end
|
78
|
-
|
79
|
-
it "
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
class SingerCellTest < Cell::TestCase
|
84
|
-
end
|
85
|
-
|
86
|
-
assert_equal SingerCell, SingerCellTest.new(:cell_test).class.controller_class
|
114
|
+
|
115
|
+
it "provide #invoke accepting args" do
|
116
|
+
assert_equal "*shouts* Listen!\n", invoke(:shout, :words => "Listen!")
|
87
117
|
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
it "provide #invoke" do
|
95
|
-
assert_equal "Doo", invoke(:play)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "provide #last_invoke" do
|
99
|
-
assert_equal nil, last_invoke
|
100
|
-
assert_equal "Doo", invoke(:play)
|
101
|
-
assert_equal "Doo", last_invoke
|
102
|
-
end
|
103
|
-
|
104
|
-
it "provide #invoke accepting options" do
|
105
|
-
#assert_equal "Doo", invoke(:play)
|
106
|
-
end
|
107
|
-
|
108
|
-
it "provide #invoke accepting args" do
|
109
|
-
assert_equal "*shouts* Listen!\n", invoke(:shout, :words => "Listen!")
|
110
|
-
end
|
111
|
-
|
112
|
-
it "provide assert_select" do
|
113
|
-
invoke :promote
|
114
|
-
assert_select "a", "vd.com"
|
115
|
-
end
|
118
|
+
|
119
|
+
it "provide assert_select" do
|
120
|
+
invoke :promote
|
121
|
+
assert_select "a", "vd.com"
|
116
122
|
end
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "#before_test_states_in" do
|
126
|
+
it "add the :in_view state" do
|
127
|
+
c = cell(:bassist)
|
128
|
+
assert ! c.respond_to?(:in_view)
|
129
|
+
|
130
|
+
setup_test_states_in(c)
|
131
|
+
assert_equal "Cells rock.", c.render_state(:in_view, lambda{"Cells rock."})
|
126
132
|
end
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "#in_view" do
|
136
|
+
it "execute the block in a real view" do
|
137
|
+
content = "Cells rule."
|
138
|
+
@test.setup
|
139
|
+
assert_equal("<h1>Cells rule.</h1>", @test.in_view(:bassist) do content_tag("h1", content) end)
|
134
140
|
end
|
135
141
|
end
|
136
142
|
end
|
data/test/test_helper.rb
CHANGED
@@ -20,7 +20,7 @@ MiniTest::Spec.class_eval do
|
|
20
20
|
def assert_not(assertion)
|
21
21
|
assert !assertion
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def assert_is_a(klass, object)
|
25
25
|
assert object.is_a?(klass)
|
26
26
|
end
|
@@ -37,3 +37,15 @@ require File.join(test_app_dir, 'cells', 'bad_guitarist_cell')
|
|
37
37
|
|
38
38
|
require "haml"
|
39
39
|
require "haml/template" # Thanks, Nathan!
|
40
|
+
|
41
|
+
ActiveSupport::TestCase.class_eval do # this is only needed in integration tests (AC::TestCase).
|
42
|
+
def fix_relative_url_root
|
43
|
+
return unless Cell.rails3_0?
|
44
|
+
|
45
|
+
@controller.config.instance_eval do
|
46
|
+
def relative_url_root
|
47
|
+
""
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
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: 3.9.
|
4
|
+
version: 3.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -98,16 +98,30 @@ dependencies:
|
|
98
98
|
name: minitest
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 4.7.5
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 4.7.5
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: activemodel
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: Cells are view components for Rails. They are lightweight controllers,
|
112
126
|
can be rendered in views and thus provide an elegant and fast way for encapsulation
|
113
127
|
and component-orientation.
|
@@ -128,6 +142,7 @@ files:
|
|
128
142
|
- gemfiles/Gemfile.rails3-1
|
129
143
|
- gemfiles/Gemfile.rails3-2
|
130
144
|
- gemfiles/Gemfile.rails4-0
|
145
|
+
- gemfiles/Gemfile.rails4-1
|
131
146
|
- lib/cell.rb
|
132
147
|
- lib/cell/base.rb
|
133
148
|
- lib/cell/builder.rb
|
@@ -141,6 +156,7 @@ files:
|
|
141
156
|
- lib/cell/rails3_0_strategy.rb
|
142
157
|
- lib/cell/rails3_1_strategy.rb
|
143
158
|
- lib/cell/rails4_0_strategy.rb
|
159
|
+
- lib/cell/rails4_1_strategy.rb
|
144
160
|
- lib/cell/rendering.rb
|
145
161
|
- lib/cell/test_case.rb
|
146
162
|
- lib/cells.rb
|
@@ -225,6 +241,11 @@ files:
|
|
225
241
|
- test/dummy/config/locales/en.yml
|
226
242
|
- test/dummy/config/routes.rb
|
227
243
|
- test/dummy/db/test.sqlite3
|
244
|
+
- test/dummy/label/app/cells/label/show.erb
|
245
|
+
- test/dummy/label/app/cells/label_cell.rb
|
246
|
+
- test/dummy/label/label.gemspec
|
247
|
+
- test/dummy/label/lib/label.rb
|
248
|
+
- test/dummy/label/lib/label/version.rb
|
228
249
|
- test/dummy/log/production.log
|
229
250
|
- test/dummy/log/server.log
|
230
251
|
- test/dummy/public/404.html
|