Sha256: 517010be66094bb1f194e3fd916ebbdb7489466e04ae602584765ac2e0791ebe

Contents?: true

Size: 1.38 KB

Versions: 12

Compression:

Stored size: 1.38 KB

Contents

Feature: redirect_to matcher

  The `redirect_to` matcher is used to specify that a request redirects to a
  given template or action.  It delegates to
  [`assert_redirected_to`](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/ResponseAssertions.html#method-i-assert_redirected_to).

  It is available in controller specs (spec/controllers) and request
  specs (spec/requests).

  Scenario: redirect_to with four possible options
    Given a file named "spec/controllers/widgets_controller_spec.rb" with:
      """ruby
      require "spec_helper"

      describe WidgetsController do

        describe "#create" do
          subject { post :create, :widget => { :name => "Foo" } }

          it "redirects to widget_url(@widget)" do
            expect(subject).to redirect_to(widget_url(assigns(:widget)))
          end

          it "redirects_to :action => :show" do
            expect(subject).to redirect_to :action => :show,
                                           :id => assigns(:widget).id
          end

          it "redirects_to(@widget)" do
            expect(subject).to redirect_to(assigns(:widget))
          end

          it "redirects_to /widgets/:id" do
            expect(subject).to redirect_to("/widgets/#{assigns(:widget).id}")
          end
        end
      end
      """
    When I run `rspec spec/controllers/widgets_controller_spec.rb`
    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/redirect_to_matcher.feature
rspec-rails-3.0.0.beta2 features/matchers/redirect_to_matcher.feature
rspec-rails-2.99.0.beta2 features/matchers/redirect_to_matcher.feature
rspec-rails-2.14.1 features/matchers/redirect_to_matcher.feature
rspec-rails-3.0.0.beta1 features/matchers/redirect_to_matcher.feature
rspec-rails-2.99.0.beta1 features/matchers/redirect_to_matcher.feature
rspec-rails-2.14.0 features/matchers/redirect_to_matcher.feature
rspec-rails-2.13.1 features/matchers/redirect_to_matcher.feature
rspec-rails-2.13.0 features/matchers/redirect_to_matcher.feature
rspec-rails-2.12.2 features/matchers/redirect_to_matcher.feature
rspec-rails-2.12.1 features/matchers/redirect_to_matcher.feature
rspec-rails-2.12.0 features/matchers/redirect_to_matcher.feature