diff --git a/features/matchers/render_template_matcher.feature b/features/matchers/render_template_matcher.feature index 0fc5b21498..cfb3dbad68 100644 --- a/features/matchers/render_template_matcher.feature +++ b/features/matchers/render_template_matcher.feature @@ -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 [`assert_template`](http://api.rubyonrails.org/classes/ActionController/TemplateAssertions.html#method-i-assert_template) It is available in controller specs (spec/controllers) and request @@ -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