cells 3.3.8 → 3.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +4 -0
- data/lib/cells.rb +1 -1
- data/lib/cells/cell/test_case.rb +21 -3
- data/lib/cells/version.rb +1 -3
- data/test/test_case_test.rb +17 -0
- metadata +3 -3
data/CHANGES
CHANGED
data/lib/cells.rb
CHANGED
data/lib/cells/cell/test_case.rb
CHANGED
@@ -77,8 +77,26 @@ module Cell
|
|
77
77
|
# should "spit out a h1 title" do
|
78
78
|
# html = render_cell(:news, :latest)
|
79
79
|
# assert_selekt html, "h1", "The latest and greatest!"
|
80
|
-
def render_cell(*args)
|
81
|
-
@
|
80
|
+
def render_cell(name, state, *args)
|
81
|
+
@subject_cell = ::Cell::Base.create_cell_for(@controller, name, *args)
|
82
|
+
@view_assigns = extract_state_ivars_for(@subject_cell) do
|
83
|
+
@last_invoke = @subject_cell.render_state(state, *args)
|
84
|
+
end
|
85
|
+
|
86
|
+
@last_invoke
|
87
|
+
end
|
88
|
+
|
89
|
+
# Runs the block while computing the instance variables diff from before and after.
|
90
|
+
def extract_state_ivars_for(cell)
|
91
|
+
before = cell.instance_variables
|
92
|
+
before += [:@cell, :@state_name]
|
93
|
+
yield
|
94
|
+
after = cell.instance_variables
|
95
|
+
|
96
|
+
Hash[(after - before).collect do |var|
|
97
|
+
next if var =~ /^@_/
|
98
|
+
[var[1, var.length].to_sym, cell.instance_variable_get(var)]
|
99
|
+
end]
|
82
100
|
end
|
83
101
|
|
84
102
|
# Builds an instance of <tt>name</tt>Cell for unit testing.
|
@@ -99,7 +117,7 @@ module Cell
|
|
99
117
|
include AssertSelect
|
100
118
|
|
101
119
|
|
102
|
-
attr_reader :last_invoke
|
120
|
+
attr_reader :last_invoke, :subject_cell, :view_assigns
|
103
121
|
|
104
122
|
def invoke(state, *args)
|
105
123
|
@last_invoke = self.class.controller_class.new(@controller, *args).render_state(state)
|
data/lib/cells/version.rb
CHANGED
data/test/test_case_test.rb
CHANGED
@@ -33,6 +33,23 @@ class TestCaseTest < Cell::TestCase
|
|
33
33
|
assert_equal({:topic => :peace}, cell(:bassist, :topic => :peace) { def opts; @opts; end }.opts)
|
34
34
|
end
|
35
35
|
|
36
|
+
context "#view_assigns" do
|
37
|
+
should "be emtpy when nothing was set" do
|
38
|
+
render_cell(:bassist, :play)
|
39
|
+
assert_equal({}, view_assigns)
|
40
|
+
end
|
41
|
+
|
42
|
+
should "return the instance variables from the last #render_cell" do
|
43
|
+
BassistCell.class_eval do
|
44
|
+
def sleep
|
45
|
+
@duration = "8h"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
render_cell(:bassist, :sleep)
|
49
|
+
assert_equal({:duration => "8h"}, view_assigns)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
36
53
|
context "in declarative tests" do
|
37
54
|
should "respond to TestCase.tests" do
|
38
55
|
self.class.tests BassistCell
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 3
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 3.3.
|
8
|
+
- 9
|
9
|
+
version: 3.3.9
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nick Sutterer
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-10-06 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|