Skip to content

Commit e1aeb7b

Browse files
committed
Add tests
1 parent b75e00d commit e1aeb7b

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

spec/rails/integration/rendering_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ def render_with_instance_variable
2727
render "arbre/page_with_assignment"
2828
end
2929

30+
def render_with_autoloadable_component
31+
render "arbre/page_with_autoloadable_component"
32+
end
33+
3034
def render_partial_with_instance_variable
3135
@my_instance_var = "From Instance Var"
3236
render "arbre/page_with_arb_partial_and_assignment"
@@ -47,6 +51,7 @@ def render_with_block
4751
get 'test/render_partial', controller: "test"
4852
get 'test/render_erb_partial', controller: "test"
4953
get 'test/render_with_instance_variable', controller: "test"
54+
get 'test/render_with_autoloadable_component', controller: "test"
5055
get 'test/render_partial_with_instance_variable', controller: "test"
5156
get 'test/render_page_with_helpers', controller: "test"
5257
get 'test/render_with_block', controller: "test"
@@ -95,6 +100,12 @@ def render_with_block
95100
expect(body).to have_css("h1", text: "From Instance Var")
96101
end
97102

103+
it "renders with autoloadable component" do
104+
get "/test/render_with_autoloadable_component"
105+
expect(response).to be_successful
106+
expect(body).to have_css("div", text: "Autoloadable Component")
107+
end
108+
98109
it "renders an arbre partial with assignments" do
99110
get "/test/render_partial_with_instance_variable"
100111
expect(response).to be_successful

spec/rails/rails_spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
if Rails.gem_version >= Gem::Version.new("7.1.0")
77
config.active_support.cache_format_version = 7.1
88
end
9+
config.autoload_paths << "#{root}/services"
910
end
1011

1112
require 'rspec/rails'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
class Arbre::Components::AutoloadableComponent < Arbre::Component
3+
builder_method :autoloadable_component
4+
5+
def build
6+
div "Autoloadable Component"
7+
end
8+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
autoloadable_component

0 commit comments

Comments
 (0)