File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 1
1
Feature : render_template matcher
2
2
3
3
The `render_template` matcher is used to specify that a request renders a
4
- given template. It delegates to
4
+ given template or layout . It delegates to
5
5
[`assert_template`](http://api.rubyonrails.org/classes/ActionController/TemplateAssertions.html#method-i-assert_template)
6
6
7
7
It is available in controller specs (spec/controllers) and request
@@ -33,6 +33,28 @@ Feature: render_template matcher
33
33
When I run `rspec spec/controllers/gadgets_spec.rb`
34
34
Then the examples should all pass
35
35
36
+ Scenario : specify that a request renders a given layout
37
+ Given a file named "spec/controllers/gadgets_spec.rb" with:
38
+ """ruby
39
+ require "rails_helper"
40
+
41
+ RSpec.describe GadgetsController do
42
+ describe "GET #index" do
43
+ subject { get :index }
44
+
45
+ it "renders the application layout" do
46
+ expect(subject).to render_template("layouts/application")
47
+ end
48
+
49
+ it "does not render a different layout" do
50
+ expect(subject).to_not render_template("layouts/admin")
51
+ end
52
+ end
53
+ end
54
+ """
55
+ When I run `rspec spec/controllers/gadgets_spec.rb`
56
+ Then the examples should all pass
57
+
36
58
Scenario : render_template in a view spec
37
59
Given a file named "spec/views/gadgets/index.html.erb_spec.rb" with:
38
60
"""ruby
You can’t perform that action at this time.
0 commit comments