Sha256: 319c93b4c19bceabb2ea0c318d94fe3e5502c2edee243277940b14b77e3ef4e6
Contents?: true
Size: 1.86 KB
Versions: 2
Compression:
Stored size: 1.86 KB
Contents
require 'spec_helper' describe Tarquinn::Engine do let(:redirection_path) { '/path' } let(:redirection_path2) { '/path2' } let(:controller) do double('controller', redirect_path: redirection_path, redirect_path2: redirection_path2) end let(:config) { Tarquinn::Config.new(:redirect_path) } let(:config2) { Tarquinn::Config.new(:redirect_path2) } let(:configs) { { redirect_path: config, redirect_path2: config2 } } let(:subject) do described_class.new configs, Tarquinn::Controller.new(controller) end describe '#perform_redirect' do context 'when no redirection should be performed' do before do config.add_skip_rules { true } config2.add_skip_rules { true } end it 'redirects to the first redirection' do expect(controller).not_to receive(:redirect_to) subject.perform_redirect end end context 'when all redirection are required' do before do config.add_redirection_rules { true } config2.add_redirection_rules { true } end it do expect(controller).to receive(:redirect_to).with(redirection_path) subject.perform_redirect end end context 'when only one allow for redirection' do context 'when its the first redirection' do before do config.add_redirection_rules { true } config2.add_skip_rules { true } end it do expect(controller).to receive(:redirect_to).with(redirection_path) subject.perform_redirect end end context 'when its the second redirection' do before do config.add_skip_rules { true } config2.add_redirection_rules { true } end it do expect(controller).to receive(:redirect_to).with(redirection_path2) subject.perform_redirect end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tarquinn-0.2.0 | spec/lib/tarquinn/engine_spec.rb |
tarquinn-0.1.0 | spec/lib/tarquinn/engine_spec.rb |