Skip to content

Commit

Permalink
Add failing test for rendering explicit template
Browse files Browse the repository at this point in the history
  • Loading branch information
Burgestrand committed Nov 27, 2023
1 parent 1799dca commit 36f9e56
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec/internal/app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ def index
end

def show; end

def preview
render Articles::PreviewView
end
end
7 changes: 7 additions & 0 deletions spec/internal/app/views/articles/preview_view.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class Articles::PreviewView < Phlex::HTML
def template
render(template: "articles/show")
end
end
1 change: 1 addition & 0 deletions spec/internal/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@

get "articles/index", to: "articles#index"
get "articles/show", to: "articles#show"
get "articles/preview", to: "articles#preview"
end
6 changes: 6 additions & 0 deletions spec/layout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@

expect(response.body).to eq %(<!DOCTYPE html><html><head><title>Article</title></head><body><main>\n<h1>Article</h1>\n</main></body></html>)
end

it "supports rendering templates" do
get "/articles/preview"

expect(response.body).to eq %(<!DOCTYPE html><html><head><title>Article</title></head><body><main>\n<h1>Article</h1>\n</main></body></html>)
end
end

0 comments on commit 36f9e56

Please sign in to comment.