Skip to content

Commit bedcede

Browse files
committed
Add tests to the page rendering feature
1 parent 4fe179e commit bedcede

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

spec/test/base/core/page/rendering_spec.rb

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,41 @@
66
before :all do
77
Rails.application.routes.append do
88
scope "page_rendering_components_spec" do
9-
get '/page_test', to: 'page_test#my_action', as: 'rendering_page_test_action'
9+
get '/page_rendering_test', to: 'page_rendering_test#my_action'
1010
end
1111
end
1212
Rails.application.reload_routes!
13+
14+
class ExamplePageRendering < Matestack::Ui::Page
15+
def response
16+
div do
17+
plain "ExamplePage"
18+
end
19+
end
20+
end
21+
22+
class PageRenderingTestController < ActionController::Base
23+
include Matestack::Ui::Core::Helper
24+
25+
def my_action
26+
render ExamplePageRendering
27+
end
28+
end
1329
end
1430

15-
it "wraps page content with a specific dom structure"
31+
before :each do
32+
visit "page_rendering_components_spec/page_rendering_test"
33+
end
34+
35+
it "wraps content with a specific dom structure" do
36+
expect(page).to have_xpath('//div[@id="matestack-ui"]/div[@class="matestack-page-container"]/div[@class="matestack-page-wrapper"]')
37+
end
1638

39+
it "renders its root element with a dynamic id composed of {controller} and {action}" do
40+
expect(page).to have_xpath('//div[@id="matestack-page-page-rendering-test-my-action"]')
41+
end
42+
43+
it "renders its root element with a specific class" do
44+
expect(page).to have_xpath('//div[@class="matestack-page-root"]')
45+
end
1746
end

0 commit comments

Comments
 (0)