fortitude 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +19 -19
- data/CHANGES.md +31 -0
- data/Gemfile +1 -0
- data/README-erector.md +1 -1
- data/lib/fortitude/erector.rb +32 -0
- data/lib/fortitude/method_templates/tag_method_template.rb.smpl +6 -6
- data/lib/fortitude/method_templates/text_method_template.rb.smpl +3 -3
- data/lib/fortitude/rails/railtie.rb +6 -4
- data/lib/fortitude/rails/renderer.rb +7 -4
- data/lib/fortitude/rails/template_handler.rb +18 -3
- data/lib/fortitude/rendering_context.rb +20 -2
- data/lib/fortitude/tags/render_widget_placeholder.rb +19 -0
- data/lib/fortitude/tags/tag.rb +18 -4
- data/lib/fortitude/tags/tag_return_value.rb +1 -1
- data/lib/fortitude/tags/tag_store.rb +4 -0
- data/lib/fortitude/tilt/fortitude_template.rb +6 -128
- data/lib/fortitude/version.rb +1 -1
- data/lib/fortitude/widget.rb +2 -0
- data/lib/fortitude/widget/files.rb +162 -0
- data/lib/fortitude/widget/integration.rb +5 -3
- data/lib/fortitude/widget/modules_and_subclasses.rb +17 -0
- data/lib/fortitude/widget/rendering.rb +12 -5
- data/lib/fortitude/widget/start_and_end_comments.rb +4 -2
- data/lib/fortitude/widget/tags.rb +6 -1
- data/lib/fortitude/widget/widget_class_inheritable_attributes.rb +7 -0
- data/spec/helpers/rails_server.rb +4 -0
- data/spec/rails/basic_rails_system_spec.rb +4 -0
- data/spec/rails/erector_coexistence_system_spec.rb +33 -0
- data/spec/rails/rendering_context_system_spec.rb +19 -3
- data/spec/rails/rendering_system_spec.rb +6 -0
- data/spec/rails/templates/basic_rails_system_spec/app/controllers/basic_rails_system_spec_controller.rb +5 -0
- data/spec/rails/templates/basic_rails_system_spec/app/views/basic_rails_system_spec/double_render_one.rb +5 -0
- data/spec/rails/templates/basic_rails_system_spec/app/views/basic_rails_system_spec/double_render_three.rb +5 -0
- data/spec/rails/templates/basic_rails_system_spec/app/views/basic_rails_system_spec/double_render_two.rb +9 -0
- data/spec/rails/templates/erector_coexistence_system_spec/app/controllers/erector_coexistence_system_spec_controller.rb +19 -0
- data/spec/rails/templates/erector_coexistence_system_spec/app/v/views/erector_coexistence_system_spec/erector_widget_in_app_v_views.rb +7 -0
- data/spec/rails/templates/erector_coexistence_system_spec/app/v/views/erector_coexistence_system_spec/fortitude_widget_in_app_v_views.rb +7 -0
- data/spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/erector_widget_in_app_views.rb +7 -0
- data/spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/fortitude_widget_in_app_views.rb +7 -0
- data/spec/rails/templates/erector_coexistence_system_spec/config/application.rb +25 -0
- data/spec/rails/templates/rendering_context_system_spec/app/controllers/rendering_context_system_spec_controller.rb +2 -2
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/_current_element_nesting_intermediate.html.erb +3 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/current_element_nesting_child.rb +13 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/current_element_nesting_toplevel.rb +9 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/start_end_widget_through_partials.rb +2 -2
- data/spec/system/convenience_methods_system_spec.rb +22 -0
- data/spec/system/inline_system_spec.rb +2 -2
- data/spec/system/record_tag_emission_system_spec.rb +71 -0
- data/spec/system/rendering_context_system_spec.rb +21 -0
- data/spec/system/setting_inheritance_system_spec.rb +52 -0
- data/spec/system/tag_return_value_system_spec.rb +7 -0
- data/spec/system/tilt_system_spec.rb +13 -18
- data/spec/system/widget_class_from_spec.rb +240 -0
- data/spec/system/widget_method_system_spec.rb +52 -0
- metadata +37 -2
@@ -15,6 +15,7 @@ module Fortitude
|
|
15
15
|
_fortitude_class_inheritable_attribute :extra_assigns, :ignore, [ :error, :ignore, :use ]
|
16
16
|
_fortitude_class_inheritable_attribute :automatic_helper_access, true, [ true, false ]
|
17
17
|
_fortitude_class_inheritable_attribute :implicit_shared_variable_access, false, [ true, false ]
|
18
|
+
_fortitude_class_inheritable_attribute :record_tag_emission, false, [ true, false ]
|
18
19
|
_fortitude_class_inheritable_attribute :enforce_element_nesting_rules, false, [ true, false ]
|
19
20
|
_fortitude_class_inheritable_attribute :enforce_attribute_rules, false, [ true, false ]
|
20
21
|
_fortitude_class_inheritable_attribute :enforce_id_uniqueness, false, [ true, false ]
|
@@ -30,6 +31,12 @@ module Fortitude
|
|
30
31
|
end)
|
31
32
|
_fortitude_class_inheritable_attribute :debug, false, [ true, false ]
|
32
33
|
end
|
34
|
+
|
35
|
+
module ClassMethods
|
36
|
+
def _fortitude_record_emitting_tag?
|
37
|
+
self.enforce_element_nesting_rules || self.record_tag_emission
|
38
|
+
end
|
39
|
+
end
|
33
40
|
end
|
34
41
|
end
|
35
42
|
end
|
@@ -248,6 +248,10 @@ EOS
|
|
248
248
|
# new-style hash syntax. As a result, we pin the version backwards in this one specific case.
|
249
249
|
gemfile_contents << "\ngem 'execjs', '~> 2.0.0'\n" if RUBY_VERSION =~ /^1\.8\./
|
250
250
|
|
251
|
+
Array(@options[:additional_gemfile_lines] || [ ]).each do |gemfile_line|
|
252
|
+
gemfile_contents << "\n#{gemfile_line}\n"
|
253
|
+
end
|
254
|
+
|
251
255
|
File.open(gemfile, 'w') { |f| f << gemfile_contents }
|
252
256
|
end
|
253
257
|
|
@@ -4,4 +4,8 @@ describe "basic Rails support", :type => :rails do
|
|
4
4
|
it "should be able to render a trivial widget" do
|
5
5
|
expect_match("trivial_widget", /layout_default/, /hello, world/)
|
6
6
|
end
|
7
|
+
|
8
|
+
it "should be able to use 'render' more than once in an action, and it should work fine" do
|
9
|
+
expect_match("double_render", /layout_default/, /hello, world.*goodbye, world.*and this is the last partial\!/mi)
|
10
|
+
end
|
7
11
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
describe "Erector coexistence support", :type => :rails do
|
2
|
+
uses_rails_with_template :erector_coexistence_system_spec, :additional_gemfile_lines => "gem 'erector'"
|
3
|
+
|
4
|
+
begin
|
5
|
+
gem 'erector'
|
6
|
+
rescue Gem::LoadError => le
|
7
|
+
# ok
|
8
|
+
end
|
9
|
+
|
10
|
+
begin
|
11
|
+
require 'erector'
|
12
|
+
rescue LoadError => le
|
13
|
+
# ok
|
14
|
+
end
|
15
|
+
|
16
|
+
if defined?(::Erector::Widget)
|
17
|
+
it "should be able to render a Fortitude widget in app/views" do
|
18
|
+
expect_match("fortitude_widget_in_app_views", /this is Fortitude: foo = bar/)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be able to render a Fortitude widget in app/v/views" do
|
22
|
+
expect_match("fortitude_widget_in_app_v_views", /this is Fortitude: foo = marph/)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be able to render an Erector widget in app/views" do
|
26
|
+
expect_match("erector_widget_in_app_views", /<p\s+class\s*=\s*"some_class"\s*>this is Erector: foo = baz<\/p>/)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be able to render an Erector widget in app/v/views" do
|
30
|
+
expect_match("erector_widget_in_app_v_views", /<p\s+class\s*=\s*"some_class"\s*>this is Erector: foo = quux<\/p>/)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -32,7 +32,7 @@ describe "Rails RenderingContext support", :type => :rails do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should still call that method for all widgets" do
|
35
|
-
expect_match("uses_direct_context_for_all_widgets", /context is: SimpleRc, value 67890.*context is: SimpleRc, value
|
35
|
+
expect_match("uses_direct_context_for_all_widgets", /context is: SimpleRc, value 67890.*context is: SimpleRc, value 67890.*context is: SimpleRc, value 67890/mi)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should call start_widget! and end_widget! properly on widgets in Rails" do
|
@@ -55,10 +55,26 @@ describe "Rails RenderingContext support", :type => :rails do
|
|
55
55
|
lines = lines.select { |l| l =~ /^\d:/ }.map { |l| l.strip }
|
56
56
|
|
57
57
|
expect(lines[0]).to eq("0: start Views::RenderingContextSystemSpec::StartEndWidgetThroughPartials")
|
58
|
-
expect(lines[1]).to eq("1: start [{:partial=>\"start_end_widget_through_partials_partial\"}]")
|
58
|
+
expect(lines[1]).to eq("1: start Fortitude::Tags::RenderWidgetPlaceholder [{:partial=>\"start_end_widget_through_partials_partial\"}]")
|
59
59
|
expect(lines[2]).to eq("2: start Views::RenderingContextSystemSpec::StartEndWidgetThroughPartialsPartialWidget 12345")
|
60
60
|
expect(lines[3]).to eq("3: end Views::RenderingContextSystemSpec::StartEndWidgetThroughPartialsPartialWidget 12345")
|
61
|
-
expect(lines[4]).to eq("4: end [{:partial=>\"start_end_widget_through_partials_partial\"}]")
|
61
|
+
expect(lines[4]).to eq("4: end Fortitude::Tags::RenderWidgetPlaceholder [{:partial=>\"start_end_widget_through_partials_partial\"}]")
|
62
62
|
expect(lines.length).to eq(5)
|
63
|
+
end
|
64
|
+
|
65
|
+
# +<div><span>yohoho
|
66
|
+
# +<p>[Views::RenderingContextSystemSpec::CurrentElementNestingToplevel][Fortitude::Tags::Tag][Fortitude::Tags::PartialTagPlaceholder][Array][Views::RenderingContextSystemSpec::CurrentElementNestingChild][Fortitude::Tags::Tag]</p>
|
67
|
+
# +</span>
|
68
|
+
# +</div>
|
69
|
+
|
70
|
+
it "should return the correct #current_element_nesting, even through multiple widgets and partials" do
|
71
|
+
text = get_success("current_element_nesting_toplevel")
|
72
|
+
expect(text).to match(%r{<div><span>yohoho\s*<p>0:.*</p>\s*</span>\s*</div>$}mi)
|
73
|
+
expect(text).to match(%r{0: \[Views::RenderingContextSystemSpec::CurrentElementNestingToplevel\]}mi)
|
74
|
+
expect(text).to match(%r{1: \[Fortitude::Tags::Tag/:div\]}mi)
|
75
|
+
expect(text).to match(%r{2: \[Fortitude::Tags::PartialTagPlaceholder/:_fortitude_partial_placeholder\]}mi)
|
76
|
+
expect(text).to match(%r{3: \[Fortitude::Tags::RenderWidgetPlaceholder/:_fortitude_render_widget_placeholder\]}mi)
|
77
|
+
expect(text).to match(%r{4: \[Views::RenderingContextSystemSpec::CurrentElementNestingChild\]}mi)
|
78
|
+
expect(text).to match(%r{5: \[Fortitude::Tags::Tag/:p\]}mi)
|
63
79
|
end
|
64
80
|
end
|
@@ -20,6 +20,12 @@ describe "Rails rendering support", :type => :rails do
|
|
20
20
|
expect(data).not_to match(/rails_spec_application/)
|
21
21
|
end
|
22
22
|
|
23
|
+
it "should set the Content-Type to text/html when using render :widget" do
|
24
|
+
response = get_response("render_widget")
|
25
|
+
expect(response.body).to match(/hello from a widget named Fred/)
|
26
|
+
expect(response.header['Content-Type']).to match(%r{text/html}i)
|
27
|
+
end
|
28
|
+
|
23
29
|
it "should let you render a widget with 'render \"foo\"'" do
|
24
30
|
expect_match("render_widget_via_file_path", /hello from a widget named Fred/)
|
25
31
|
end
|
@@ -2,6 +2,11 @@ class BasicRailsSystemSpecController < ApplicationController
|
|
2
2
|
def trivial_widget
|
3
3
|
end
|
4
4
|
|
5
|
+
def double_render
|
6
|
+
@rendered_string = render_to_string(:action => 'double_render_one', :layout => nil)
|
7
|
+
render :action => 'double_render_two'
|
8
|
+
end
|
9
|
+
|
5
10
|
def the_class_should_not_load
|
6
11
|
render :text => BasicRailsSystemSpec::ClassShouldNotLoad.new.to_s
|
7
12
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class ErectorCoexistenceSystemSpecController < ApplicationController
|
2
|
+
prepend_view_path "app/v/views"
|
3
|
+
|
4
|
+
def fortitude_widget_in_app_views
|
5
|
+
@foo = "bar"
|
6
|
+
end
|
7
|
+
|
8
|
+
def fortitude_widget_in_app_v_views
|
9
|
+
@foo = "marph"
|
10
|
+
end
|
11
|
+
|
12
|
+
def erector_widget_in_app_views
|
13
|
+
@foo = "baz"
|
14
|
+
end
|
15
|
+
|
16
|
+
def erector_widget_in_app_v_views
|
17
|
+
@foo = "quux"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
# Require the gems listed in Gemfile, including any gems
|
6
|
+
# you've limited to :test, :development, or :production.
|
7
|
+
Bundler.require(:default, Rails.env)
|
8
|
+
|
9
|
+
module ErectorCoexistenceSystemSpec
|
10
|
+
class Application < Rails::Application
|
11
|
+
# Settings in config/environments/* take precedence over those specified here.
|
12
|
+
# Application configuration should go into files in config/initializers
|
13
|
+
# -- all .rb files in that directory are automatically loaded.
|
14
|
+
|
15
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
16
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
17
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
18
|
+
|
19
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
20
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
21
|
+
# config.i18n.default_locale = :de
|
22
|
+
|
23
|
+
config.autoload_paths += [ File.join(Rails.root, "app", "v") ]
|
24
|
+
end
|
25
|
+
end
|
@@ -35,7 +35,7 @@ class RenderingContextSystemSpecController < ApplicationController
|
|
35
35
|
def uses_direct_context_in_view
|
36
36
|
$invoke_count = 0
|
37
37
|
class << self
|
38
|
-
def
|
38
|
+
def create_fortitude_rendering_context(options)
|
39
39
|
out = SimpleRc.new(options.merge(:the_value => 67890 + $invoke_count))
|
40
40
|
$invoke_count += 1
|
41
41
|
out
|
@@ -46,7 +46,7 @@ class RenderingContextSystemSpecController < ApplicationController
|
|
46
46
|
def uses_direct_context_for_all_widgets
|
47
47
|
$invoke_count = 0
|
48
48
|
class << self
|
49
|
-
def
|
49
|
+
def create_fortitude_rendering_context(options)
|
50
50
|
out = SimpleRc.new(options.merge(:the_value => 67890 + $invoke_count))
|
51
51
|
$invoke_count += 1
|
52
52
|
out
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Views::RenderingContextSystemSpec::CurrentElementNestingChild < Fortitude::Widgets::Html5
|
2
|
+
record_tag_emission true
|
3
|
+
|
4
|
+
def content
|
5
|
+
p {
|
6
|
+
rendering_context.current_element_nesting.each_with_index do |item, index|
|
7
|
+
name_text = ""
|
8
|
+
name_text = "/#{item.name.inspect}" if item.respond_to?(:name)
|
9
|
+
text "#{index}: [#{item.class.name}#{name_text}]\n"
|
10
|
+
end
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
@@ -5,8 +5,8 @@ class Views::RenderingContextSystemSpec::StartEndWidgetThroughPartials < Fortitu
|
|
5
5
|
rendering_context.start_end_calls.each_with_index do |data, index|
|
6
6
|
start_or_end = data[0]
|
7
7
|
widget = data[1]
|
8
|
-
widget_data = if widget.
|
9
|
-
widget.inspect
|
8
|
+
widget_data = if widget.respond_to?(:render_args)
|
9
|
+
"#{widget.class.name} #{widget.render_args.inspect}"
|
10
10
|
else
|
11
11
|
widget.class.name
|
12
12
|
end
|
@@ -1,4 +1,26 @@
|
|
1
1
|
describe "Fortitude convenience methods", :type => :system do
|
2
|
+
describe "#all_fortitude_superclasses" do
|
3
|
+
it "should return an empty array for ::Fortitude::Widget" do
|
4
|
+
expect(::Fortitude::Widget.all_fortitude_superclasses).to eq([ ])
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should return just ::Fortitude::Widget for a direct subclass" do
|
8
|
+
class ConvenienceSpecAllSuperclassesDirectSubclass < ::Fortitude::Widget; end
|
9
|
+
expect(ConvenienceSpecAllSuperclassesDirectSubclass.all_fortitude_superclasses).to eq([ ::Fortitude::Widget ])
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return a whole class hierarchy if appropriate" do
|
13
|
+
class ConvenienceSpecAllSuperclassesGrandparent < ::Fortitude::Widget; end
|
14
|
+
class ConvenienceSpecAllSuperclassesParent < ConvenienceSpecAllSuperclassesGrandparent; end
|
15
|
+
class ConvenienceSpecAllSuperclassesChild < ConvenienceSpecAllSuperclassesParent; end
|
16
|
+
expect(ConvenienceSpecAllSuperclassesChild.all_fortitude_superclasses).to eq([
|
17
|
+
ConvenienceSpecAllSuperclassesParent,
|
18
|
+
ConvenienceSpecAllSuperclassesGrandparent,
|
19
|
+
::Fortitude::Widget
|
20
|
+
])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
2
24
|
describe "#javascript" do
|
3
25
|
it "should output JavaScript inside the proper tag, by default" do
|
4
26
|
expect(render(widget_class_with_content { javascript "hi, there" })).to eq(
|
@@ -25,7 +25,7 @@ describe "Fortitude inline-code support", :type => :system do
|
|
25
25
|
<div>
|
26
26
|
<p>hello, julia</p>
|
27
27
|
</div>
|
28
|
-
<!-- END
|
28
|
+
<!-- END (anonymous widget class) depth 0 -->})
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should let you get rendered content back with .inline_html" do
|
@@ -53,6 +53,6 @@ describe "Fortitude inline-code support", :type => :system do
|
|
53
53
|
<div>
|
54
54
|
<p>hello, julia</p>
|
55
55
|
</div>
|
56
|
-
<!-- END
|
56
|
+
<!-- END (anonymous widget class) depth 0 -->})
|
57
57
|
end
|
58
58
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
describe "Fortitude record_tag_emission behavior", :type => :system do
|
2
|
+
before :each do
|
3
|
+
@recording_class = widget_class do
|
4
|
+
attr_reader :recorded_tags
|
5
|
+
|
6
|
+
def content
|
7
|
+
div {
|
8
|
+
p {
|
9
|
+
@recorded_tags = rendering_context.current_element_nesting.dup
|
10
|
+
}
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should not record tag emission by default" do
|
17
|
+
expect(recorded_tags_from(@recording_class.new)).to eq([ ])
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should record tag emission if asked to" do
|
21
|
+
@recording_class.class_eval { record_tag_emission true }
|
22
|
+
expect(recorded_tags_from(@recording_class.new).map(&:name)).to eq([ :div, :p ])
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should record tag emission across two widgets" do
|
26
|
+
parent_class = widget_class do
|
27
|
+
record_tag_emission true
|
28
|
+
attr_accessor :child_instance
|
29
|
+
|
30
|
+
def content
|
31
|
+
div {
|
32
|
+
widget child_instance
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
child_class = widget_class do
|
38
|
+
record_tag_emission true
|
39
|
+
attr_reader :recorded_tags
|
40
|
+
|
41
|
+
def content
|
42
|
+
p {
|
43
|
+
@recorded_tags = rendering_context.current_element_nesting.dup
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
parent_instance = parent_class.new
|
49
|
+
child_instance = child_class.new
|
50
|
+
|
51
|
+
parent_instance.child_instance = child_instance
|
52
|
+
|
53
|
+
results = render(parent_instance)
|
54
|
+
expect(results).to eq("<div><p></p></div>")
|
55
|
+
|
56
|
+
rt = child_instance.recorded_tags
|
57
|
+
|
58
|
+
expect(rt.shift).to be(parent_instance)
|
59
|
+
expect(rt.shift.name).to eq(:div)
|
60
|
+
expect(rt.shift).to be(child_instance)
|
61
|
+
expect(rt.shift.name).to eq(:p)
|
62
|
+
expect(rt).to eq([ ])
|
63
|
+
end
|
64
|
+
|
65
|
+
def recorded_tags_from(instance)
|
66
|
+
expect(render(instance)).to eq("<div><p></p></div>")
|
67
|
+
rt = instance.recorded_tags
|
68
|
+
expect(rt.shift).to be(instance)
|
69
|
+
rt
|
70
|
+
end
|
71
|
+
end
|
@@ -21,6 +21,27 @@ describe "Fortitude rendering context interactions", :type => :system do
|
|
21
21
|
super(widget_or_class, options.merge(:rendering_context => @rc))
|
22
22
|
end
|
23
23
|
|
24
|
+
it "should return the parent widget properly" do
|
25
|
+
child_widget_class = widget_class_with_content { p "child: #{rendering_context.parent_widget.some_method}" }
|
26
|
+
parent_widget_class = widget_class do
|
27
|
+
attr_accessor :child_widget_class
|
28
|
+
|
29
|
+
def some_method
|
30
|
+
"ahoy!"
|
31
|
+
end
|
32
|
+
|
33
|
+
def content
|
34
|
+
p "foo"
|
35
|
+
widget child_widget_class.new
|
36
|
+
p "baz"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
pw = parent_widget_class.new
|
41
|
+
pw.child_widget_class = child_widget_class
|
42
|
+
expect(render(pw)).to eq("<p>foo</p><p>child: ahoy!</p><p>baz</p>")
|
43
|
+
end
|
44
|
+
|
24
45
|
it "should call start_widget! and end_widget! on the context when starting and ending a simple widget" do
|
25
46
|
wc = widget_class_with_content { p "foo" }
|
26
47
|
instance = wc.new
|