Sha256: 1558886e80f7aa2f412c9b2e66f315336b2522fb37b810426ad087b37e5b63bb

Contents?: true

Size: 1.32 KB

Versions: 12

Compression:

Stored size: 1.32 KB

Contents

require 'unit_spec_helper'

describe Shoulda::Matchers::ActionController::RedirectToMatcher, type: :controller do
  context 'a controller that redirects' do
    it 'accepts redirecting to that url' do
      expect(controller_redirecting_to('/some/url')).to redirect_to('/some/url')
    end

    it 'rejects redirecting to a different url' do
      expect(controller_redirecting_to('/some/url')).
        not_to redirect_to('/some/other/url')
    end

    it 'accepts redirecting to that url in a block' do
      expect(controller_redirecting_to('/some/url')).
        to redirect_to('somewhere') { '/some/url' }
    end

    it 'rejects redirecting to a different url in a block' do
      expect(controller_redirecting_to('/some/url')).
        not_to redirect_to('somewhere else') { '/some/other/url' }
    end

    def controller_redirecting_to(url)
      build_fake_response { redirect_to url }
    end
  end

  context 'a controller that does not redirect' do
    it 'rejects redirecting to a url' do
      controller = build_fake_response { render text: 'hello' }

      expect(controller).not_to redirect_to('/some/url')
    end
  end

  it 'provides the correct description when provided a block' do
    matcher = redirect_to('somewhere else') { '/some/other/url' }

    expect(matcher.description).to eq 'redirect to "somewhere else"'
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
shoulda-matchers-3.1.3 spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-4.0.0.rc1 spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-3.1.2 spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/shoulda-matchers-2.8.0/spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-3.1.1 spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-3.1.0 spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-3.0.1 spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-3.0.0 spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-3.0.0.rc1 spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-2.8.0 spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-2.8.0.rc2 spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-2.8.0.rc1 spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb