Sha256: ad40d424538baa9cc6f8940ef9f0fe1b7234ed8101b4b93ea35475ae0b1b3b6c

Contents?: true

Size: 1.6 KB

Versions: 12

Compression:

Stored size: 1.6 KB

Contents

Feature: render_template matcher

  The `render_template` matcher is used to specify that a request renders a
  given template.  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
  specs (spec/requests).

  NOTE: use `redirect_to(:action => 'new')` for redirects, not `render_template`.

  Scenario: render_template with three possible options
    Given a file named "spec/controllers/gadgets_spec.rb" with:
      """ruby
      require "spec_helper"

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

          it "renders the index template" do
            expect(subject).to render_template(:index)
            expect(subject).to render_template("index")
            expect(subject).to render_template("gadgets/index")
          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
      require "spec_helper"

      describe "gadgets/index" do
        it "renders the index template" do
          assign(:gadgets, [stub_model(Gadget)])
          render

          expect(view).to render_template(:index)
          expect(view).to render_template("index")
          expect(view).to render_template("gadgets/index")
        end
      end
      """
    When I run `rspec spec/views`
    Then the examples should all pass

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-rails-2.13.0/features/matchers/render_template_matcher.feature
rspec-rails-3.0.0.beta2 features/matchers/render_template_matcher.feature
rspec-rails-2.99.0.beta2 features/matchers/render_template_matcher.feature
rspec-rails-2.14.1 features/matchers/render_template_matcher.feature
rspec-rails-3.0.0.beta1 features/matchers/render_template_matcher.feature
rspec-rails-2.99.0.beta1 features/matchers/render_template_matcher.feature
rspec-rails-2.14.0 features/matchers/render_template_matcher.feature
rspec-rails-2.13.1 features/matchers/render_template_matcher.feature
rspec-rails-2.13.0 features/matchers/render_template_matcher.feature
rspec-rails-2.12.2 features/matchers/render_template_matcher.feature
rspec-rails-2.12.1 features/matchers/render_template_matcher.feature
rspec-rails-2.12.0 features/matchers/render_template_matcher.feature