Sha256: 1229220716b1efdd34f067e32414db30aa692b5e2e6a26496d709bea7b1e118c

Contents?: true

Size: 1.27 KB

Versions: 16

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

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

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

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

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

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

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

      controller.should_not redirect_to('/some/url')
    end
  end

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

    matcher.description.should == 'redirect to somewhere else'
  end
end

Version data entries

16 entries across 15 versions & 2 rubygems

Version Path
shoulda-matchers-2.4.0.rc1 spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-2.3.0 spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
challah-1.0.0 vendor/bundle/gems/shoulda-matchers-2.2.0/spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-2.2.0 spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
challah-1.0.0.beta3 vendor/bundle/gems/shoulda-matchers-2.1.0/spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
challah-1.0.0.beta3 vendor/bundle/gems/shoulda-matchers-1.5.6/spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-2.1.0 spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
challah-1.0.0.beta2 vendor/bundle/gems/shoulda-matchers-1.5.6/spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
challah-1.0.0.beta vendor/bundle/gems/shoulda-matchers-1.5.6/spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-2.0.0 spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-1.5.6 spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-1.5.5 spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-1.5.4 spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-1.5.2 spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-1.5.1 spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
shoulda-matchers-1.5.0 spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb