Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion lib/arbre/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ def clear_children!
# 4. Call super
#
ruby2_keywords def method_missing(name, *args, &block)
if current_arbre_element.respond_to?(name)
if "Arbre::Components::#{name.to_s.camelize}".safe_constantize && respond_to?(name)
public_send(name, *args, &block)
elsif current_arbre_element.respond_to?(name)
current_arbre_element.send name, *args, &block
elsif assigns && assigns.has_key?(name)
assigns[name]
Expand Down
11 changes: 11 additions & 0 deletions spec/rails/integration/rendering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def render_with_instance_variable
render "arbre/page_with_assignment"
end

def render_with_autoloadable_component
render "arbre/page_with_autoloadable_component"
end

def render_partial_with_instance_variable
@my_instance_var = "From Instance Var"
render "arbre/page_with_arb_partial_and_assignment"
Expand All @@ -47,6 +51,7 @@ def render_with_block
get 'test/render_partial', controller: "test"
get 'test/render_erb_partial', controller: "test"
get 'test/render_with_instance_variable', controller: "test"
get 'test/render_with_autoloadable_component', controller: "test"
get 'test/render_partial_with_instance_variable', controller: "test"
get 'test/render_page_with_helpers', controller: "test"
get 'test/render_with_block', controller: "test"
Expand Down Expand Up @@ -95,6 +100,12 @@ def render_with_block
expect(body).to have_css("h1", text: "From Instance Var")
end

it "renders with autoloadable component" do
get "/test/render_with_autoloadable_component"
expect(response).to be_successful
expect(body).to have_css("div", text: "Autoloadable Component")
end

it "renders an arbre partial with assignments" do
get "/test/render_partial_with_instance_variable"
expect(response).to be_successful
Expand Down
1 change: 1 addition & 0 deletions spec/rails/rails_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
if Rails.gem_version >= Gem::Version.new("7.1.0")
config.active_support.cache_format_version = 7.1
end
config.autoload_paths << "#{root}/services"
end

require 'rspec/rails'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true
class Arbre::Components::AutoloadableComponent < Arbre::Component
builder_method :autoloadable_component

def build
div "Autoloadable Component"
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
autoloadable_component