Skip to content

Specify layout with render template #2063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2019
Merged
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
24 changes: 23 additions & 1 deletion features/matchers/render_template_matcher.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: render_template matcher

The `render_template` matcher is used to specify that a request renders a
given template. It delegates to
given template or layout. It delegates to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space after the period?

[`assert_template`](http://api.rubyonrails.org/classes/ActionController/TemplateAssertions.html#method-i-assert_template)

It is available in controller specs (spec/controllers) and request
Expand Down Expand Up @@ -33,6 +33,28 @@ Feature: render_template matcher
When I run `rspec spec/controllers/gadgets_spec.rb`
Then the examples should all pass

Scenario: specify that a request renders a given layout
Given a file named "spec/controllers/gadgets_spec.rb" with:
"""ruby
require "rails_helper"

RSpec.describe GadgetsController do
describe "GET #index" do
subject { get :index }

it "renders the application layout" do
expect(subject).to render_template("layouts/application")
end

it "does not render a different layout" do
expect(subject).to_not render_template("layouts/admin")
end
end
end
"""
When I run `rspec spec/controllers/gadgets_spec.rb`
Then the examples should all pass

Scenario: render_template in a view spec
Given a file named "spec/views/gadgets/index.html.erb_spec.rb" with:
"""ruby
Expand Down